mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
systray: hide systray when there are no systray icons to show ref. #268
This commit is contained in:
parent
2f70c42aab
commit
404401622b
@ -8,8 +8,11 @@ width_systray(Bar *bar, BarArg *a)
|
|||||||
Client *i;
|
Client *i;
|
||||||
if (!systray)
|
if (!systray)
|
||||||
return 1;
|
return 1;
|
||||||
if (showsystray)
|
if (showsystray) {
|
||||||
for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next);
|
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;
|
return w ? w + lrpad - systrayspacing : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,12 +39,12 @@ draw_systray(Bar *bar, BarArg *a)
|
|||||||
#if BAR_ALPHA_PATCH
|
#if BAR_ALPHA_PATCH
|
||||||
wa.background_pixel = 0;
|
wa.background_pixel = 0;
|
||||||
wa.colormap = cmap;
|
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,
|
InputOutput, visual,
|
||||||
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
|
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
|
||||||
#else
|
#else
|
||||||
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
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);
|
XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa);
|
||||||
#endif // BAR_ALPHA_PATCH
|
#endif // BAR_ALPHA_PATCH
|
||||||
|
|
||||||
@ -91,7 +94,7 @@ draw_systray(Bar *bar, BarArg *a)
|
|||||||
i->mon = bar->mon;
|
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;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user