From e81ca5a6e50e9f3055e1464941f69e43594eb7d4 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 7 Sep 2025 09:47:36 +0800 Subject: [PATCH] opt: Optimize the insertion position of the new window in the scrolling layout --- src/mango.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mango.c b/src/mango.c index 48a20d9..db134c5 100644 --- a/src/mango.c +++ b/src/mango.c @@ -1181,7 +1181,8 @@ void applyrules(Client *c) { r->offsety); } if (c->isfloating) { - c->geom = c->oldgeom.width> 0 && c->oldgeom.height > 0 ? c->oldgeom : c->geom; + c->geom = c->oldgeom.width > 0 && c->oldgeom.height > 0 ? c->oldgeom + : c->geom; if (!c->isnosizehint) client_set_size_bound(c); } @@ -3478,6 +3479,7 @@ void // old fix to 0.5 mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ Client *p = NULL; + Client *at_client; Client *c = wl_container_of(listener, c, map); /* Create scene tree for this client and its border */ c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); @@ -3545,8 +3547,16 @@ mapnotify(struct wl_listener *listener, void *data) { if (new_is_master && selmon && !is_scroller_layout(selmon)) // tile at the top wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈 - else if (selmon && is_scroller_layout(selmon) && center_select(selmon)) { - Client *at_client = center_select(selmon); + else if (selmon && is_scroller_layout(selmon) && + selmon->visible_tiling_clients > 0) { + + if (selmon->sel && ISTILED(selmon->sel) && + VISIBLEON(selmon->sel, selmon)) { + at_client = selmon->sel; + } else { + at_client = center_select(selmon); + } + at_client->link.next->prev = &c->link; c->link.prev = &at_client->link; c->link.next = at_client->link.next;