aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_default.c
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-10-22 00:37:29 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2022-10-21 10:05:00 +0200
commit5e514e6474754ea6a4b4d1bfc5738457a0fb41cf (patch)
tree81015cbe6fe5fe8cb8b393b57a8f867571b6698c /sway/input/seatop_default.c
parentAdd support for ext-idle-notify-v1 (diff)
downloadsway-5e514e6474754ea6a4b4d1bfc5738457a0fb41cf.tar.gz
sway-5e514e6474754ea6a4b4d1bfc5738457a0fb41cf.tar.zst
sway-5e514e6474754ea6a4b4d1bfc5738457a0fb41cf.zip
input: tweak focus behavior to allow focusing parent containers
Sway focuses the inactive child when focusing split containers. However, there is currently no way to focus the parent container itself by mouse. A user must use the keyboard to do so. This commit maintains the current behavior, but makes it such that a second click on the split container titlebar (i.e., after its children are visible) focuses the split container itself.
Diffstat (limited to 'sway/input/seatop_default.c')
-rw-r--r--sway/input/seatop_default.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 227b3cc9..84acefdf 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -429,13 +429,31 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
429 } 429 }
430 } 430 }
431 431
432 // Handle changing focus when clicking on a container
433 if (cont && state == WLR_BUTTON_PRESSED) {
434 // Default case: focus the container that was just clicked.
435 node = &cont->node;
436
437 // If the container is a tab/stacked container and the click happened
438 // on a tab, switch to the tab. If the tab contents were already
439 // focused, focus the tab container itself. If the tab container was
440 // already focused, cycle back to focusing the tab contents.
441 if (on_titlebar) {
442 struct sway_container *focus = seat_get_focused_container(seat);
443 if (focus == cont || !container_has_ancestor(focus, cont)) {
444 node = seat_get_focus_inactive(seat, &cont->node);
445 }
446 }
447
448 seat_set_focus(seat, node);
449 transaction_commit_dirty();
450 }
451
432 // Handle beginning floating move 452 // Handle beginning floating move
433 if (cont && is_floating_or_child && !is_fullscreen_or_child && 453 if (cont && is_floating_or_child && !is_fullscreen_or_child &&
434 state == WLR_BUTTON_PRESSED) { 454 state == WLR_BUTTON_PRESSED) {
435 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; 455 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
436 if (button == btn_move && (mod_pressed || on_titlebar)) { 456 if (button == btn_move && (mod_pressed || on_titlebar)) {
437 seat_set_focus_container(seat,
438 seat_get_focus_inactive_view(seat, &cont->node));
439 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); 457 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
440 return; 458 return;
441 } 459 }
@@ -471,25 +489,18 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
471 if (config->tiling_drag && (mod_pressed || on_titlebar) && 489 if (config->tiling_drag && (mod_pressed || on_titlebar) &&
472 state == WLR_BUTTON_PRESSED && !is_floating_or_child && 490 state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
473 cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) { 491 cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
474 struct sway_container *focus = seat_get_focused_container(seat);
475 bool focused = focus == cont || container_has_ancestor(focus, cont);
476 if (on_titlebar && !focused) {
477 node = seat_get_focus_inactive(seat, &cont->node);
478 seat_set_focus(seat, node);
479 }
480
481 // If moving a container by its title bar, use a threshold for the drag 492 // If moving a container by its title bar, use a threshold for the drag
482 if (!mod_pressed && config->tiling_drag_threshold > 0) { 493 if (!mod_pressed && config->tiling_drag_threshold > 0) {
483 seatop_begin_move_tiling_threshold(seat, cont); 494 seatop_begin_move_tiling_threshold(seat, cont);
484 } else { 495 } else {
485 seatop_begin_move_tiling(seat, cont); 496 seatop_begin_move_tiling(seat, cont);
486 } 497 }
498
487 return; 499 return;
488 } 500 }
489 501
490 // Handle mousedown on a container surface 502 // Handle mousedown on a container surface
491 if (surface && cont && state == WLR_BUTTON_PRESSED) { 503 if (surface && cont && state == WLR_BUTTON_PRESSED) {
492 seat_set_focus_container(seat, cont);
493 seatop_begin_down(seat, cont, time_msec, sx, sy); 504 seatop_begin_down(seat, cont, time_msec, sx, sy);
494 seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED); 505 seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED);
495 return; 506 return;
@@ -497,9 +508,6 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
497 508
498 // Handle clicking a container surface or decorations 509 // Handle clicking a container surface or decorations
499 if (cont && state == WLR_BUTTON_PRESSED) { 510 if (cont && state == WLR_BUTTON_PRESSED) {
500 node = seat_get_focus_inactive(seat, &cont->node);
501 seat_set_focus(seat, node);
502 transaction_commit_dirty();
503 seat_pointer_notify_button(seat, time_msec, button, state); 511 seat_pointer_notify_button(seat, time_msec, button, state);
504 return; 512 return;
505 } 513 }