1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
--- a/plugins/cube/cube.cpp
+++ b/plugins/cube/cube.cpp
@@ -330,12 +330,21 @@
cube_render_node_t(wayfire_cube *cube) : node_t(false)
{
this->cube = cube;
- auto w = cube->output->wset()->get_workspace_grid_size().width;
- auto y = cube->output->wset()->get_current_workspace().y;
- for (int i = 0; i < w; i++)
- {
+ auto grid = cube->output->wset()->get_workspace_grid_size();
+ auto current = cube->output->wset()->get_current_workspace();
+ int count = cube->vertical_transition ? grid.height : grid.width;
+ for (int i = 0; i < count; i++)
+ {
+ wf::point_t workspace = cube->vertical_transition ?
+ wf::point_t{current.x, i} : wf::point_t{i, current.y};
+ if (cube->vertical_transition && cube->workspace_animation_anchor &&
+ (i == cube->workspace_animation_anchor->y))
+ {
+ workspace.x = cube->workspace_animation_anchor->x;
+ }
+
auto node = std::make_shared<wf::workspace_stream_node_t>(
- cube->output, wf::point_t{i, y});
+ cube->output, workspace);
node->background = wf::color_t{0.0, 0.0, 0.0, 0.0};
node->include_desktop_environment = false;
workspaces.push_back(node);
@@ -392,6 +401,8 @@
* for the given FOV */
float identity_z_offset = 0.0f;
int geometry_faces = 0;
+ int geometry_rows = 0;
+ bool vertical_transition = false;
OpenGL::program_t program;
@@ -399,6 +410,9 @@
std::make_shared<wf::config::option_t<wf::animation_description_t>>(
"cube-runtime-animation", wf::animation_description_t{});
wf_cube_animation_attribs animation{runtime_duration};
+ // Keep added state local: resident Cube libraries export the original
+ // animation attributes, whose layout must remain compatible on reload.
+ timed_transition_t row_rotation{animation.cube_animation};
void start_animation(int duration_limit_ms = -1)
{
@@ -455,15 +469,27 @@
return output->wset()->get_workspace_grid_size().width;
}
+ static float row_side_angle(int rows)
+ {
+ // Rows span at most half a turn, like latitudes from pole to pole.
+ return M_PI / std::max(2, rows - 1);
+ }
+
+ static float row_z_offset(int rows)
+ {
+ return 0.5 / std::tan(row_side_angle(rows) / 2);
+ }
+
bool refresh_cube_geometry()
{
- int faces = get_num_faces();
- if (faces == geometry_faces)
+ auto grid = output->wset()->get_workspace_grid_size();
+ int faces = grid.width;
+ if ((faces == geometry_faces) && (grid.height == geometry_rows))
{
return false;
}
- float old_offset = identity_z_offset;
+ float old_offset = vertical_transition ? row_z_offset(geometry_rows) : identity_z_offset;
animation.side_angle = 2 * M_PI / float(faces);
identity_z_offset = faces == 1 ? 0.0f :
0.5 / std::tan(animation.side_angle / 2);
@@ -471,13 +497,27 @@
{
// Preserve the camera's distance from the cube when a new
// workspace count changes its radius.
- float offset = animation.cube_animation.offset_z +
- identity_z_offset - old_offset;
+ float new_offset = vertical_transition ? row_z_offset(grid.height) : identity_z_offset;
+ float offset = animation.cube_animation.offset_z + new_offset - old_offset;
animation.cube_animation.offset_z.set(offset, offset);
}
geometry_faces = faces;
+ geometry_rows = grid.height;
return true;
+ }
+
+ void end_vertical_transition()
+ {
+ if (vertical_transition)
+ {
+ vertical_transition = false;
+ row_rotation.set(0, 0);
+ animation.cube_animation.offset_z.set(identity_z_offset + Z_OFFSET_NEAR,
+ identity_z_offset + Z_OFFSET_NEAR);
+ rebuild_cube_render_node();
+ output->render->damage_whole();
+ }
}
wf::plugin_activation_data_t grab_interface{
@@ -609,6 +649,7 @@
return;
}
+ end_vertical_transition();
float offset_z = identity_z_offset + Z_OFFSET_NEAR;
animation.cube_animation.rotation.set(angle, angle);
@@ -636,6 +677,13 @@
{
fixed_view = nullptr;
}
+
+ const float previous_pitch = vertical_transition ?
+ float(row_rotation) : 0.0f;
+ vertical_transition = delta.y != 0;
+ const int rows = output->wset()->get_workspace_grid_size().height;
+ row_rotation.set(
+ vertical_transition ? previous_pitch + delta.y * row_side_angle(rows) : 0.0f, 0.0f);
workspace_animation_anchor = anchor_workspace;
fixed_workspace_view = fixed_view;
@@ -644,13 +692,12 @@
animation.in_exit = false;
animation.cube_animation.zoom.set(1.0, 1.0);
- animation.cube_animation.offset_z.set(
- identity_z_offset + Z_OFFSET_NEAR,
- identity_z_offset + Z_OFFSET_NEAR);
+ const float radius = vertical_transition ? row_z_offset(rows) : identity_z_offset;
+ animation.cube_animation.offset_z.set(radius + Z_OFFSET_NEAR, radius + Z_OFFSET_NEAR);
animation.cube_animation.offset_y.set(0, 0);
animation.cube_animation.ease_deformation.set(0, 0);
- if (delta.x != 0)
+ if (!vertical_transition && (delta.x != 0))
{
animation.cube_animation.rotation.set(
delta.x * animation.side_angle,
@@ -978,6 +1025,8 @@
fixed_workspace_view = nullptr;
workspace_animation_anchor.reset();
+ vertical_transition = false;
+ row_rotation.set(0, 0);
clear_fixed_workspace_overlay();
clear_unused_fixed_top_node();
release_cube_input();
@@ -1010,6 +1059,7 @@
return false;
}
+ end_vertical_transition();
/* After the rotation is done, we want to exit cube and focus the target
* workspace */
animation.in_exit = false;
@@ -1063,6 +1113,7 @@
return false;
}
+ end_vertical_transition();
/* Rotations, offset_y and zoom stay as they are now, as they have been
* grabbed.
* offset_z changes to the default one.
@@ -1208,11 +1259,20 @@
static const GLuint indexData[] = {0, 1, 2, 0, 2, 3};
auto cws = output->wset()->get_current_workspace();
- for (int i = 0; i < get_num_faces(); i++)
- {
- int index = (cws.x + i) % get_num_faces();
+ const int count = vertical_transition ? (int)buffers.size() : get_num_faces();
+ for (int i = 0; i < count; i++)
+ {
+ int index = vertical_transition ? i : (cws.x + i) % get_num_faces();
GL_CALL(glBindTexture(GL_TEXTURE_2D, wf::gles_texture_t::from_aux(buffers[index]).tex_id));
auto model = calculate_model_matrix(i);
+ if (vertical_transition)
+ {
+ const int rows = output->wset()->get_workspace_grid_size().height;
+ const float angle = -((i - cws.y) * row_side_angle(rows) +
+ row_rotation);
+ model = glm::rotate(glm::mat4(1.0), angle, glm::vec3(1, 0, 0)) *
+ glm::translate(glm::mat4(1.0), glm::vec3(0, 0, row_z_offset(rows)));
+ }
program.uniformMatrix4f("model", model);
if (tessellation_support)
@@ -1327,6 +1387,7 @@
fixed_workspace_view = nullptr;
workspace_animation_anchor.reset();
clear_fixed_workspace_overlay();
+ end_vertical_transition();
rebuild_cube_render_node();
}
}
--- a/plugins/vswitch/vswitch.cpp
+++ b/plugins/vswitch/vswitch.cpp
@@ -353,6 +353,15 @@
{}
protected:
+ bool handle_dir(wf::point_t direction, wayfire_toplevel_view view, bool window_only,
+ binding_callback_t callback) override
+ {
+ auto current = output->wset()->get_current_workspace();
+ auto grid = output->wset()->get_workspace_grid_size();
+ direction.y = wf::clamp(current.y + direction.y, 0, grid.height - 1) - current.y;
+ return control_bindings_t::handle_dir(direction, view, window_only, callback);
+ }
+
wayfire_toplevel_view get_target_view() override
{
return target();
@@ -632,7 +641,12 @@
auto grid = output->wset()->get_workspace_grid_size();
auto target_ws = cws + delta;
target_ws.x = (target_ws.x % grid.width + grid.width) % grid.width;
- target_ws.y = (target_ws.y % grid.height + grid.height) % grid.height;
+ // Columns wrap around the globe. Rows stop at its poles.
+ target_ws.y = wf::clamp(target_ws.y, 0, grid.height - 1);
+ if (target_ws == cws)
+ {
+ return true;
+ }
auto animation_delta = target_ws - cws;
if (animation_delta.x > grid.width / 2)
{
@@ -640,14 +654,6 @@
} else if (animation_delta.x < -grid.width / 2)
{
animation_delta.x += grid.width;
- }
-
- if (animation_delta.y > grid.height / 2)
- {
- animation_delta.y -= grid.height;
- } else if (animation_delta.y < -grid.height / 2)
- {
- animation_delta.y += grid.height;
}
wayfire_toplevel_view fixed_view = nullptr;
|