mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-09 13:29:54 -05:00
opt: optimize floating window auto ajust monitor position change
This commit is contained in:
parent
ba763332fc
commit
5f688d6e6c
1 changed files with 25 additions and 17 deletions
42
src/maomao.c
42
src/maomao.c
|
|
@ -7279,7 +7279,7 @@ void updatemons(struct wl_listener *listener, void *data) {
|
|||
Client *c;
|
||||
struct wlr_output_configuration_head_v1 *config_head;
|
||||
Monitor *m;
|
||||
int offset_x = 0, offset_y = 0, oldx, oldy;
|
||||
int mon_pos_offsetx, mon_pos_offsety, oldx, oldy;
|
||||
|
||||
/* First remove from the layout the disabled monitors */
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
|
|
@ -7321,8 +7321,30 @@ void updatemons(struct wl_listener *listener, void *data) {
|
|||
/* 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;
|
||||
offset_x = m->m.x - oldx;
|
||||
offset_y = m->m.y - oldy;
|
||||
mon_pos_offsetx = m->m.x - oldx;
|
||||
mon_pos_offsety = m->m.y - oldy;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
// floating window position auto adjust the change of monitor
|
||||
// position
|
||||
if (c->isfloating && c->mon == m) {
|
||||
c->geom.x += mon_pos_offsetx;
|
||||
c->geom.y += mon_pos_offsety;
|
||||
c->oldgeom = c->geom;
|
||||
resize(c, c->geom, 1);
|
||||
}
|
||||
|
||||
// restore window to old monitor
|
||||
if (c->mon && c->mon != m && client_surface(c)->mapped &&
|
||||
strcmp(c->oldmonname, m->wlr_output->name) == 0) {
|
||||
client_change_mon(c, m);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
must put it under the floating window position adjustment,
|
||||
Otherwise, incorrect floating window calculations will occur here.
|
||||
*/
|
||||
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);
|
||||
|
|
@ -7352,20 +7374,6 @@ void updatemons(struct wl_listener *listener, void *data) {
|
|||
|
||||
if (!selmon)
|
||||
selmon = m;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->isfloating && c->mon == m) {
|
||||
c->geom.x += offset_x;
|
||||
c->geom.y += offset_y;
|
||||
c->oldgeom = c->geom;
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
if (c->mon && c->mon != m && client_surface(c)->mapped &&
|
||||
strcmp(c->oldmonname, m->wlr_output->name) == 0) {
|
||||
client_change_mon(c, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selmon && selmon->wlr_output->enabled) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue