aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h7
-rw-r--r--sway/input/seatop_default.c10
-rw-r--r--sway/tree/container.c19
3 files changed, 19 insertions, 17 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 8d2d8827..fd028131 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -273,6 +273,13 @@ void container_set_fullscreen(struct sway_container *con,
273void container_fullscreen_disable(struct sway_container *con); 273void container_fullscreen_disable(struct sway_container *con);
274 274
275/** 275/**
276 * Walk up the container tree branch starting at the given container, and return
277 * its earliest ancestor.
278 */
279struct sway_container *container_toplevel_ancestor(
280 struct sway_container *container);
281
282/**
276 * Return true if the container is floating, or a child of a floating split 283 * Return true if the container is floating, or a child of a floating split
277 * container. 284 * container.
278 */ 285 */
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,
338 if (button == btn_move && (mod_pressed || on_titlebar)) { 338 if (button == btn_move && (mod_pressed || on_titlebar)) {
339 seat_set_focus_container(seat, 339 seat_set_focus_container(seat,
340 seat_get_focus_inactive_view(seat, &cont->node)); 340 seat_get_focus_inactive_view(seat, &cont->node));
341 while (cont->parent) { 341 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
342 cont = cont->parent;
343 }
344 seatop_begin_move_floating(seat, cont);
345 return; 342 return;
346 } 343 }
347 } 344 }
@@ -359,10 +356,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
359 uint32_t btn_resize = config->floating_mod_inverse ? 356 uint32_t btn_resize = config->floating_mod_inverse ?
360 BTN_LEFT : BTN_RIGHT; 357 BTN_LEFT : BTN_RIGHT;
361 if (mod_pressed && button == btn_resize) { 358 if (mod_pressed && button == btn_resize) {
362 struct sway_container *floater = cont; 359 struct sway_container *floater = container_toplevel_ancestor(cont);
363 while (floater->parent) {
364 floater = floater->parent;
365 }
366 edge = 0; 360 edge = 0;
367 edge |= cursor->cursor->x > floater->x + floater->width / 2 ? 361 edge |= cursor->cursor->x > floater->x + floater->width / 2 ?
368 WLR_EDGE_RIGHT : WLR_EDGE_LEFT; 362 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 3e99aa75..2fbd0d38 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1108,11 +1108,17 @@ void container_set_fullscreen(struct sway_container *con,
1108 } 1108 }
1109} 1109}
1110 1110
1111bool container_is_floating_or_child(struct sway_container *container) { 1111struct sway_container *container_toplevel_ancestor(
1112 struct sway_container *container) {
1112 while (container->parent) { 1113 while (container->parent) {
1113 container = container->parent; 1114 container = container->parent;
1114 } 1115 }
1115 return container_is_floating(container); 1116
1117 return container;
1118}
1119
1120bool container_is_floating_or_child(struct sway_container *container) {
1121 return container_is_floating(container_toplevel_ancestor(container));
1116} 1122}
1117 1123
1118bool container_is_fullscreen_or_child(struct sway_container *container) { 1124bool container_is_fullscreen_or_child(struct sway_container *container) {
@@ -1537,10 +1543,7 @@ void container_update_marks_textures(struct sway_container *con) {
1537 1543
1538void container_raise_floating(struct sway_container *con) { 1544void container_raise_floating(struct sway_container *con) {
1539 // Bring container to front by putting it at the end of the floating list. 1545 // Bring container to front by putting it at the end of the floating list.
1540 struct sway_container *floater = con; 1546 struct sway_container *floater = container_toplevel_ancestor(con);
1541 while (floater->parent) {
1542 floater = floater->parent;
1543 }
1544 if (container_is_floating(floater) && floater->workspace) { 1547 if (container_is_floating(floater) && floater->workspace) {
1545 list_move_to_end(floater->workspace->floating, floater); 1548 list_move_to_end(floater->workspace->floating, floater);
1546 node_set_dirty(&floater->workspace->node); 1549 node_set_dirty(&floater->workspace->node);
@@ -1552,8 +1555,6 @@ bool container_is_scratchpad_hidden(struct sway_container *con) {
1552} 1555}
1553 1556
1554bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { 1557bool container_is_scratchpad_hidden_or_child(struct sway_container *con) {
1555 while (con->parent) { 1558 con = container_toplevel_ancestor(con);
1556 con = con->parent;
1557 }
1558 return con->scratchpad && !con->workspace; 1559 return con->scratchpad && !con->workspace;
1559} 1560}