aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 10:49:52 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 13:05:45 -0400
commitae6d459000865f0a3a54a1d0429ee28b282a7954 (patch)
tree264caea4be15679d6da1ffa51c3056780827149d /sway/input
parentCheck for null container (diff)
downloadsway-ae6d459000865f0a3a54a1d0429ee28b282a7954.tar.gz
sway-ae6d459000865f0a3a54a1d0429ee28b282a7954.tar.zst
sway-ae6d459000865f0a3a54a1d0429ee28b282a7954.zip
Implement mouse warping
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c4
-rw-r--r--sway/input/seat.c18
2 files changed, 18 insertions, 4 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 74af6426..9cdd66d8 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -156,8 +156,8 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
156 cursor_send_pointer_motion(cursor, event->time_msec); 156 cursor_send_pointer_motion(cursor, event->time_msec);
157} 157}
158 158
159static void handle_cursor_motion_absolute(struct wl_listener *listener, 159static void handle_cursor_motion_absolute(
160 void *data) { 160 struct wl_listener *listener, void *data) {
161 struct sway_cursor *cursor = 161 struct sway_cursor *cursor =
162 wl_container_of(listener, cursor, motion_absolute); 162 wl_container_of(listener, cursor, motion_absolute);
163 struct wlr_event_pointer_motion_absolute *event = data; 163 struct wlr_event_pointer_motion_absolute *event = data;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 8d592872..eab5cf40 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -333,15 +333,29 @@ void sway_seat_set_focus(struct sway_seat *seat,
333 if (last_focus) { 333 if (last_focus) {
334 struct sway_container *last_ws = last_focus; 334 struct sway_container *last_ws = last_focus;
335 if (last_ws && last_ws->type != C_WORKSPACE) { 335 if (last_ws && last_ws->type != C_WORKSPACE) {
336 last_ws = container_parent(last_focus, C_WORKSPACE); 336 last_ws = container_parent(last_ws, C_WORKSPACE);
337 } 337 }
338 if (last_ws) { 338 if (last_ws) {
339 wlr_log(L_DEBUG, "sending workspace event");
340 ipc_event_workspace(last_ws, container, "focus"); 339 ipc_event_workspace(last_ws, container, "focus");
341 if (last_ws->children->length == 0) { 340 if (last_ws->children->length == 0) {
342 container_workspace_destroy(last_ws); 341 container_workspace_destroy(last_ws);
343 } 342 }
344 } 343 }
344 struct sway_container *last_output = last_focus;
345 if (last_output && last_output->type != C_OUTPUT) {
346 last_output = container_parent(last_output, C_OUTPUT);
347 }
348 struct sway_container *new_output = container;
349 if (new_output && new_output->type != C_OUTPUT) {
350 new_output = container_parent(new_output, C_OUTPUT);
351 }
352 if (new_output != last_output && config->mouse_warping) {
353 struct wlr_output *output = new_output->sway_output->wlr_output;
354 // TODO: Change container coords to layout coords
355 double x = container->x + output->lx + container->width / 2.0;
356 double y = container->y + output->ly + container->height / 2.0;
357 wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
358 }
345 } 359 }
346 360
347 if (last_focus && last_focus->type == C_VIEW && 361 if (last_focus && last_focus->type == C_VIEW &&