diff --git a/bar/systray.c b/bar/systray.c index 26ce3e5..722ffc7 100644 --- a/bar/systray.c +++ b/bar/systray.c @@ -8,19 +8,21 @@ width_systray(Bar *bar, BarWidthArg *a) Client *i; if (!systray) return 1; - if (!selmon->hidesystray) - for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); - return w ? w + lrpad - systrayspacing : 0; + if (!selmon->hidesystray) { + for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); + return w ? w + lrpad - systrayspacing : 0; + } else { + return 0; + } } int draw_systray(Bar *bar, BarDrawArg *a) { if (selmon->hidesystray) { - if (systray) - XMoveWindow(dpy, systray->win, -500, bar->by); - return a->x; - } + if (systray) + XMoveWindow(dpy, systray->win, -500, bar->by); + } XSetWindowAttributes wa; Client *i; @@ -91,8 +93,9 @@ removesystrayicon(Client *i) { Client **ii; - if (selmon->hidesystray || !i) - return; + if (!i) + return; + for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next); if (ii) *ii = i->next; @@ -143,7 +146,7 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev) long flags; int code = 0; - if (hidesystray || !systray || !i || ev->atom != xatom[XembedInfo] || + if (selmon->hidesystray || !systray || !i || ev->atom != xatom[XembedInfo] || !(flags = getatomprop(i, xatom[XembedInfo]))) return; @@ -171,7 +174,7 @@ wintosystrayicon(Window w) if (!systray) return NULL; Client *i = NULL; - if (hidesystray || !w) + if (selmon->hidesystray || !w) return i; for (i = systray->icons; i && i->win != w; i = i->next); return i; diff --git a/keybinds.h b/keybinds.h index 4f7adca..73ba6ee 100644 --- a/keybinds.h +++ b/keybinds.h @@ -85,6 +85,11 @@ static Key keys[] = { { MODIFIER1, -1, XK_Tab, switcherstart, {0} }, #endif + /* Systray */ + #if USESYSTRAY + { MODIFIER1, -1, XK_s, togglesystray, {0} }, + #endif + /* Layout keybinds */ { MODIFIER1|CONTROL|SHIFT, -1, XK_a, cyclelayout, {.i = -1 } }, { MODIFIER1|CONTROL|SHIFT, -1, XK_d, cyclelayout, {.i = +1 } }, diff --git a/speedwm.c b/speedwm.c index 4417a9c..eca84f2 100644 --- a/speedwm.c +++ b/speedwm.c @@ -648,6 +648,9 @@ static void set_s_layout(const Arg *arg); /* bar items */ static void togglebar(const Arg *arg); static void togglebartags(const Arg *arg); +#if USESYSTRAY +static void togglesystray(const Arg *arg); +#endif static void togglebaremptytags(const Arg *arg); static void togglebartitle(const Arg *arg); static void togglebarlt(const Arg *arg); @@ -5488,6 +5491,28 @@ togglebar(const Arg *arg) arrange(selmon); } +#if USESYSTRAY +void +togglesystray(const Arg *arg) +{ + Bar *bar; + Client *c; + + selmon->hidesystray = !selmon->hidesystray; + + /* + if (selmon->hidesystray) { + removesystrayicon(systray->icons); + //XUnmapWindow(dpy, systray->win); + //XDestroyWindow(dpy, systray->win); + free(systray); + } + */ + + updatebarpos(selmon); + arrange(selmon); +} +#endif void togglebartags(const Arg *arg)