opt: optimize drop tile client when cross monitor

This commit is contained in:
DreamMaoMao 2026-06-14 07:53:57 +08:00
parent 792bfac475
commit 7e178369ff
2 changed files with 78 additions and 41 deletions

View file

@ -2202,9 +2202,10 @@ void hold_end(struct wl_listener *listener, void *data) {
Client *find_closest_tiled_client(Client *c) {
Client *tc, *closest = NULL;
long min_dist = LONG_MAX;
Monitor *cursor_mon = xytomon(cursor->x, cursor->y);
wl_list_for_each(tc, &clients, link) {
if (tc == c || !ISTILED(tc) || !VISIBLEON(tc, c->mon))
if (tc == c || !ISTILED(tc) || !VISIBLEON(tc, cursor_mon))
continue;
if (cursor->x >= tc->geom.x &&
@ -2236,7 +2237,9 @@ void place_drag_tile_client(Client *c) {
if (closest->drop_direction == UNDIR) {
setfloating(c, 0);
exchange_two_client(c, closest);
wl_list_remove(&c->link);
wl_list_insert(closest->link.prev, &c->link);
arrange(closest->mon, false, false);
return;
}