aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 15:32:29 -0400
committerLibravatar GitHub <noreply@github.com>2018-03-31 15:32:29 -0400
commit122b96abed9955f78e3f157167d34312f5bb551d (patch)
treefdcb6ffc0520145a029118aec443eb2199981d77 /sway/input/seat.c
parentMerge pull request #1689 from emersion/destroy-output-segfaults (diff)
parentAddress review feedback (diff)
downloadsway-122b96abed9955f78e3f157167d34312f5bb551d.tar.gz
sway-122b96abed9955f78e3f157167d34312f5bb551d.tar.zst
sway-122b96abed9955f78e3f157167d34312f5bb551d.zip
Merge pull request #1684 from swaywm/follow-warp
Implement focus_follows_mouse, mouse_warping
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 8d592872..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,8 +292,8 @@ 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) { 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
298 if (container && last_focus == container) { 299 if (container && last_focus == container) {
@@ -333,15 +334,33 @@ void sway_seat_set_focus(struct sway_seat *seat,
333 if (last_focus) { 334 if (last_focus) {
334 struct sway_container *last_ws = last_focus; 335 struct sway_container *last_ws = last_focus;
335 if (last_ws && last_ws->type != C_WORKSPACE) { 336 if (last_ws && last_ws->type != C_WORKSPACE) {
336 last_ws = container_parent(last_focus, C_WORKSPACE); 337 last_ws = container_parent(last_ws, C_WORKSPACE);
337 } 338 }
338 if (last_ws) { 339 if (last_ws) {
339 wlr_log(L_DEBUG, "sending workspace event");
340 ipc_event_workspace(last_ws, container, "focus"); 340 ipc_event_workspace(last_ws, container, "focus");
341 if (last_ws->children->length == 0) { 341 if (last_ws->children->length == 0) {
342 container_workspace_destroy(last_ws); 342 container_workspace_destroy(last_ws);
343 } 343 }
344 } 344 }
345 struct sway_container *last_output = last_focus;
346 if (last_output && last_output->type != C_OUTPUT) {
347 last_output = container_parent(last_output, C_OUTPUT);
348 }
349 struct sway_container *new_output = container;
350 if (new_output && new_output->type != C_OUTPUT) {
351 new_output = container_parent(new_output, C_OUTPUT);
352 }
353 if (new_output && last_output && new_output != last_output
354 && config->mouse_warping && warp) {
355 struct wlr_output *output = new_output->sway_output->wlr_output;
356 double x = container->x + output->lx + container->width / 2.0;
357 double y = container->y + output->ly + container->height / 2.0;
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 }
363 }
345 } 364 }
346 365
347 if (last_focus && last_focus->type == C_VIEW && 366 if (last_focus && last_focus->type == C_VIEW &&
@@ -353,6 +372,11 @@ void sway_seat_set_focus(struct sway_seat *seat,
353 seat->has_focus = (container != NULL); 372 seat->has_focus = (container != NULL);
354} 373}
355 374
375void sway_seat_set_focus(struct sway_seat *seat,
376 struct sway_container *container) {
377 sway_seat_set_focus_warp(seat, container, true);
378}
379
356struct 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) {
357 struct sway_seat_container *current = NULL; 381 struct sway_seat_container *current = NULL;
358 struct sway_container *parent = NULL; 382 struct sway_container *parent = NULL;