aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--sway/input/cursor.c5
-rw-r--r--sway/input/seat.c13
3 files changed, 12 insertions, 9 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 496bfd5d..31210a5a 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -56,6 +56,9 @@ void sway_seat_configure_xcursor(struct sway_seat *seat);
56 56
57void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container); 57void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container);
58 58
59void sway_seat_set_focus_warp(struct sway_seat *seat,
60 struct sway_container *container, bool warp);
61
59struct sway_container *sway_seat_get_focus(struct sway_seat *seat); 62struct sway_container *sway_seat_get_focus(struct sway_seat *seat);
60 63
61/** 64/**
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 2a096033..4a3f558d 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -120,9 +120,6 @@ 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
126static void cursor_send_pointer_motion(struct sway_cursor *cursor, 123static void cursor_send_pointer_motion(struct sway_cursor *cursor,
127 uint32_t time) { 124 uint32_t time) {
128 struct wlr_seat *seat = cursor->seat->wlr_seat; 125 struct wlr_seat *seat = cursor->seat->wlr_seat;
@@ -130,7 +127,7 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
130 double sx, sy; 127 double sx, sy;
131 struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy); 128 struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy);
132 if (c && config->focus_follows_mouse) { 129 if (c && config->focus_follows_mouse) {
133 _sway_seat_set_focus(cursor->seat, c, false); 130 sway_seat_set_focus_warp(cursor->seat, c, false);
134 } 131 }
135 132
136 // reset cursor if switching between clients 133 // reset cursor if switching between clients
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 4e7e018d..9aa34aca 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1,5 +1,6 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#include <wlr/types/wlr_cursor.h> 2#include <wlr/types/wlr_cursor.h>
3#include <wlr/types/wlr_output_layout.h>
3#include <wlr/types/wlr_xcursor_manager.h> 4#include <wlr/types/wlr_xcursor_manager.h>
4#include "sway/tree/container.h" 5#include "sway/tree/container.h"
5#include "sway/input/seat.h" 6#include "sway/input/seat.h"
@@ -291,7 +292,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
291 seat->cursor->cursor->y); 292 seat->cursor->cursor->y);
292} 293}
293 294
294void _sway_seat_set_focus(struct sway_seat *seat, 295void sway_seat_set_focus_warp(struct sway_seat *seat,
295 struct sway_container *container, bool warp) { 296 struct sway_container *container, bool warp) {
296 struct sway_container *last_focus = sway_seat_get_focus(seat); 297 struct sway_container *last_focus = sway_seat_get_focus(seat);
297 298
@@ -351,12 +352,14 @@ void _sway_seat_set_focus(struct sway_seat *seat,
351 } 352 }
352 if (new_output && last_output && new_output != last_output 353 if (new_output && last_output && new_output != last_output
353 && config->mouse_warping && warp) { 354 && config->mouse_warping && warp) {
354 wlr_log(L_DEBUG, "warpin the mouse baby");
355 struct wlr_output *output = new_output->sway_output->wlr_output; 355 struct wlr_output *output = new_output->sway_output->wlr_output;
356 // TODO: Change container coords to layout coords
357 double x = container->x + output->lx + container->width / 2.0; 356 double x = container->x + output->lx + container->width / 2.0;
358 double y = container->y + output->ly + container->height / 2.0; 357 double y = container->y + output->ly + container->height / 2.0;
359 wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); 358 if (!wlr_output_layout_contains_point(
359 root_container.sway_root->output_layout,
360 output, seat->cursor->cursor->x, seat->cursor->cursor->y)) {
361 wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
362 }
360 } 363 }
361 } 364 }
362 365
@@ -371,7 +374,7 @@ void _sway_seat_set_focus(struct sway_seat *seat,
371 374
372void sway_seat_set_focus(struct sway_seat *seat, 375void sway_seat_set_focus(struct sway_seat *seat,
373 struct sway_container *container) { 376 struct sway_container *container) {
374 _sway_seat_set_focus(seat, container, true); 377 sway_seat_set_focus_warp(seat, container, true);
375} 378}
376 379
377struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { 380struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) {