dwm-canfocusrule-20200702-f709b19.diff - sites - public wiki contents of suckle… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-canfocusrule-20200702-f709b19.diff (3070B) | |
--- | |
1 From f709b1910af85d8ff2fdd5c38215c204f8bb34e7 Mon Sep 17 00:00:00 2001 | |
2 From: Danil Demchenko <[email protected]> | |
3 Date: Fri, 7 Feb 2020 00:11:53 +0300 | |
4 Subject: [PATCH] Add rule to remove the opportunity to focus certain wi… | |
5 May be useful for tray applications. | |
6 | |
7 --- | |
8 config.def.h | 6 +++--- | |
9 dwm.c | 15 ++++++++++----- | |
10 2 files changed, 13 insertions(+), 8 deletions(-) | |
11 | |
12 diff --git a/config.def.h b/config.def.h | |
13 index 1c0b587..a4468eb 100644 | |
14 --- a/config.def.h | |
15 +++ b/config.def.h | |
16 @@ -26,9 +26,9 @@ static const Rule rules[] = { | |
17 * WM_CLASS(STRING) = instance, class | |
18 * WM_NAME(STRING) = title | |
19 */ | |
20 - /* class instance title tags mask isfloating … | |
21 - { "Gimp", NULL, NULL, 0, 1, … | |
22 - { "Firefox", NULL, NULL, 1 << 8, 0, … | |
23 + /* class instance title tags mask isfloating … | |
24 + { "Gimp", NULL, NULL, 0, 1, … | |
25 + { "Firefox", NULL, NULL, 1 << 8, 0, … | |
26 }; | |
27 | |
28 /* layout(s) */ | |
29 diff --git a/dwm.c b/dwm.c | |
30 index 4465af1..c678e90 100644 | |
31 --- a/dwm.c | |
32 +++ b/dwm.c | |
33 @@ -92,7 +92,7 @@ struct Client { | |
34 int basew, baseh, incw, inch, maxw, maxh, minw, minh; | |
35 int bw, oldbw; | |
36 unsigned int tags; | |
37 - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfull… | |
38 + int isfixed, isfloating, canfocus, isurgent, neverfocus, oldsta… | |
39 Client *next; | |
40 Client *snext; | |
41 Monitor *mon; | |
42 @@ -138,6 +138,7 @@ typedef struct { | |
43 const char *title; | |
44 unsigned int tags; | |
45 int isfloating; | |
46 + int canfocus; | |
47 int monitor; | |
48 } Rule; | |
49 | |
50 @@ -286,6 +287,7 @@ applyrules(Client *c) | |
51 | |
52 /* rule matching */ | |
53 c->isfloating = 0; | |
54 + c->canfocus = 1; | |
55 c->tags = 0; | |
56 XGetClassHint(dpy, c->win, &ch); | |
57 class = ch.res_class ? ch.res_class : broken; | |
58 @@ -298,6 +300,7 @@ applyrules(Client *c) | |
59 && (!r->instance || strstr(instance, r->instance))) | |
60 { | |
61 c->isfloating = r->isfloating; | |
62 + c->canfocus = r->canfocus; | |
63 c->tags |= r->tags; | |
64 for (m = mons; m && m->num != r->monitor; m = m… | |
65 if (m) | |
66 @@ -788,6 +791,8 @@ focus(Client *c) | |
67 if (selmon->sel && selmon->sel != c) | |
68 unfocus(selmon->sel, 0); | |
69 if (c) { | |
70 + if (!c->canfocus) | |
71 + return; | |
72 if (c->mon != selmon) | |
73 selmon = c->mon; | |
74 if (c->isurgent) | |
75 @@ -837,16 +842,16 @@ focusstack(const Arg *arg) | |
76 if (!selmon->sel) | |
77 return; | |
78 if (arg->i > 0) { | |
79 - for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->… | |
80 + for (c = selmon->sel->next; c && (!ISVISIBLE(c) || !c->… | |
81 if (!c) | |
82 - for (c = selmon->clients; c && !ISVISIBLE(c); c… | |
83 + for (c = selmon->clients; c && (!ISVISIBLE(c) |… | |
84 } else { | |
85 for (i = selmon->clients; i != selmon->sel; i = i->next) | |
86 - if (ISVISIBLE(i)) | |
87 + if (ISVISIBLE(i) && i->canfocus) | |
88 c = i; | |
89 if (!c) | |
90 for (; i; i = i->next) | |
91 - if (ISVISIBLE(i)) | |
92 + if (ISVISIBLE(i) && i->canfocus) | |
93 c = i; | |
94 } | |
95 if (c) { | |
96 -- | |
97 2.25.0 | |
98 |