diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-10-31 19:56:40 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2020-11-01 03:43:00 -0500 |
commit | 60d95414d4a7ff163099c9e551ec435cb0cb7eca (patch) | |
tree | 1a4bcf041850390d00f05e78884dab51b4ef0c35 | |
parent | input: remove motion deltas from seatop callbacks (diff) | |
download | sway-60d95414d4a7ff163099c9e551ec435cb0cb7eca.tar.gz sway-60d95414d4a7ff163099c9e551ec435cb0cb7eca.tar.zst sway-60d95414d4a7ff163099c9e551ec435cb0cb7eca.zip |
commands/focus: force container warp when fulfilling `focus mode_toggle`
This commit switches focusing behavior to force a warp when executing
`focus mode_toggle`.
Fixes #5772.
-rw-r--r-- | include/sway/input/cursor.h | 2 | ||||
-rw-r--r-- | sway/commands/focus.c | 11 | ||||
-rw-r--r-- | sway/input/cursor.c | 17 | ||||
-rw-r--r-- | sway/input/seat.c | 5 |
4 files changed, 24 insertions, 11 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index ca3c6f4b..55e2ce8e 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -116,7 +116,7 @@ void cursor_set_image_surface(struct sway_cursor *cursor, | |||
116 | struct wl_client *client); | 116 | struct wl_client *client); |
117 | 117 | ||
118 | void cursor_warp_to_container(struct sway_cursor *cursor, | 118 | void cursor_warp_to_container(struct sway_cursor *cursor, |
119 | struct sway_container *container); | 119 | struct sway_container *container, bool force); |
120 | 120 | ||
121 | void cursor_warp_to_workspace(struct sway_cursor *cursor, | 121 | void cursor_warp_to_workspace(struct sway_cursor *cursor, |
122 | struct sway_workspace *workspace); | 122 | struct sway_workspace *workspace); |
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 56c3d981..79b7aed5 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -268,7 +268,16 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, | |||
268 | } | 268 | } |
269 | if (new_focus) { | 269 | if (new_focus) { |
270 | seat_set_focus_container(seat, new_focus); | 270 | seat_set_focus_container(seat, new_focus); |
271 | seat_consider_warp_to_focus(seat); | 271 | |
272 | // If we're on the floating layer and the floating container area | ||
273 | // overlaps the position on the tiling layer that would be warped to, | ||
274 | // `seat_consider_warp_to_focus` would decide not to warp, but we need | ||
275 | // to anyway. | ||
276 | if (config->mouse_warping == WARP_CONTAINER) { | ||
277 | cursor_warp_to_container(seat->cursor, new_focus, true); | ||
278 | } else { | ||
279 | seat_consider_warp_to_focus(seat); | ||
280 | } | ||
272 | } else { | 281 | } else { |
273 | return cmd_results_new(CMD_FAILURE, | 282 | return cmd_results_new(CMD_FAILURE, |
274 | "Failed to find a %s container in workspace", | 283 | "Failed to find a %s container in workspace", |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 9ad4900b..5c883924 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -306,12 +306,16 @@ void cursor_handle_activity(struct sway_cursor *cursor, | |||
306 | 306 | ||
307 | enum sway_input_idle_source idle_source = idle_source_from_device(device); | 307 | enum sway_input_idle_source idle_source = idle_source_from_device(device); |
308 | seat_idle_notify_activity(cursor->seat, idle_source); | 308 | seat_idle_notify_activity(cursor->seat, idle_source); |
309 | if (cursor->hidden && idle_source != IDLE_SOURCE_TOUCH) { | 309 | if (idle_source != IDLE_SOURCE_TOUCH) { |
310 | cursor_unhide(cursor); | 310 | cursor_unhide(cursor); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | void cursor_unhide(struct sway_cursor *cursor) { | 314 | void cursor_unhide(struct sway_cursor *cursor) { |
315 | if (!cursor->hidden) { | ||
316 | return; | ||
317 | } | ||
318 | |||
315 | cursor->hidden = false; | 319 | cursor->hidden = false; |
316 | if (cursor->image_surface) { | 320 | if (cursor->image_surface) { |
317 | cursor_set_image_surface(cursor, | 321 | cursor_set_image_surface(cursor, |
@@ -1141,18 +1145,19 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | |||
1141 | 1145 | ||
1142 | /** | 1146 | /** |
1143 | * Warps the cursor to the middle of the container argument. | 1147 | * Warps the cursor to the middle of the container argument. |
1144 | * Does nothing if the cursor is already inside the container. | 1148 | * Does nothing if the cursor is already inside the container and `force` is |
1145 | * If container is NULL, returns without doing anything. | 1149 | * false. If container is NULL, returns without doing anything. |
1146 | */ | 1150 | */ |
1147 | void cursor_warp_to_container(struct sway_cursor *cursor, | 1151 | void cursor_warp_to_container(struct sway_cursor *cursor, |
1148 | struct sway_container *container) { | 1152 | struct sway_container *container, bool force) { |
1149 | if (!container) { | 1153 | if (!container) { |
1150 | return; | 1154 | return; |
1151 | } | 1155 | } |
1152 | 1156 | ||
1153 | struct wlr_box box; | 1157 | struct wlr_box box; |
1154 | container_get_box(container, &box); | 1158 | container_get_box(container, &box); |
1155 | if (wlr_box_contains_point(&box, cursor->cursor->x, cursor->cursor->y)) { | 1159 | if (!force && wlr_box_contains_point(&box, cursor->cursor->x, |
1160 | cursor->cursor->y)) { | ||
1156 | return; | 1161 | return; |
1157 | } | 1162 | } |
1158 | 1163 | ||
@@ -1160,6 +1165,7 @@ void cursor_warp_to_container(struct sway_cursor *cursor, | |||
1160 | double y = container->y + container->height / 2.0; | 1165 | double y = container->y + container->height / 2.0; |
1161 | 1166 | ||
1162 | wlr_cursor_warp(cursor->cursor, NULL, x, y); | 1167 | wlr_cursor_warp(cursor->cursor, NULL, x, y); |
1168 | cursor_unhide(cursor); | ||
1163 | } | 1169 | } |
1164 | 1170 | ||
1165 | /** | 1171 | /** |
@@ -1176,6 +1182,7 @@ void cursor_warp_to_workspace(struct sway_cursor *cursor, | |||
1176 | double y = workspace->y + workspace->height / 2.0; | 1182 | double y = workspace->y + workspace->height / 2.0; |
1177 | 1183 | ||
1178 | wlr_cursor_warp(cursor->cursor, NULL, x, y); | 1184 | wlr_cursor_warp(cursor->cursor, NULL, x, y); |
1185 | cursor_unhide(cursor); | ||
1179 | } | 1186 | } |
1180 | 1187 | ||
1181 | uint32_t get_mouse_bindsym(const char *name, char **error) { | 1188 | uint32_t get_mouse_bindsym(const char *name, char **error) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index e178c08a..24d7e903 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1477,13 +1477,10 @@ void seat_consider_warp_to_focus(struct sway_seat *seat) { | |||
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | if (focus->type == N_CONTAINER) { | 1479 | if (focus->type == N_CONTAINER) { |
1480 | cursor_warp_to_container(seat->cursor, focus->sway_container); | 1480 | cursor_warp_to_container(seat->cursor, focus->sway_container, false); |
1481 | } else { | 1481 | } else { |
1482 | cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); | 1482 | cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); |
1483 | } | 1483 | } |
1484 | if (seat->cursor->hidden){ | ||
1485 | cursor_unhide(seat->cursor); | ||
1486 | } | ||
1487 | } | 1484 | } |
1488 | 1485 | ||
1489 | void seatop_unref(struct sway_seat *seat, struct sway_container *con) { | 1486 | void seatop_unref(struct sway_seat *seat, struct sway_container *con) { |