activation-rules: new patch

This commit is contained in:
Leonardo Hernández Hernández 2024-09-04 20:47:31 -06:00
parent 2ce469b149
commit 690a5dea84
No known key found for this signature in database
GPG Key ID: E538897EE11B9624
2 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,8 @@
### Description
Allow certain clients to be focused on activation requests.
### Download
- [main 2024-09-03](/dwl/dwl-patches/raw/branch/main/patches/activation-rules/activation-rules.patch)
### Authors
- [sevz](https://codeberg.org/sevz)

View File

@ -0,0 +1,116 @@
From f06b23ec91aa019e529e23c18c14bde867b4ed0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
<leohdz172@proton.me>
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 <leohdz172@proton.me>
---
config.def.h | 7 ++++---
dwl.c | 35 ++++++++++++++++++++++++++++++-----
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171d..1a61ffb2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,10 +22,11 @@ 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 monitor */
+ /* app_id title tags mask isfloating allow_activation monitor */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, 0, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, -1 }, /* Start on ONLY tag "9" */
+ { "emacs_EXAMPLE", NULL, 0, 0, 1, -1 }, /* Allow to be focused through activations requests */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index 9021e442..106099ed 100644
--- a/dwl.c
+++ b/dwl.c
@@ -141,6 +141,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
+ int allow_activation;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -231,6 +232,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int allow_activation;
int monitor;
} Rule;
@@ -466,6 +468,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->allow_activation = r->allow_activation;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -2899,10 +2902,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
@@ -3112,10 +3125,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
--
2.46.0