fix: isfloating rule not follow monitor rule
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled

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

@@ -740,7 +740,7 @@ int32_t centerwin(const Arg *arg) {
return 0; return 0;
if (c->isfloating) { if (c->isfloating) {
c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0); c->float_geom = setclient_coordinate_center(c, c->mon, c->geom, 0, 0);
c->iscustomsize = 1; c->iscustomsize = 1;
resize(c, c->float_geom, 1); resize(c, c->float_geom, 1);
return 0; return 0;
@@ -1055,7 +1055,7 @@ int32_t tagmon(const Arg *arg) {
c->float_geom.height = 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 / selmon->w.height);
selmon = c->mon; selmon = c->mon;
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);
// 重新计算居中的坐标 // 重新计算居中的坐标
// 重新计算居中的坐标 // 重新计算居中的坐标

View File

@@ -74,12 +74,12 @@ Client *get_client_by_id_or_title(const char *arg_id, const char *arg_title) {
return target_client; return target_client;
} }
struct wlr_box // 计算客户端居中坐标 struct wlr_box // 计算客户端居中坐标
setclient_coordinate_center(Client *c, struct wlr_box geom, int32_t offsetx, setclient_coordinate_center(Client *c, Monitor *tm, struct wlr_box geom,
int32_t offsety) { int32_t offsetx, int32_t offsety) {
struct wlr_box tempbox; struct wlr_box tempbox;
int32_t offset = 0; int32_t offset = 0;
int32_t len = 0; int32_t len = 0;
Monitor *m = c->mon ? c->mon : selmon; Monitor *m = tm ? tm : selmon;
uint32_t cbw = check_hit_no_border(c) ? c->bw : 0; uint32_t cbw = check_hit_no_border(c) ? c->bw : 0;

View File

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