mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 12:05:45 +00:00
systray: avoid dwm crashing when removing the monitor where the systray is running (fix ref. #70)
This commit is contained in:
parent
558849940b
commit
a947f8d667
13
dwm.c
13
dwm.c
@ -1133,8 +1133,10 @@ cleanupmon(Monitor *mon)
|
||||
XDestroyWindow(dpy, bar->win);
|
||||
}
|
||||
mon->bar = bar->next;
|
||||
#if BAR_SYSTRAY_PATCH
|
||||
if (systray && bar == systray->bar)
|
||||
systray->bar = NULL;
|
||||
#endif // BAR_SYSTRAY_PATCH
|
||||
free(bar);
|
||||
}
|
||||
free(mon);
|
||||
@ -1645,7 +1647,9 @@ drawbarwin(Bar *bar)
|
||||
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;
|
||||
#if BAR_SYSTRAY_PATCH
|
||||
Monitor *lastmon;
|
||||
#endif // BAR_SYSTRAY_PATCH
|
||||
|
||||
if (bar->borderpx) {
|
||||
XSetForeground(drw->dpy, drw->gc, scheme[bar->borderscheme][ColBorder].pixel);
|
||||
@ -1659,7 +1663,9 @@ drawbarwin(Bar *bar)
|
||||
rw = lw = bar->bw - 2 * bar->borderpx;
|
||||
rx = lx = bar->borderpx;
|
||||
|
||||
#if BAR_SYSTRAY_PATCH
|
||||
for (lastmon = mons; lastmon && lastmon->next; lastmon = lastmon->next);
|
||||
#endif // BAR_SYSTRAY_PATCH
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, lx, bar->borderpx, lw, bar->bh - 2 * bar->borderpx, 1, 1);
|
||||
@ -1667,8 +1673,11 @@ drawbarwin(Bar *bar)
|
||||
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 &&
|
||||
(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
|
||||
if (br->monitor != 'A' && br->monitor != -1 && br->monitor != bar->mon->index
|
||||
#if BAR_SYSTRAY_PATCH
|
||||
&& (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
|
||||
#endif // BAR_SYSTRAY_PATCH
|
||||
)
|
||||
continue;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
warg.w = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw);
|
||||
|
Loading…
x
Reference in New Issue
Block a user