diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-06-04 14:28:43 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-06-07 10:46:14 +0200 |
commit | 53dc83fb68d2da079f2595994af41cc6b9acbeea (patch) | |
tree | 7532ea7ae132fcb592779b69606a54c6205dbbd9 /sway/input | |
parent | d7900c6e5e82406c1ed6a6df2ff3d1896149deff (diff) | |
download | sway-53dc83fb68d2da079f2595994af41cc6b9acbeea.tar.xz |
tree/container: introduce `container_toplevel_ancestor` helper
This allows us to not have to explicitly write the same while loop
everywhere.
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/seatop_default.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 2bce2f77..b8265441 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -338,10 +338,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, if (button == btn_move && (mod_pressed || on_titlebar)) { seat_set_focus_container(seat, seat_get_focus_inactive_view(seat, &cont->node)); - while (cont->parent) { - cont = cont->parent; - } - seatop_begin_move_floating(seat, cont); + seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); return; } } @@ -359,10 +356,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, uint32_t btn_resize = config->floating_mod_inverse ? BTN_LEFT : BTN_RIGHT; if (mod_pressed && button == btn_resize) { - struct sway_container *floater = cont; - while (floater->parent) { - floater = floater->parent; - } + struct sway_container *floater = container_toplevel_ancestor(cont); edge = 0; edge |= cursor->cursor->x > floater->x + floater->width / 2 ? WLR_EDGE_RIGHT : WLR_EDGE_LEFT; |