aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-19 07:57:50 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-19 08:00:13 +1000
commita2fdac2c4b81b6da95b914a5f65fb297cb8d4ce4 (patch)
treecc3e83eae5042db2ca75b063413d4d8403e79a7a /sway
parentMerge pull request #2874 from ianyfan/swaybar (diff)
downloadsway-a2fdac2c4b81b6da95b914a5f65fb297cb8d4ce4.tar.gz
sway-a2fdac2c4b81b6da95b914a5f65fb297cb8d4ce4.tar.zst
sway-a2fdac2c4b81b6da95b914a5f65fb297cb8d4ce4.zip
Consider cursor warp when switching workspaces
Fixes a regression introduced in 24a90e5d86441fc345356eb3767e5a6880dcedbd. consider_warp_to_focus has been renamed to seat_consider_warp_to_focus, moved to seat.c and made public. It is now called when switching workspaces via `workspace <ws>`.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/focus.c30
-rw-r--r--sway/commands/workspace.c1
-rw-r--r--sway/input/seat.c18
3 files changed, 25 insertions, 24 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 46304ae0..b6f29fec 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -34,24 +34,6 @@ static bool parse_movement_direction(const char *name,
34 return true; 34 return true;
35} 35}
36 36
37static void consider_warp_to_focus(struct sway_seat *seat) {
38 struct sway_node *focus = seat_get_focus(seat);
39 if (config->mouse_warping == WARP_NO || !focus || !seat->prev_focus) {
40 return;
41 }
42 if (config->mouse_warping == WARP_OUTPUT &&
43 node_get_output(focus) == node_get_output(seat->prev_focus)) {
44 return;
45 }
46
47 if (focus->type == N_CONTAINER) {
48 cursor_warp_to_container(seat->cursor, focus->sway_container);
49 } else {
50 cursor_warp_to_workspace(seat->cursor, focus->sway_workspace);
51 }
52 cursor_send_pointer_motion(seat->cursor, 0, false);
53}
54
55/** 37/**
56 * Get node in the direction of newly entered output. 38 * Get node in the direction of newly entered output.
57 */ 39 */
@@ -199,7 +181,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
199 } 181 }
200 if (new_focus) { 182 if (new_focus) {
201 seat_set_focus_container(seat, new_focus); 183 seat_set_focus_container(seat, new_focus);
202 consider_warp_to_focus(seat); 184 seat_consider_warp_to_focus(seat);
203 } else { 185 } else {
204 return cmd_results_new(CMD_FAILURE, "focus", 186 return cmd_results_new(CMD_FAILURE, "focus",
205 "Failed to find a %s container in workspace", 187 "Failed to find a %s container in workspace",
@@ -232,7 +214,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
232 free(identifier); 214 free(identifier);
233 if (output) { 215 if (output) {
234 seat_set_focus(seat, seat_get_focus_inactive(seat, &output->node)); 216 seat_set_focus(seat, seat_get_focus_inactive(seat, &output->node));
235 consider_warp_to_focus(seat); 217 seat_consider_warp_to_focus(seat);
236 } 218 }
237 219
238 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 220 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@@ -253,7 +235,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
253 235
254 if (argc == 0 && container) { 236 if (argc == 0 && container) {
255 seat_set_focus_container(seat, container); 237 seat_set_focus_container(seat, container);
256 consider_warp_to_focus(seat); 238 seat_consider_warp_to_focus(seat);
257 cursor_send_pointer_motion(seat->cursor, 0, true); 239 cursor_send_pointer_motion(seat->cursor, 0, true);
258 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 240 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
259 } 241 }
@@ -283,7 +265,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
283 struct sway_node *focus = seat_get_active_tiling_child(seat, node); 265 struct sway_node *focus = seat_get_active_tiling_child(seat, node);
284 if (focus) { 266 if (focus) {
285 seat_set_focus(seat, focus); 267 seat_set_focus(seat, focus);
286 consider_warp_to_focus(seat); 268 seat_consider_warp_to_focus(seat);
287 } 269 }
288 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 270 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
289 } 271 }
@@ -303,7 +285,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
303 struct sway_node *node = 285 struct sway_node *node =
304 get_node_in_output_direction(new_output, direction); 286 get_node_in_output_direction(new_output, direction);
305 seat_set_focus(seat, node); 287 seat_set_focus(seat, node);
306 consider_warp_to_focus(seat); 288 seat_consider_warp_to_focus(seat);
307 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 289 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
308 } 290 }
309 291
@@ -311,7 +293,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
311 node_get_in_direction(container, seat, direction); 293 node_get_in_direction(container, seat, direction);
312 if (next_focus) { 294 if (next_focus) {
313 seat_set_focus(seat, next_focus); 295 seat_set_focus(seat, next_focus);
314 consider_warp_to_focus(seat); 296 seat_consider_warp_to_focus(seat);
315 } 297 }
316 298
317 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 299 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 58c2201d..da597f8a 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -157,6 +157,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
157 free(name); 157 free(name);
158 } 158 }
159 workspace_switch(ws, no_auto_back_and_forth); 159 workspace_switch(ws, no_auto_back_and_forth);
160 seat_consider_warp_to_focus(config->handler_context.seat);
160 } 161 }
161 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 162 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
162} 163}
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 60ee27d0..08b2e7cf 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1187,3 +1187,21 @@ void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
1187 seat->last_button_serial = wlr_seat_pointer_notify_button(seat->wlr_seat, 1187 seat->last_button_serial = wlr_seat_pointer_notify_button(seat->wlr_seat,
1188 time_msec, button, state); 1188 time_msec, button, state);
1189} 1189}
1190
1191void seat_consider_warp_to_focus(struct sway_seat *seat) {
1192 struct sway_node *focus = seat_get_focus(seat);
1193 if (config->mouse_warping == WARP_NO || !focus || !seat->prev_focus) {
1194 return;
1195 }
1196 if (config->mouse_warping == WARP_OUTPUT &&
1197 node_get_output(focus) == node_get_output(seat->prev_focus)) {
1198 return;
1199 }
1200
1201 if (focus->type == N_CONTAINER) {
1202 cursor_warp_to_container(seat->cursor, focus->sway_container);
1203 } else {
1204 cursor_warp_to_workspace(seat->cursor, focus->sway_workspace);
1205 }
1206 cursor_send_pointer_motion(seat->cursor, 0, false);
1207}