aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 11:18:29 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 13:05:45 -0400
commitb9d2983324c91f0a2805b1f10afcf2a929f939b4 (patch)
tree2a6346a760d051e01142770a16d6b92365ca01ce
parentImplement focus_follows_mouse (diff)
downloadsway-b9d2983324c91f0a2805b1f10afcf2a929f939b4.tar.gz
sway-b9d2983324c91f0a2805b1f10afcf2a929f939b4.tar.zst
sway-b9d2983324c91f0a2805b1f10afcf2a929f939b4.zip
Fix interaction between warping and following
-rw-r--r--sway/input/cursor.c5
-rw-r--r--sway/input/seat.c13
2 files changed, 14 insertions, 4 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 35dd5dc8..2a096033 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -120,6 +120,9 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
120 return NULL; 120 return NULL;
121} 121}
122 122
123void _sway_seat_set_focus(struct sway_seat *seat,
124 struct sway_container *container, bool warp);
125
123static void cursor_send_pointer_motion(struct sway_cursor *cursor, 126static void cursor_send_pointer_motion(struct sway_cursor *cursor,
124 uint32_t time) { 127 uint32_t time) {
125 struct wlr_seat *seat = cursor->seat->wlr_seat; 128 struct wlr_seat *seat = cursor->seat->wlr_seat;
@@ -127,7 +130,7 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
127 double sx, sy; 130 double sx, sy;
128 struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy); 131 struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy);
129 if (c && config->focus_follows_mouse) { 132 if (c && config->focus_follows_mouse) {
130 sway_seat_set_focus(cursor->seat, c); 133 _sway_seat_set_focus(cursor->seat, c, false);
131 } 134 }
132 135
133 // reset cursor if switching between clients 136 // reset cursor if switching between clients
diff --git a/sway/input/seat.c b/sway/input/seat.c
index eab5cf40..4e7e018d 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -291,8 +291,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
291 seat->cursor->cursor->y); 291 seat->cursor->cursor->y);
292} 292}
293 293
294void sway_seat_set_focus(struct sway_seat *seat, 294void _sway_seat_set_focus(struct sway_seat *seat,
295 struct sway_container *container) { 295 struct sway_container *container, bool warp) {
296 struct sway_container *last_focus = sway_seat_get_focus(seat); 296 struct sway_container *last_focus = sway_seat_get_focus(seat);
297 297
298 if (container && last_focus == container) { 298 if (container && last_focus == container) {
@@ -349,7 +349,9 @@ void sway_seat_set_focus(struct sway_seat *seat,
349 if (new_output && new_output->type != C_OUTPUT) { 349 if (new_output && new_output->type != C_OUTPUT) {
350 new_output = container_parent(new_output, C_OUTPUT); 350 new_output = container_parent(new_output, C_OUTPUT);
351 } 351 }
352 if (new_output != last_output && config->mouse_warping) { 352 if (new_output && last_output && new_output != last_output
353 && config->mouse_warping && warp) {
354 wlr_log(L_DEBUG, "warpin the mouse baby");
353 struct wlr_output *output = new_output->sway_output->wlr_output; 355 struct wlr_output *output = new_output->sway_output->wlr_output;
354 // TODO: Change container coords to layout coords 356 // TODO: Change container coords to layout coords
355 double x = container->x + output->lx + container->width / 2.0; 357 double x = container->x + output->lx + container->width / 2.0;
@@ -367,6 +369,11 @@ void sway_seat_set_focus(struct sway_seat *seat,
367 seat->has_focus = (container != NULL); 369 seat->has_focus = (container != NULL);
368} 370}
369 371
372void sway_seat_set_focus(struct sway_seat *seat,
373 struct sway_container *container) {
374 _sway_seat_set_focus(seat, container, true);
375}
376
370struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { 377struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) {
371 struct sway_seat_container *current = NULL; 378 struct sway_seat_container *current = NULL;
372 struct sway_container *parent = NULL; 379 struct sway_container *parent = NULL;