feat: support nofucs rule for some special window

This commit is contained in:
DreamMaoMao
2025-11-09 15:40:51 +08:00
parent 11dfab478a
commit c206693257
2 changed files with 29 additions and 17 deletions

View File

@@ -77,6 +77,7 @@ typedef struct {
int offsety; int offsety;
int width; int width;
int height; int height;
int nofocus;
int nofadein; int nofadein;
int nofadeout; int nofadeout;
int no_force_center; int no_force_center;
@@ -1716,6 +1717,7 @@ void parse_option(Config *config, char *key, char *value) {
rule->force_tearing = -1; rule->force_tearing = -1;
rule->noswallow = -1; rule->noswallow = -1;
rule->noblur = -1; rule->noblur = -1;
rule->nofocus = -1;
rule->nofadein = -1; rule->nofadein = -1;
rule->nofadeout = -1; rule->nofadeout = -1;
rule->no_force_center = -1; rule->no_force_center = -1;
@@ -1770,6 +1772,8 @@ void parse_option(Config *config, char *key, char *value) {
rule->offsetx = atoi(val); rule->offsetx = atoi(val);
} else if (strcmp(key, "offsety") == 0) { } else if (strcmp(key, "offsety") == 0) {
rule->offsety = atoi(val); rule->offsety = atoi(val);
} else if (strcmp(key, "nofocus") == 0) {
rule->nofocus = atoi(val);
} else if (strcmp(key, "nofadein") == 0) { } else if (strcmp(key, "nofadein") == 0) {
rule->nofadein = atoi(val); rule->nofadein = atoi(val);
} else if (strcmp(key, "nofadeout") == 0) { } else if (strcmp(key, "nofadeout") == 0) {

View File

@@ -353,6 +353,7 @@ struct Client {
bool drag_to_tile; bool drag_to_tile;
bool scratchpad_switching_mon; bool scratchpad_switching_mon;
bool fake_no_border; bool fake_no_border;
int nofocus;
int nofadein; int nofadein;
int nofadeout; int nofadeout;
int no_force_center; int no_force_center;
@@ -1132,6 +1133,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
APPLY_INT_PROP(c, r, force_maximize); APPLY_INT_PROP(c, r, force_maximize);
APPLY_INT_PROP(c, r, force_tearing); APPLY_INT_PROP(c, r, force_tearing);
APPLY_INT_PROP(c, r, noswallow); APPLY_INT_PROP(c, r, noswallow);
APPLY_INT_PROP(c, r, nofocus);
APPLY_INT_PROP(c, r, nofadein); APPLY_INT_PROP(c, r, nofadein);
APPLY_INT_PROP(c, r, nofadeout); APPLY_INT_PROP(c, r, nofadeout);
APPLY_INT_PROP(c, r, no_force_center); APPLY_INT_PROP(c, r, no_force_center);
@@ -1245,11 +1247,16 @@ void applyrules(Client *c) {
const char *appid, *title; const char *appid, *title;
unsigned int i, newtags = 0; unsigned int i, newtags = 0;
const ConfigWinRule *r; const ConfigWinRule *r;
Monitor *mon = selmon, *m = NULL; Monitor *m = NULL;
Client *fc = NULL; Client *fc = NULL;
bool hit_rule_pos = false; bool hit_rule_pos = false;
Client *parent = NULL;
c->isfloating = client_is_float_type(c); parent = client_get_parent(c);
Monitor *mon = parent && parent->mon ? parent->mon : selmon;
c->isfloating = client_is_float_type(c) || parent;
if (!(appid = client_get_appid(c))) if (!(appid = client_get_appid(c)))
appid = broken; appid = broken;
if (!(title = client_get_title(c))) if (!(title = client_get_title(c)))
@@ -1266,8 +1273,14 @@ void applyrules(Client *c) {
// set general properties // set general properties
apply_rule_properties(c, r); apply_rule_properties(c, r);
// set tags // // set tags
newtags |= (r->tags > 0) ? r->tags : 0; if (r->tags > 0) {
newtags |= r->tags;
} else if (parent) {
newtags = parent->tags;
} else {
newtags |= 0;
}
// set monitor of client // set monitor of client
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
@@ -1336,8 +1349,9 @@ void applyrules(Client *c) {
int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c); int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c);
setmon(c, mon, newtags, setmon(c, mon, newtags,
!c->isopensilent && (!c->istagsilent || !newtags || !c->isopensilent && !client_should_ignore_focus(c) &&
newtags & mon->tagset[mon->seltags])); (!c->istagsilent || !newtags ||
newtags & mon->tagset[mon->seltags]));
if (c->mon && if (c->mon &&
!(c->mon == selmon && c->tags & c->mon->tagset[c->mon->seltags]) && !(c->mon == selmon && c->tags & c->mon->tagset[c->mon->seltags]) &&
@@ -3095,6 +3109,9 @@ void focusclient(Client *c, int lift) {
if (c && client_should_ignore_focus(c) && client_is_x11_popup(c)) if (c && client_should_ignore_focus(c) && client_is_x11_popup(c))
return; return;
if (c && c->nofocus)
return;
/* Raise client in stacking order if requested */ /* Raise client in stacking order if requested */
if (c && lift) if (c && lift)
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
@@ -3571,6 +3588,7 @@ void init_client_properties(Client *c) {
c->fake_no_border = false; c->fake_no_border = false;
c->focused_opacity = focused_opacity; c->focused_opacity = focused_opacity;
c->unfocused_opacity = unfocused_opacity; c->unfocused_opacity = unfocused_opacity;
c->nofocus = 0;
c->nofadein = 0; c->nofadein = 0;
c->nofadeout = 0; c->nofadeout = 0;
c->no_force_center = 0; c->no_force_center = 0;
@@ -3591,7 +3609,6 @@ void init_client_properties(Client *c) {
void // old fix to 0.5 void // old fix to 0.5
mapnotify(struct wl_listener *listener, void *data) { mapnotify(struct wl_listener *listener, void *data) {
/* Called when the surface is mapped, or ready to display on-screen. */ /* Called when the surface is mapped, or ready to display on-screen. */
Client *p = NULL;
Client *at_client = NULL; Client *at_client = NULL;
Client *c = wl_container_of(listener, c, map); Client *c = wl_container_of(listener, c, map);
/* Create scene tree for this client and its border */ /* Create scene tree for this client and its border */
@@ -3686,16 +3703,7 @@ mapnotify(struct wl_listener *listener, void *data) {
wl_list_insert(clients.prev, &c->link); // 尾部入栈 wl_list_insert(clients.prev, &c->link); // 尾部入栈
wl_list_insert(&fstack, &c->flink); wl_list_insert(&fstack, &c->flink);
/* Set initial monitor, tags, floating status, and focus: applyrules(c);
* we always consider floating, clients that have parent and thus
* we set the same tags and monitor than its parent, if not
* try to apply rules for them */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
setmon(c, p->mon, p->tags, true);
} else {
applyrules(c);
}
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT); WLR_EDGE_RIGHT);