dwm-xfce4-panel-20210611-67d76bd.diff (4171B)
1 From 7a9b83d0d74f9aca800c1ec0d2e698449c166e86 Mon Sep 17 00:00:00 2001 2 From: Gunther Klessinger <gunther.klessinger@axiros.com> 3 Date: Fri, 11 Jun 2021 21:54:29 +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 13 Which window? "xfce4-panel" - configurable in config.h 14 15 => Might work for other panels as well, if you adapt. 16 --- 17 config.def.h | 2 ++ 18 dwm.c | 27 ++++++++++++++++++++------- 19 2 files changed, 22 insertions(+), 7 deletions(-) 20 21 diff --git a/config.def.h b/config.def.h 22 index 1c0b587..3b9e7d6 100644 23 --- a/config.def.h 24 +++ b/config.def.h 25 @@ -3,6 +3,7 @@ 26 /* appearance */ 27 static const unsigned int borderpx = 1; /* border pixel of windows */ 28 static const unsigned int snap = 32; /* snap pixel */ 29 +static const char panel[][20] = { "xfce4-panel", "Xfce4-panel" }; /* name & cls of panel win */ 30 static const int showbar = 1; /* 0 means no bar */ 31 static const int topbar = 1; /* 0 means bottom bar */ 32 static const char *fonts[] = { "monospace:size=10" }; 33 @@ -29,6 +30,7 @@ static const Rule rules[] = { 34 /* class instance title tags mask isfloating monitor */ 35 { "Gimp", NULL, NULL, 0, 1, -1 }, 36 { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, 37 + { panel[1], NULL, NULL, (1 << 9) - 1, 0, -1 }, 38 }; 39 40 /* layout(s) */ 41 diff --git a/dwm.c b/dwm.c 42 index b0b3466..a3b618b 100644 43 --- a/dwm.c 44 +++ b/dwm.c 45 @@ -175,6 +175,7 @@ static long getstate(Window w); 46 static int gettextprop(Window w, Atom atom, char *text, unsigned int size); 47 static void grabbuttons(Client *c, int focused); 48 static void grabkeys(void); 49 +static int ispanel(Client *c); 50 static void incnmaster(const Arg *arg); 51 static void keypress(XEvent *e); 52 static void killclient(const Arg *arg); 53 @@ -710,6 +711,8 @@ drawbar(Monitor *m) 54 } 55 56 for (c = m->clients; c; c = c->next) { 57 + // prevent showing the panel as active application: 58 + if (ispanel(c)) continue; 59 occ |= c->tags; 60 if (c->isurgent) 61 urg |= c->tags; 62 @@ -793,11 +796,14 @@ focus(Client *c) 63 selmon = c->mon; 64 if (c->isurgent) 65 seturgent(c, 0); 66 - detachstack(c); 67 - attachstack(c); 68 - grabbuttons(c, 1); 69 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 70 - setfocus(c); 71 + // prevents the panel getting focus when tag switching: 72 + if (!ispanel(c)) { 73 + detachstack(c); 74 + attachstack(c); 75 + grabbuttons(c, 1); 76 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 77 + setfocus(c); 78 + } 79 } else { 80 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 81 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); 82 @@ -964,6 +970,11 @@ grabkeys(void) 83 } 84 } 85 86 +int 87 +ispanel(Client *c) { 88 + return !strcmp(c->name, panel[0]); 89 +} 90 + 91 void 92 incnmaster(const Arg *arg) 93 { 94 @@ -1049,7 +1060,8 @@ manage(Window w, XWindowAttributes *wa) 95 c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) 96 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); 97 c->bw = borderpx; 98 - 99 + // no border - even when active 100 + if (ispanel(c)) c->bw = c->oldbw = 0; 101 wc.border_width = c->bw; 102 XConfigureWindow(dpy, w, CWBorderWidth, &wc); 103 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); 104 @@ -1283,6 +1295,7 @@ resizeclient(Client *c, int x, int y, int w, int h) 105 c->oldw = c->w; c->w = wc.width = w; 106 c->oldh = c->h; c->h = wc.height = h; 107 wc.border_width = c->bw; 108 + if (ispanel(c)) c->y = c->oldy = c->bw = wc.y = wc.border_width = 0; 109 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); 110 configure(c); 111 XSync(dpy, False); 112 @@ -1991,7 +2004,7 @@ void 113 updatestatus(void) 114 { 115 if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) 116 - strcpy(stext, "dwm-"VERSION); 117 + strcpy(stext, " "); // no shining of dwm version thru panel, when transparent 118 drawbar(selmon); 119 } 120 121 -- 122 2.31.1 123