diff options
| author | bakkeby <[email protected]> | 2022-06-27 11:07:26 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2022-06-27 11:07:26 +0200 |
| commit | 404401622b89b8e9f9d76b8ec28129623387d737 (patch) | |
| tree | 33d8c64b65c6d036de9e0bf3fdcc7d28e9d2b27c | |
| parent | 2f70c42aab2ac71f5cdb1996499247f2268c98ce (diff) | |
| download | dwm-flexipatch-404401622b89b8e9f9d76b8ec28129623387d737.tar.gz dwm-flexipatch-404401622b89b8e9f9d76b8ec28129623387d737.zip | |
systray: hide systray when there are no systray icons to show ref. #268
| -rw-r--r-- | patch/bar_systray.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/patch/bar_systray.c b/patch/bar_systray.c index 158dfa3..be337e4 100644 --- a/patch/bar_systray.c +++ b/patch/bar_systray.c @@ -8,8 +8,11 @@ width_systray(Bar *bar, BarArg *a) Client *i; if (!systray) return 1; - if (showsystray) + if (showsystray) { for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); + if (!w) + XMoveWindow(dpy, systray->win, -systray->h, bar->by); + } return w ? w + lrpad - systrayspacing : 0; } @@ -36,12 +39,12 @@ draw_systray(Bar *bar, BarArg *a) #if BAR_ALPHA_PATCH wa.background_pixel = 0; wa.colormap = cmap; - systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MAX(a->w + 40, 1), systray->h, 0, depth, + systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MAX(a->w + 40, 1), systray->h, 0, depth, InputOutput, visual, CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap #else wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; - systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel); + systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel); XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa); #endif // BAR_ALPHA_PATCH @@ -91,7 +94,7 @@ draw_systray(Bar *bar, BarArg *a) i->mon = bar->mon; } - XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -bar->by - a->y), MAX(w, 1), systray->h); + XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -systray->h), MAX(w, 1), systray->h); return w; } |
