feat:add windowrule option isopensilent and tagsilent dispatch

This commit is contained in:
DreamMaoMao 2025-04-03 09:43:20 +08:00
parent 47c1a7e328
commit 8bfbd0c546
4 changed files with 42 additions and 13 deletions

View file

@ -105,12 +105,13 @@ tags=id:9,layout_name:tile
# animation_type_open : type-string(zoom,slide,none)
# animation_type_close : type-string(zoom,slide)
# isnoborder : type-num(0 or 1)
# monitor : type-int(0-99999)
# monitor : type-num(0-99999)
# width : type-num(0-9999)
# height : type-num(0-9999)
# isterm : type-num (0 or 1) -- when new window open, will replace it, and will restore after the sub window exit
# nnoswallow : type-num(0 or 1) -- if enable, this window wll not replace isterm window when it was open by isterm window
# globalkeybinding: type-string(for example-- alt-l or alt+super-l)
# isopensilent: type-num(0 or 1) -- open but not focus it
# example
# windowrule=isfloating:1,appid:yesplaymusic
@ -231,6 +232,10 @@ bind=Ctrl,KP_7,view,7
bind=Ctrl,KP_8,view,8
bind=Ctrl,KP_9,view,9
# tag: move client to the tag and focus it
# tagsilent: move client to the tag and not focus it
# bind=Alt,KP_1,tagsilent,1
bind=Alt,KP_1,tag,1
bind=Alt,KP_2,tag,2
bind=Alt,KP_3,tag,3

View file

@ -7,6 +7,7 @@ void set_proportion(const Arg *arg);
void increase_proportion(const Arg *arg);
void switch_proportion_preset(const Arg *arg);
void zoom(const Arg *arg);
void tagsilent(const Arg *arg);
void tagtoleft(const Arg *arg);
void tagtoright(const Arg *arg);
void viewtoleft(const Arg *arg);

View file

@ -238,6 +238,7 @@ struct Client {
int is_scratchpad_show;
int isglobal;
int isnoborder;
int isopensilent;
int iskilling;
struct wlr_box bounds;
bool resizing;
@ -513,7 +514,7 @@ static void setfullscreen(Client *c, int fullscreen);
static void setmaxmizescreen(Client *c, int maxmizescreen);
static void setgaps(int oh, int ov, int ih, int iv);
static void setmon(Client *c, Monitor *m, unsigned int newtags);
static void setmon(Client *c, Monitor *m, unsigned int newtags, bool focus);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@ -1525,6 +1526,7 @@ applyrules(Client *c) {
? r->scroller_proportion
: c->scroller_proportion;
c->isnoborder = r->isnoborder > 0 ? r->isnoborder : c->isnoborder;
c->isopensilent = r->isopensilent > 0 ? r->isopensilent : c->isopensilent;
newtags = r->tags > 0 ? r->tags | newtags : newtags;
i = 0;
wl_list_for_each(m, &mons, link) if (r->monitor == i++) mon = m;
@ -1566,9 +1568,9 @@ applyrules(Client *c) {
arrange(c->mon, false);
}
setmon(c, mon, newtags);
setmon(c, mon, newtags,!c->isopensilent);
if (!(c->tags & (1 << (selmon->pertag->curtag - 1)))) {
if (!c->isopensilent && !(c->tags & (1 << (selmon->pertag->curtag - 1)))) {
c->animation.from_rule = true;
view(&(Arg){.ui = c->tags}, true);
}
@ -2224,7 +2226,7 @@ buttonpress(struct wl_listener *listener, void *data) {
motionnotify(0, NULL, 0, 0, 0, 0);
/* Drop the window off on its new monitor */
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
setmon(grabc, selmon, 0,true);
grabc = NULL;
return;
} else {
@ -2361,7 +2363,7 @@ void closemon(Monitor *m) // 0.5
.height = c->geom.height},
0);
if (c->mon == m) {
setmon(c, selmon, c->tags);
setmon(c, selmon, c->tags,true);
reset_foreign_tolevel(c);
}
}
@ -3937,7 +3939,7 @@ mapnotify(struct wl_listener *listener, void *data) {
* try to apply rules for them */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
setmon(c, p->mon, p->tags);
setmon(c, p->mon, p->tags,true);
} else {
applyrules(c);
}
@ -3948,7 +3950,6 @@ mapnotify(struct wl_listener *listener, void *data) {
if (selmon->sel && selmon->sel->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_activated(selmon->sel->foreign_toplevel,
false);
selmon->sel = c;
if (c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true);
@ -5095,7 +5096,7 @@ void setsmfact(const Arg *arg) {
}
void
setmon(Client *c, Monitor *m, uint32_t newtags)
setmon(Client *c, Monitor *m, uint32_t newtags,bool focus)
{
Monitor *oldmon = c->mon;
@ -5114,7 +5115,8 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
}
focusclient(focustop(selmon), 1);
if(focus)
focusclient(focustop(selmon), 1);
}
void // 17
@ -5636,6 +5638,20 @@ void tag(const Arg *arg) {
tag_client(arg, target_client);
}
void tagsilent(const Arg *arg) {
Client *fc;
Client *target_client = selmon->sel;
target_client->tags = arg->ui & TAGMASK;
wl_list_for_each(fc, &clients, link) {
if (fc && fc != target_client && target_client->tags & fc->tags &&
ISFULLSCREEN(fc) && !target_client->isfloating) {
clear_fullscreen_flag(fc);
}
}
focusclient(focustop(selmon), 1);
arrange(target_client->mon, false);
}
void tagmon(const Arg *arg) {
Client *c = focustop(selmon);
Monitor *m;
@ -5644,7 +5660,7 @@ void tagmon(const Arg *arg) {
selmon->sel = NULL;
}
m = dirtomon(arg->i);
setmon(c, m, 0);
setmon(c, m, 0,true);
reset_foreign_tolevel(c);
// 重新计算居中的坐标
if (c->isfloating) {
@ -6425,7 +6441,7 @@ void unmapnotify(struct wl_listener *listener, void *data) {
} else {
if (!c->swallowing)
wl_list_remove(&c->link);
setmon(c, NULL, 0);
setmon(c, NULL, 0,true);
if (!c->swallowing)
wl_list_remove(&c->flink);
}
@ -6538,7 +6554,7 @@ updatemons(struct wl_listener *listener, void *data) {
if (selmon && selmon->wlr_output->enabled) {
wl_list_for_each(c, &clients, link) {
if (!c->mon && client_surface(c)->mapped) {
setmon(c, selmon, c->tags);
setmon(c, selmon, c->tags,true);
reset_foreign_tolevel(c);
}
}

View file

@ -24,6 +24,7 @@ typedef struct {
const char *animation_type_open;
const char *animation_type_close;
int isnoborder;
int isopensilent;
int monitor;
int width;
int height;
@ -425,6 +426,9 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value) {
func = viewtoleft;
} else if (strcmp(func_name, "viewtoright") == 0) {
func = viewtoright;
} else if (strcmp(func_name, "tagsilent") == 0) {
func = tagsilent;
(*arg).ui = 1 << (atoi(arg_value) - 1);
} else if (strcmp(func_name, "tagtoleft") == 0) {
func = tagtoleft;
} else if (strcmp(func_name, "tagtoright") == 0) {
@ -828,6 +832,7 @@ void parse_config_line(Config *config, const char *line) {
rule->isfloating = -1;
rule->isfullscreen = -1;
rule->isnoborder = -1;
rule->isopensilent = -1;
rule->isterm = -1;
rule->noswallow = -1;
rule->monitor = -1;
@ -869,6 +874,8 @@ void parse_config_line(Config *config, const char *line) {
rule->height = atoi(val);
} else if (strcmp(key, "isnoborder") == 0) {
rule->isnoborder = atoi(val);
} else if (strcmp(key, "isopensilent") == 0) {
rule->isopensilent = atoi(val);
} else if (strcmp(key, "isterm") == 0) {
rule->isterm = atoi(val);
} else if (strcmp(key, "noswallow") == 0) {