dwm-xfce4-panel-20220306-d39e2f3.diff (4775B)
1 From 2cf1eff75a6dc6ee21ed37f4f57a1eb4bf588b9f Mon Sep 17 00:00:00 2001 2 From: Gunther Klessinger <gunther.klessinger@axiros.com> 3 Date: Sun, 6 Mar 2022 10:32:29 +0100 4 Subject: [PATCH] fix: Fixing problems at monitor setup changes 5 6 - Panel was sometimes out of place when monitor setup was changed on the 7 fly 8 - Patch less intrusive than the previous one. 9 - Tested with dwm6.3 and 6.2. 10 --- 11 config.def.h | 2 ++ 12 dwm.c | 36 +++++++++++++++++++++++++++++------- 13 2 files changed, 31 insertions(+), 7 deletions(-) 14 15 diff --git a/config.def.h b/config.def.h 16 index a2ac963..eaf909e 100644 17 --- a/config.def.h 18 +++ b/config.def.h 19 @@ -3,6 +3,7 @@ 20 /* appearance */ 21 static const unsigned int borderpx = 1; /* border pixel of windows */ 22 static const unsigned int snap = 32; /* snap pixel */ 23 +static const char panel[][20] = { "xfce4-panel", "Xfce4-panel" }; /* name & cls of panel win */ 24 static const int showbar = 1; /* 0 means no bar */ 25 static const int topbar = 1; /* 0 means bottom bar */ 26 static const char *fonts[] = { "monospace:size=10" }; 27 @@ -29,6 +30,7 @@ static const Rule rules[] = { 28 /* class instance title tags mask isfloating monitor */ 29 { "Gimp", NULL, NULL, 0, 1, -1 }, 30 { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, 31 + { panel[1], NULL, NULL, (1 << 9) - 1, 1, -1 }, 32 }; 33 34 /* layout(s) */ 35 diff --git a/dwm.c b/dwm.c 36 index a96f33c..458f3dc 100644 37 --- a/dwm.c 38 +++ b/dwm.c 39 @@ -175,6 +175,7 @@ static long getstate(Window w); 40 static int gettextprop(Window w, Atom atom, char *text, unsigned int size); 41 static void grabbuttons(Client *c, int focused); 42 static void grabkeys(void); 43 +static int ispanel(Client *c); 44 static void incnmaster(const Arg *arg); 45 static void keypress(XEvent *e); 46 static void killclient(const Arg *arg); 47 @@ -713,6 +714,8 @@ drawbar(Monitor *m) 48 } 49 50 for (c = m->clients; c; c = c->next) { 51 + // prevent showing the panel as active application: 52 + if (ispanel(c)) continue; 53 occ |= c->tags; 54 if (c->isurgent) 55 urg |= c->tags; 56 @@ -796,11 +799,14 @@ focus(Client *c) 57 selmon = c->mon; 58 if (c->isurgent) 59 seturgent(c, 0); 60 - detachstack(c); 61 - attachstack(c); 62 - grabbuttons(c, 1); 63 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 64 - setfocus(c); 65 + // prevents the panel getting focus when tag switching: 66 + if (!ispanel(c)) { 67 + detachstack(c); 68 + attachstack(c); 69 + grabbuttons(c, 1); 70 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); 71 + setfocus(c); 72 + } 73 } else { 74 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 75 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); 76 @@ -833,6 +839,7 @@ focusmon(const Arg *arg) 77 focus(NULL); 78 } 79 80 +int focussed_panel = 0; // helper for focusstack, avoids loops when panel is the only client 81 void 82 focusstack(const Arg *arg) 83 { 84 @@ -857,6 +864,12 @@ focusstack(const Arg *arg) 85 focus(c); 86 restack(selmon); 87 } 88 + // skipping the panel when switching focus: 89 + if (ispanel(c) && focussed_panel == 0) { 90 + focussed_panel = 1; 91 + focusstack(arg); 92 + focussed_panel = 0; 93 + } 94 } 95 96 Atom 97 @@ -967,6 +980,11 @@ grabkeys(void) 98 } 99 } 100 101 +int 102 +ispanel(Client *c) { 103 + return !strcmp(c->name, panel[0]); 104 +} 105 + 106 void 107 incnmaster(const Arg *arg) 108 { 109 @@ -1053,6 +1071,8 @@ manage(Window w, XWindowAttributes *wa) 110 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); 111 c->bw = borderpx; 112 113 + // no border - even when active 114 + if (ispanel(c)) c->bw = c->oldbw = 0; 115 wc.border_width = c->bw; 116 XConfigureWindow(dpy, w, CWBorderWidth, &wc); 117 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); 118 @@ -1272,7 +1292,7 @@ recttomon(int x, int y, int w, int h) 119 void 120 resize(Client *c, int x, int y, int w, int h, int interact) 121 { 122 - if (applysizehints(c, &x, &y, &w, &h, interact)) 123 + if (ispanel(c) || applysizehints(c, &x, &y, &w, &h, interact)) 124 resizeclient(c, x, y, w, h); 125 } 126 127 @@ -1286,6 +1306,8 @@ resizeclient(Client *c, int x, int y, int w, int h) 128 c->oldw = c->w; c->w = wc.width = w; 129 c->oldh = c->h; c->h = wc.height = h; 130 wc.border_width = c->bw; 131 + // nail it to no border & y=0: 132 + if (ispanel(c)) c->y = c->oldy = c->bw = wc.y = wc.border_width = 0; 133 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); 134 configure(c); 135 XSync(dpy, False); 136 @@ -1994,7 +2016,7 @@ void 137 updatestatus(void) 138 { 139 if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) 140 - strcpy(stext, "dwm-"VERSION); 141 + strcpy(stext, ""); // no shining of dwm version thru panel, when transparent 142 drawbar(selmon); 143 } 144 145 -- 146 2.31.1 147