From 2daeeb4ffd1b7b382b80976a14f0ae5f23b920b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 26 Jul 2024 23:04:32 -0600 Subject: [PATCH] allow clients to be focused on activation requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all clients are allow to do so. Users can specify which clients through rules Signed-off-by: Leonardo Hernández Hernández --- config.def.h | 10 +++++----- dwl.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/config.def.h b/config.def.h index 8ff043f2f445292ce1c0114ed39efe4b6c9f7f7a..63005316c28ccb0119d8daf1aa85fdbc4344d161 100644 --- a/config.def.h +++ b/config.def.h @@ -29,12 +29,12 @@ static int log_level = WLR_ERROR; /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ static const Rule rules[] = { - /* app_id title tags mask isfloating isterm noswallow monitor scratchkey */ + /* app_id title tags mask isfloating isterm noswallow allow_activation monitor scratchkey */ /* examples: */ - { "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, -1, 0 }, /* Start on currently visible tags floating, not tiled */ - { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, 0, -1, 0 }, /* Start on ONLY tag "9" */ - { "foot", NULL, 0, 0, 1, 1, -1, 0 }, /* make foot swallow clients that are not foot */ - { NULL, "scratchpad", 0, 1, 0, 0, -1, 's' }, + { "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, 0, -1, 0 }, /* Start on currently visible tags floating, not tiled */ + { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, 0, 0, -1, 0 }, /* Start on ONLY tag "9" */ + { "foot", NULL, 0, 0, 1, 1, 1, -1, 0 }, /* make foot swallow clients that are not foot */ + { NULL, "scratchpad", 0, 1, 0, 0, 0, -1, 's' }, }; /* layout(s) */ diff --git a/dwl.c b/dwl.c index 09524d92b8e802e30273bca3d053b022a87ed4e1..cef9b8a469dde502d68769e31bb8089eb7c8ff91 100644 --- a/dwl.c +++ b/dwl.c @@ -148,6 +148,7 @@ struct Client { uint32_t tags; int isfloating, isurgent, isfullscreen, issticky, isterm, noswallow; char scratchkey; + int allow_activation; uint32_t resize; /* configure serial of a pending resize */ pid_t pid; Client *swallowing, *swallowedby; @@ -258,6 +259,7 @@ typedef struct { int isfloating; int isterm; int noswallow; + int allow_activation; int monitor; const char scratchkey; } Rule; @@ -599,6 +601,7 @@ applyrules(Client *c) c->isterm = r->isterm; c->noswallow = r->noswallow; c->scratchkey = r->scratchkey; + c->allow_activation = r->allow_activation; newtags |= r->tags; i = 0; wl_list_for_each(m, &mons, link) { @@ -3785,10 +3788,20 @@ urgent(struct wl_listener *listener, void *data) return; c->isurgent = 1; - printstatus(); + if (!client_surface(c)->mapped) { + printstatus(); + return; + } - if (client_surface(c)->mapped) + if (event->token->seat && event->token->surface && c->allow_activation) { + selmon = c->mon; + if (!VISIBLEON(c, c->mon)) + view(&((Arg){.ui = c->tags})); + focusclient(c, 1); + } else { client_set_border_color(c, urgentcolor); + printstatus(); + } } void @@ -4031,10 +4044,22 @@ sethints(struct wl_listener *listener, void *data) return; c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints); - printstatus(); + if (!surface || !surface->mapped) { + printstatus(); + return; + } - if (c->isurgent && surface && surface->mapped) - client_set_border_color(c, urgentcolor); + if (c->isurgent) { + if (c->allow_activation) { + selmon = c->mon; + if (!VISIBLEON(c, c->mon)) + view(&((Arg){.ui = c->tags})); + focusclient(c, 1); + } else { + client_set_border_color(c, urgentcolor); + printstatus(); + } + } } void