diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-31 10:49:52 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-31 13:05:45 -0400 |
commit | ae6d459000865f0a3a54a1d0429ee28b282a7954 (patch) | |
tree | 264caea4be15679d6da1ffa51c3056780827149d /sway/input/seat.c | |
parent | Check for null container (diff) | |
download | sway-ae6d459000865f0a3a54a1d0429ee28b282a7954.tar.gz sway-ae6d459000865f0a3a54a1d0429ee28b282a7954.tar.zst sway-ae6d459000865f0a3a54a1d0429ee28b282a7954.zip |
Implement mouse warping
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 18 |
1 files changed, 16 insertions, 2 deletions
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 && |