summaryrefslogtreecommitdiffhomepage
path: root/dwm.c
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-11-05 12:08:18 +0100
committerbakkeby <[email protected]>2020-11-05 12:08:18 +0100
commitf662f6e749cc853afd124393b2d28919b5f355b5 (patch)
tree1777b445136f8733aa986874514e47a9f58d4505 /dwm.c
parent7bfcd388f6d2a45d5753a909a5a8c2cf91529194 (diff)
downloaddwm-flexipatch-f662f6e749cc853afd124393b2d28919b5f355b5.tar.gz
dwm-flexipatch-f662f6e749cc853afd124393b2d28919b5f355b5.zip
systray: avoid dwm crashing when removing the monitor where the systray is running (hotplugging issues)
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index aa3b145..d7087f1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1133,6 +1133,8 @@ cleanupmon(Monitor *mon)
XDestroyWindow(dpy, bar->win);
}
mon->bar = bar->next;
+ if (systray && bar == systray->bar)
+ systray->bar = NULL;
free(bar);
}
free(mon);
@@ -1265,7 +1267,7 @@ configurenotify(XEvent *e)
sw = ev->width;
sh = ev->height;
if (updategeom() || dirty) {
- drw_resize(drw, sw, bh);
+ drw_resize(drw, sw, sh);
updatebars();
for (m = mons; m; m = m->next) {
#if !FAKEFULLSCREEN_PATCH
@@ -1638,11 +1640,12 @@ drawbars(void)
void
drawbarwin(Bar *bar)
{
- if (!bar->win || bar->external)
+ if (!bar || !bar->win || bar->external)
return;
int r, w, total_drawn = 0;
int rx, lx, rw, lw; // bar size, split between left and right if a center module is added
const BarRule *br;
+ Monitor *lastmon;
if (bar->borderpx) {
XSetForeground(drw->dpy, drw->gc, scheme[bar->borderscheme][ColBorder].pixel);
@@ -1656,13 +1659,16 @@ drawbarwin(Bar *bar)
rw = lw = bar->bw - 2 * bar->borderpx;
rx = lx = bar->borderpx;
+ for (lastmon = mons; lastmon && lastmon->next; lastmon = lastmon->next);
+
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, lx, bar->borderpx, lw, bar->bh - 2 * bar->borderpx, 1, 1);
for (r = 0; r < LENGTH(barrules); r++) {
br = &barrules[r];
if (br->bar != bar->idx || !br->widthfunc || (br->monitor == 'A' && bar->mon != selmon))
continue;
- if (br->monitor != 'A' && br->monitor != -1 && br->monitor != bar->mon->index)
+ if (br->monitor != 'A' && br->monitor != -1 && br->monitor != bar->mon->index &&
+ (br->drawfunc != draw_systray || (lastmon->index >= br->monitor && bar->mon->index == 0))) // hack: draw systray on first monitor if the designated one is not available
continue;
drw_setscheme(drw, scheme[SchemeNorm]);
warg.w = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw);