dwm-xfce4-panel-20210701-67d76bd.diff - sites - public wiki contents of suckles… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-xfce4-panel-20210701-67d76bd.diff (4295B) | |
--- | |
1 From 4e33fe0d465fb24f6b42d4a1fb63d4d7902f1986 Mon Sep 17 00:00:00 2001 | |
2 From: Gunther Klessinger <[email protected]> | |
3 Date: Thu, 1 Jul 2021 09:19:07 +0200 | |
4 Subject: [PATCH] Supporting xfce4-panel in dwm | |
5 | |
6 We treat the panel as special window which | |
7 - never has borders | |
8 - never has focus | |
9 - always has y=0 | |
10 - is never shown as active window in the indicators | |
11 - is shown on all tags (via config rule) | |
12 - is ignored on focusstack (MOD+j, MOD+k) | |
13 | |
14 Which window? "xfce4-panel" - configurable in config.h | |
15 --- | |
16 config.def.h | 2 ++ | |
17 dwm.c | 28 +++++++++++++++++++++------- | |
18 2 files changed, 23 insertions(+), 7 deletions(-) | |
19 | |
20 diff --git a/config.def.h b/config.def.h | |
21 index 1c0b587..3b9e7d6 100644 | |
22 --- a/config.def.h | |
23 +++ b/config.def.h | |
24 @@ -3,6 +3,7 @@ | |
25 /* appearance */ | |
26 static const unsigned int borderpx = 1; /* border pixel of wind… | |
27 static const unsigned int snap = 32; /* snap pixel */ | |
28 +static const char panel[][20] = { "xfce4-panel", "Xfce4-panel" };… | |
29 static const int showbar = 1; /* 0 means no bar */ | |
30 static const int topbar = 1; /* 0 means bottom bar */ | |
31 static const char *fonts[] = { "monospace:size=10" }; | |
32 @@ -29,6 +30,7 @@ static const Rule rules[] = { | |
33 /* class instance title tags mask isfloating … | |
34 { "Gimp", NULL, NULL, 0, 1, … | |
35 { "Firefox", NULL, NULL, 1 << 8, 0, … | |
36 + { panel[1], NULL, NULL, (1 << 9) - 1, 0, … | |
37 }; | |
38 | |
39 /* layout(s) */ | |
40 diff --git a/dwm.c b/dwm.c | |
41 index b0b3466..956d402 100644 | |
42 --- a/dwm.c | |
43 +++ b/dwm.c | |
44 @@ -175,6 +175,7 @@ static long getstate(Window w); | |
45 static int gettextprop(Window w, Atom atom, char *text, unsigned int si… | |
46 static void grabbuttons(Client *c, int focused); | |
47 static void grabkeys(void); | |
48 +static int ispanel(Client *c); | |
49 static void incnmaster(const Arg *arg); | |
50 static void keypress(XEvent *e); | |
51 static void killclient(const Arg *arg); | |
52 @@ -710,6 +711,8 @@ drawbar(Monitor *m) | |
53 } | |
54 | |
55 for (c = m->clients; c; c = c->next) { | |
56 + // prevent showing the panel as active application: | |
57 + if (ispanel(c)) continue; | |
58 occ |= c->tags; | |
59 if (c->isurgent) | |
60 urg |= c->tags; | |
61 @@ -793,11 +796,14 @@ focus(Client *c) | |
62 selmon = c->mon; | |
63 if (c->isurgent) | |
64 seturgent(c, 0); | |
65 - detachstack(c); | |
66 - attachstack(c); | |
67 - grabbuttons(c, 1); | |
68 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBord… | |
69 - setfocus(c); | |
70 + // prevents the panel getting focus when tag switching: | |
71 + if (!ispanel(c)) { | |
72 + detachstack(c); | |
73 + attachstack(c); | |
74 + grabbuttons(c, 1); | |
75 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].… | |
76 + setfocus(c); | |
77 + } | |
78 } else { | |
79 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTi… | |
80 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); | |
81 @@ -853,6 +859,7 @@ focusstack(const Arg *arg) | |
82 if (c) { | |
83 focus(c); | |
84 restack(selmon); | |
85 + if (ispanel(c)) focusstack(arg); | |
86 } | |
87 } | |
88 | |
89 @@ -964,6 +971,11 @@ grabkeys(void) | |
90 } | |
91 } | |
92 | |
93 +int | |
94 +ispanel(Client *c) { | |
95 + return !strcmp(c->name, panel[0]); | |
96 +} | |
97 + | |
98 void | |
99 incnmaster(const Arg *arg) | |
100 { | |
101 @@ -1049,7 +1061,8 @@ manage(Window w, XWindowAttributes *wa) | |
102 c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / … | |
103 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh :… | |
104 c->bw = borderpx; | |
105 - | |
106 + // no border - even when active | |
107 + if (ispanel(c)) c->bw = c->oldbw = 0; | |
108 wc.border_width = c->bw; | |
109 XConfigureWindow(dpy, w, CWBorderWidth, &wc); | |
110 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); | |
111 @@ -1283,6 +1296,7 @@ resizeclient(Client *c, int x, int y, int w, int h) | |
112 c->oldw = c->w; c->w = wc.width = w; | |
113 c->oldh = c->h; c->h = wc.height = h; | |
114 wc.border_width = c->bw; | |
115 + if (ispanel(c)) c->y = c->oldy = c->bw = wc.y = wc.border_width = 0; | |
116 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderW… | |
117 configure(c); | |
118 XSync(dpy, False); | |
119 @@ -1991,7 +2005,7 @@ void | |
120 updatestatus(void) | |
121 { | |
122 if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) | |
123 - strcpy(stext, "dwm-"VERSION); | |
124 + strcpy(stext, " "); // no shining of dwm version thru p… | |
125 drawbar(selmon); | |
126 } | |
127 | |
128 -- | |
129 2.31.1 | |
130 |