diff options
author | 2018-09-25 10:29:58 +0200 | |
---|---|---|
committer | 2018-10-03 16:23:14 +0200 | |
commit | ec713125c6593b3671dc54e41b90333b42783dff (patch) | |
tree | 8c2ec870a42c79f075b38fdb519bd782e726c422 /sway | |
parent | Add configuration for raising containers on focus (diff) | |
download | sway-ec713125c6593b3671dc54e41b90333b42783dff.tar.gz sway-ec713125c6593b3671dc54e41b90333b42783dff.tar.zst sway-ec713125c6593b3671dc54e41b90333b42783dff.zip |
Simplify raising a container in seat
* Factor out raising a floating window into s separate function to
enable reuse.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seat.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index c747eafc..15c56a43 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -606,6 +606,18 @@ static int handle_urgent_timeout(void *data) { | |||
606 | return 0; | 606 | return 0; |
607 | } | 607 | } |
608 | 608 | ||
609 | static void container_raise_floating(struct sway_container *con) { | ||
610 | // Bring container to front by putting it at the end of the floating list. | ||
611 | struct sway_container *floater = con; | ||
612 | while (floater->parent) { | ||
613 | floater = floater->parent; | ||
614 | } | ||
615 | if (container_is_floating(floater)) { | ||
616 | list_move_to_end(floater->workspace->floating, floater); | ||
617 | node_set_dirty(&floater->workspace->node); | ||
618 | } | ||
619 | } | ||
620 | |||
609 | void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | 621 | void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, |
610 | bool warp, bool notify) { | 622 | bool warp, bool notify) { |
611 | if (seat->focused_layer) { | 623 | if (seat->focused_layer) { |
@@ -733,16 +745,8 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | |||
733 | } | 745 | } |
734 | 746 | ||
735 | // If we've focused a floating container, bring it to the front. | 747 | // If we've focused a floating container, bring it to the front. |
736 | // We do this by putting it at the end of the floating list. | ||
737 | if (container && config->raise_floating) { | 748 | if (container && config->raise_floating) { |
738 | struct sway_container *floater = container; | 749 | container_raise_floating(container); |
739 | while (floater->parent) { | ||
740 | floater = floater->parent; | ||
741 | } | ||
742 | if (container_is_floating(floater)) { | ||
743 | list_move_to_end(floater->workspace->floating, floater); | ||
744 | node_set_dirty(&floater->workspace->node); | ||
745 | } | ||
746 | } | 750 | } |
747 | 751 | ||
748 | if (last_focus) { | 752 | if (last_focus) { |
@@ -1018,17 +1022,9 @@ void seat_begin_down(struct sway_seat *seat, struct sway_container *con, | |||
1018 | seat->op_ref_con_ly = sy; | 1022 | seat->op_ref_con_ly = sy; |
1019 | seat->op_moved = false; | 1023 | seat->op_moved = false; |
1020 | 1024 | ||
1021 | // If we've focused a floating container, bring it to the front. | 1025 | // In case the container was not raised by gaining focus, raise on click |
1022 | // We do this by putting it at the end of the floating list. | ||
1023 | if (con && !config->raise_floating) { | 1026 | if (con && !config->raise_floating) { |
1024 | struct sway_container *floater = con; | 1027 | container_raise_floating(con); |
1025 | while (floater->parent) { | ||
1026 | floater = floater->parent; | ||
1027 | } | ||
1028 | if (container_is_floating(floater)) { | ||
1029 | list_move_to_end(floater->workspace->floating, floater); | ||
1030 | node_set_dirty(&floater->workspace->node); | ||
1031 | } | ||
1032 | } | 1028 | } |
1033 | } | 1029 | } |
1034 | 1030 | ||