fix: foreign toplevel mon change

This commit is contained in:
DreamMaoMao 2026-05-07 11:24:41 +08:00
parent 42c02e3dc2
commit 18fa5a22c2
3 changed files with 58 additions and 25 deletions

View file

@ -1109,7 +1109,7 @@ int32_t tag(const Arg *arg) {
}
int32_t tagmon(const Arg *arg) {
Monitor *m = NULL, *cm = NULL;
Monitor *m = NULL, *cm = NULL, *oldmon = NULL;
if (!selmon)
return 0;
Client *c = focustop(selmon);
@ -1117,6 +1117,8 @@ int32_t tagmon(const Arg *arg) {
if (!c)
return 0;
oldmon = c->mon;
if (arg->i != UNDIR) {
m = dirtomon(arg->i);
} else if (arg->v) {
@ -1151,12 +1153,12 @@ int32_t tagmon(const Arg *arg) {
setmon(c, m, newtags, true);
client_update_oldmonname_record(c, m);
reset_foreign_tolevel(c);
reset_foreign_tolevel(c, oldmon, c->mon);
c->float_geom.width =
(int32_t)(c->float_geom.width * c->mon->w.width / selmon->w.width);
(int32_t)(c->float_geom.width * c->mon->w.width / oldmon->w.width);
c->float_geom.height =
(int32_t)(c->float_geom.height * c->mon->w.height / selmon->w.height);
(int32_t)(c->float_geom.height * c->mon->w.height / oldmon->w.height);
selmon = c->mon;
c->float_geom = setclient_coordinate_center(c, c->mon, c->float_geom, 0, 0);