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 | eb5a8e03ff10d956de70f121bc70fd4cad524a9f (diff) |
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, if (last_focus) { struct sway_container *last_ws = last_focus; if (last_ws && last_ws->type != C_WORKSPACE) { - last_ws = container_parent(last_focus, C_WORKSPACE); + last_ws = container_parent(last_ws, C_WORKSPACE); } if (last_ws) { - wlr_log(L_DEBUG, "sending workspace event"); ipc_event_workspace(last_ws, container, "focus"); if (last_ws->children->length == 0) { container_workspace_destroy(last_ws); } } + struct sway_container *last_output = last_focus; + if (last_output && last_output->type != C_OUTPUT) { + last_output = container_parent(last_output, C_OUTPUT); + } + struct sway_container *new_output = container; + if (new_output && new_output->type != C_OUTPUT) { + new_output = container_parent(new_output, C_OUTPUT); + } + if (new_output != last_output && config->mouse_warping) { + struct wlr_output *output = new_output->sway_output->wlr_output; + // TODO: Change container coords to layout coords + double x = container->x + output->lx + container->width / 2.0; + double y = container->y + output->ly + container->height / 2.0; + wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); + } } if (last_focus && last_focus->type == C_VIEW && |