aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-10-31 19:56:40 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-11-01 03:43:00 -0500
commit60d95414d4a7ff163099c9e551ec435cb0cb7eca (patch)
tree1a4bcf041850390d00f05e78884dab51b4ef0c35 /sway/input/cursor.c
parentinput: remove motion deltas from seatop callbacks (diff)
downloadsway-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.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c17
1 files changed, 12 insertions, 5 deletions
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
314void cursor_unhide(struct sway_cursor *cursor) { 314void 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 */
1147void cursor_warp_to_container(struct sway_cursor *cursor, 1151void 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
1181uint32_t get_mouse_bindsym(const char *name, char **error) { 1188uint32_t get_mouse_bindsym(const char *name, char **error) {