feat: floating window pos adjust change of monitor pos

This commit is contained in:
DreamMaoMao 2025-06-15 18:59:53 +08:00
parent ea263a0ed5
commit d45e903893

16
dwl.c
View File

@ -807,9 +807,6 @@ closemon(Monitor *m)
}
wl_list_for_each(c, &clients, link) {
if (c->isfloating && c->geom.x > m->m.width)
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
.width = c->geom.width, .height = c->geom.height}, 0);
if (c->mon == m)
setmon(c, selmon, c->tags);
}
@ -2850,6 +2847,7 @@ updatemons(struct wl_listener *listener, void *data)
Client *c;
struct wlr_output_configuration_head_v1 *config_head;
Monitor *m;
int oldx, oldy;
/* First remove from the layout the disabled monitors */
wl_list_for_each(m, &mons, link) {
@ -2884,9 +2882,21 @@ updatemons(struct wl_listener *listener, void *data)
continue;
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
oldx = m->m.x;
oldy = m->m.y;
/* Get the effective monitor geometry to use for surfaces */
wlr_output_layout_get_box(output_layout, m->wlr_output, &m->m);
m->w = m->m;
wl_list_for_each(c, &clients, link) {
if (c->isfloating && c->mon == m) {
c->geom.x += (m->m.x - oldx);
c->geom.y += (m->m.y - oldy);
resize(c, c->geom, 1);
}
}
wlr_scene_output_set_position(m->scene_output, m->m.x, m->m.y);
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);