fix: isfloating rule not follow monitor rule

This commit is contained in:
DreamMaoMao 2026-01-08 10:13:21 +08:00
parent 5a714b7562
commit 4efb8c5e06
3 changed files with 17 additions and 13 deletions

View file

@ -689,7 +689,7 @@ static void show_scratchpad(Client *c);
static void show_hide_client(Client *c);
static void tag_client(const Arg *arg, Client *target_client);
static struct wlr_box setclient_coordinate_center(Client *c,
static struct wlr_box setclient_coordinate_center(Client *c, Monitor *m,
struct wlr_box geom,
int32_t offsetx,
int32_t offsety);
@ -952,7 +952,8 @@ void client_change_mon(Client *c, Monitor *m) {
setmon(c, m, c->tags, true);
reset_foreign_tolevel(c);
if (c->isfloating) {
c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
c->float_geom = c->geom =
setclient_coordinate_center(c, c->mon, c->geom, 0, 0);
}
}
@ -1019,7 +1020,7 @@ void show_scratchpad(Client *c) {
: c->mon->w.height * scratchpad_height_ratio;
// 重新计算居中的坐标
c->float_geom = c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c, c->geom, 0, 0);
setclient_coordinate_center(c, c->mon, c->geom, 0, 0);
c->iscustomsize = 1;
resize(c, c->geom, 0);
}
@ -1089,7 +1090,8 @@ bool switch_scratchpad_client_state(Client *c) {
c->float_geom.height = (int32_t)(c->float_geom.height *
c->mon->w.height / oldmon->w.height);
c->float_geom = setclient_coordinate_center(c, c->float_geom, 0, 0);
c->float_geom =
setclient_coordinate_center(c, c->mon, c->float_geom, 0, 0);
// 只有显示状态的scratchpad才需要聚焦和返回true
if (c->is_scratchpad_show) {
@ -1345,7 +1347,7 @@ void applyrules(Client *c) {
if (r->offsetx || r->offsety) {
c->iscustompos = 1;
c->float_geom = c->geom = setclient_coordinate_center(
c, c->float_geom, r->offsetx, r->offsety);
c, mon, c->float_geom, r->offsetx, r->offsety);
}
if (c->isfloating) {
c->geom = c->float_geom.width > 0 && c->float_geom.height > 0
@ -1363,7 +1365,8 @@ void applyrules(Client *c) {
// the hit size
if (!c->iscustompos &&
(!client_is_x11(c) || (c->geom.x == 0 && c->geom.y == 0))) {
c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
c->float_geom = c->geom =
setclient_coordinate_center(c, mon, c->geom, 0, 0);
} else {
c->float_geom = c->geom;
}
@ -4537,7 +4540,8 @@ setfloating(Client *c, int32_t floating) {
// 重新计算居中的坐标
if (!client_is_x11(c) && !c->iscustompos)
target_box = setclient_coordinate_center(c, target_box, 0, 0);
target_box =
setclient_coordinate_center(c, c->mon, target_box, 0, 0);
else
target_box = c->geom;
@ -4553,7 +4557,7 @@ setfloating(Client *c, int32_t floating) {
}
if (window_size_outofrange) {
c->float_geom =
setclient_coordinate_center(c, c->float_geom, 0, 0);
setclient_coordinate_center(c, c->mon, c->float_geom, 0, 0);
}
resize(c, c->float_geom, 0);
} else {