Removed regular systray patch and applied alpha-systray patch instead

This commit is contained in:
_N0x 2021-10-14 15:13:35 +02:00
parent 4c03c66993
commit 96c57c3c4b

View File

@ -59,6 +59,7 @@
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define SYSTEM_TRAY_REQUEST_DOCK 0 #define SYSTEM_TRAY_REQUEST_DOCK 0
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
/* XEMBED messages */ /* XEMBED messages */
#define XEMBED_EMBEDDED_NOTIFY 0 #define XEMBED_EMBEDDED_NOTIFY 0
@ -79,10 +80,9 @@
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel}; /* color schemes */ enum { SchemeNorm, SchemeSel}; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck, enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayVisual,
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz, NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDock,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetSystemTrayOrientationHorz, NetWMWindowTypeDialog, NetClientList, NetWMCheck, NetLast }; /* EWMH atoms */
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */ enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
@ -198,6 +198,7 @@ static void focus(Client *c);
static void focusin(XEvent *e); static void focusin(XEvent *e);
static void focusmon(const Arg *arg); static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg); static void focusstack(const Arg *arg);
static Atom getatomprop(Client *c, Atom prop);
static int getrootptr(int *x, int *y); static int getrootptr(int *x, int *y);
static long getstate(Window w); static long getstate(Window w);
static unsigned int getsystraywidth(); static unsigned int getsystraywidth();
@ -220,7 +221,6 @@ static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h); static Monitor *recttomon(int x, int y, int w, int h);
static void removesystrayicon(Client *i); static void removesystrayicon(Client *i);
static void resize(Client *c, int x, int y, int w, int h, int interact); static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizebarwin(Monitor *m);
static void resizeclient(Client *c, int x, int y, int w, int h); static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg); static void resizemouse(const Arg *arg);
static void resizerequest(XEvent *e); static void resizerequest(XEvent *e);
@ -259,7 +259,7 @@ static int updategeom(void);
static void updatenumlockmask(void); static void updatenumlockmask(void);
static void updatesizehints(Client *c); static void updatesizehints(Client *c);
static void updatestatus(void); static void updatestatus(void);
static void updatesystray(void); static void updatesystray(int updatebar);
static void updatesystrayicongeom(Client *i, int w, int h); static void updatesystrayicongeom(Client *i, int w, int h);
static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
static void updatetitle(Client *c); static void updatetitle(Client *c);
@ -277,6 +277,7 @@ static void zoom(const Arg *arg);
/* variables */ /* variables */
static Systray *systray = NULL; static Systray *systray = NULL;
static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
static const char autostartblocksh[] = "autostart_blocking.sh"; static const char autostartblocksh[] = "autostart_blocking.sh";
static const char autostartsh[] = "autostart.sh"; static const char autostartsh[] = "autostart.sh";
static const char broken[] = "broken"; static const char broken[] = "broken";
@ -537,6 +538,8 @@ cleanup(void)
while (mons) while (mons)
cleanupmon(mons); cleanupmon(mons);
if (showsystray) { if (showsystray) {
while (systray->icons)
removesystrayicon(systray->icons);
XUnmapWindow(dpy, systray->win); XUnmapWindow(dpy, systray->win);
XDestroyWindow(dpy, systray->win); XDestroyWindow(dpy, systray->win);
free(systray); free(systray);
@ -588,12 +591,7 @@ clientmessage(XEvent *e)
c->mon = selmon; c->mon = selmon;
c->next = systray->icons; c->next = systray->icons;
systray->icons = c; systray->icons = c;
if (!XGetWindowAttributes(dpy, c->win, &wa)) { XGetWindowAttributes(dpy, c->win, &wa);
/* use sane defaults */
wa.width = bh;
wa.height = bh;
wa.border_width = 0;
}
c->x = c->oldx = c->y = c->oldy = 0; c->x = c->oldx = c->y = c->oldy = 0;
c->w = c->oldw = wa.width; c->w = c->oldw = wa.width;
c->h = c->oldh = wa.height; c->h = c->oldh = wa.height;
@ -611,14 +609,9 @@ clientmessage(XEvent *e)
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa); XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION); sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
/* FIXME not sure if I have to send these events, too */
sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
XSync(dpy, False); XSync(dpy, False);
resizebarwin(selmon);
updatesystray();
setclientstate(c, NormalState); setclientstate(c, NormalState);
updatesystray(1);
} }
return; return;
} }
@ -674,7 +667,7 @@ configurenotify(XEvent *e)
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (c->isfullscreen) if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh); resizeclient(c, m->mx, m->my, m->mw, m->mh);
resizebarwin(m); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
} }
focus(NULL); focus(NULL);
arrange(NULL); arrange(NULL);
@ -760,10 +753,9 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window))) if ((c = wintoclient(ev->window)))
unmanage(c, 1); unmanage(c, 1);
else if ((c = wintosystrayicon(ev->window))) { else if (showsystray && (c = wintosystrayicon(ev->window))) {
removesystrayicon(c); removesystrayicon(c);
resizebarwin(selmon); updatesystray(1);
updatesystray();
} }
} }
@ -921,8 +913,11 @@ drawbar(Monitor *m)
unsigned int i, occ = 0, urg = 0; unsigned int i, occ = 0, urg = 0;
Client *c; Client *c;
if(showsystray && m == systraytomon(m)) if (showsystray && m == systraytomon(m)) {
stw = getsystraywidth(); stw = getsystraywidth();
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, m->ww - stw - 2 * sp, 0, stw, bh, 1, 1);
}
/* draw status first so it can be overdrawn by tags later */ /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
@ -932,7 +927,6 @@ drawbar(Monitor *m)
sw = m->ww - drawstatusbar(m, bh, stext, stw); sw = m->ww - drawstatusbar(m, bh, stext, stw);
} }
resizebarwin(m);
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
occ |= c->tags; occ |= c->tags;
if (c->isurgent) if (c->isurgent)
@ -966,7 +960,7 @@ drawbar(Monitor *m)
drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
} }
} }
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh); drw_map(drw, m->barwin, 0, 0, m->ww, bh);
} }
void void
@ -976,6 +970,9 @@ drawbars(void)
for (m = mons; m; m = m->next) for (m = mons; m; m = m->next)
drawbar(m); drawbar(m);
if (showsystray && !systraypinning)
updatesystray(0);
} }
void void
@ -1005,8 +1002,8 @@ expose(XEvent *e)
if (ev->count == 0 && (m = wintomon(ev->window))) { if (ev->count == 0 && (m = wintomon(ev->window))) {
drawbar(m); drawbar(m);
if (m == selmon) if (showsystray && m == systraytomon(m))
updatesystray(); updatesystray(0);
} }
} }
@ -1143,7 +1140,7 @@ getsystraywidth()
Client *i; Client *i;
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) ;
return w ? w + systrayspacing : 1; return w ? w + systrayspacing : 0;
} }
int int
@ -1339,10 +1336,9 @@ maprequest(XEvent *e)
static XWindowAttributes wa; static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest; XMapRequestEvent *ev = &e->xmaprequest;
Client *i; Client *i;
if ((i = wintosystrayicon(ev->window))) { if (showsystray && (i = wintosystrayicon(ev->window))) {
sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION); sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION);
resizebarwin(selmon); updatesystray(1);
updatesystray();
} }
if (!XGetWindowAttributes(dpy, ev->window, &wa)) if (!XGetWindowAttributes(dpy, ev->window, &wa))
@ -1468,15 +1464,14 @@ propertynotify(XEvent *e)
Window trans; Window trans;
XPropertyEvent *ev = &e->xproperty; XPropertyEvent *ev = &e->xproperty;
if ((c = wintosystrayicon(ev->window))) { if (showsystray && (c = wintosystrayicon(ev->window))) {
if (ev->atom == XA_WM_NORMAL_HINTS) { if (ev->atom == XA_WM_NORMAL_HINTS) {
updatesizehints(c); updatesizehints(c);
updatesystrayicongeom(c, c->w, c->h); updatesystrayicongeom(c, c->w, c->h);
} }
else else
updatesystrayiconstate(c, ev); updatesystrayiconstate(c, ev);
resizebarwin(selmon); updatesystray(1);
updatesystray();
} }
if ((ev->window == root) && (ev->atom == XA_WM_NAME)) if ((ev->window == root) && (ev->atom == XA_WM_NAME))
updatestatus(); updatestatus();
@ -1549,14 +1544,6 @@ resize(Client *c, int x, int y, int w, int h, int interact)
resizeclient(c, x, y, w, h); resizeclient(c, x, y, w, h);
} }
void
resizebarwin(Monitor *m) {
unsigned int w = m->ww;
if (showsystray && m == systraytomon(m))
w -= getsystraywidth();
XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, w - 2 * sp, bh);
}
void void
resizeclient(Client *c, int x, int y, int w, int h) resizeclient(Client *c, int x, int y, int w, int h)
{ {
@ -1637,8 +1624,7 @@ resizerequest(XEvent *e)
if ((i = wintosystrayicon(ev->window))) { if ((i = wintosystrayicon(ev->window))) {
updatesystrayicongeom(i, ev->width, ev->height); updatesystrayicongeom(i, ev->width, ev->height);
resizebarwin(selmon); updatesystray(1);
updatesystray();
} }
} }
@ -1958,11 +1944,13 @@ setup(void)
netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False); netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False); netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False);
netatom[NetSystemTrayOrientationHorz] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False); netatom[NetSystemTrayOrientationHorz] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False);
netatom[NetSystemTrayVisual] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_VISUAL", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
netatom[NetWMWindowTypeDock] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
xatom[Manager] = XInternAtom(dpy, "MANAGER", False); xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
@ -1978,7 +1966,8 @@ setup(void)
for (i = 0; i < LENGTH(colors); i++) for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
/* init system tray */ /* init system tray */
updatesystray(); if (showsystray)
updatesystray(0);
/* init bars */ /* init bars */
updatebars(); updatebars();
updatestatus(); updatestatus();
@ -2062,6 +2051,23 @@ spawn(const Arg *arg)
} }
} }
Monitor *
systraytomon(Monitor *m)
{
Monitor *t;
int i, n;
if (!systraypinning) {
if (!m)
return selmon;
return m == selmon ? m : NULL;
}
for (n = 1, t = mons; t && t->next; n++, t = t->next);
for (i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next);
if (systraypinningfailfirst && n < systraypinning)
return mons;
return t;
}
void void
tag(const Arg *arg) tag(const Arg *arg)
{ {
@ -2111,15 +2117,15 @@ togglebar(const Arg *arg)
{ {
selmon->showbar = !selmon->showbar; selmon->showbar = !selmon->showbar;
updatebarpos(selmon); updatebarpos(selmon);
resizebarwin(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh);
if (showsystray) { if (showsystray) {
XWindowChanges wc; XWindowChanges wc;
if (!selmon->showbar) if (!selmon->showbar)
wc.y = -bh; wc.y = -bh;
else if (selmon->showbar) { else if (selmon->showbar) {
wc.y = 0; wc.y = vp;
if (!selmon->topbar) if (!selmon->topbar)
wc.y = selmon->mh - bh; wc.y = selmon->mh - bh + vp;
} }
XConfigureWindow(dpy, systray->win, CWY, &wc); XConfigureWindow(dpy, systray->win, CWY, &wc);
} }
@ -2217,18 +2223,17 @@ unmapnotify(XEvent *e)
else else
unmanage(c, 0); unmanage(c, 0);
} }
else if ((c = wintosystrayicon(ev->window))) { else if (showsystray && (c = wintosystrayicon(ev->window))) {
/* KLUDGE! sometimes icons occasionally unmap their windows, but do /* KLUDGE! sometimes icons occasionally unmap their windows, but do
* _not_ destroy them. We map those windows back */ * _not_ destroy them. We map those windows back */
XMapRaised(dpy, c->win); XMapRaised(dpy, c->win);
updatesystray(); updatesystray(1);
} }
} }
void void
updatebars(void) updatebars(void)
{ {
unsigned int w;
Monitor *m; Monitor *m;
XSetWindowAttributes wa = { XSetWindowAttributes wa = {
.override_redirect = True, .override_redirect = True,
@ -2241,13 +2246,10 @@ updatebars(void)
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
if (m->barwin) if (m->barwin)
continue; continue;
w = m->ww;
if (showsystray && m == systraytomon(m))
w -= getsystraywidth();
//m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w -2 * sp, bh, 0, DefaultDepth(dpy, screen), //m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w -2 * sp, bh, 0, DefaultDepth(dpy, screen),
// CopyFromParent, DefaultVisual(dpy, screen), // CopyFromParent, DefaultVisual(dpy, screen),
// CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); // CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, depth, m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, depth,
InputOutput, visual, InputOutput, visual,
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
@ -2428,7 +2430,6 @@ updatestatus(void)
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION); strcpy(stext, "dwm-"VERSION);
drawbar(selmon); drawbar(selmon);
updatesystray();
} }
void void
@ -2451,6 +2452,8 @@ updatesystrayicongeom(Client *i, int w, int h)
i->w = (int) ((float)bh * ((float)i->w / (float)i->h)); i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
i->h = bh; i->h = bh;
} }
if (i->w > 2*bh)
i->w = bh;
} }
} }
@ -2483,15 +2486,16 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev)
} }
void void
updatesystray(void) updatesystray(int updatebar)
{ {
XSetWindowAttributes wa; XSetWindowAttributes wa;
XWindowChanges wc; XWindowChanges wc;
Client *i; Client *i;
Monitor *m = systraytomon(NULL); Monitor *m = systraytomon(NULL);
unsigned int x = m->mx + m->mw - sp; unsigned int x = m->mx + m->mw;
unsigned int y = m->by + vp; unsigned int w = 1, xpad = 0, ypad = 0;
unsigned int w = 1; xpad = sp;
ypad = vp;
if (!showsystray) if (!showsystray)
return; return;
@ -2499,14 +2503,22 @@ updatesystray(void)
/* init systray */ /* init systray */
if (!(systray = (Systray *)calloc(1, sizeof(Systray)))) if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
die("fatal: could not malloc() %u bytes\n", sizeof(Systray)); die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
systray->win = XCreateSimpleWindow(dpy, root, x, y, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
wa.event_mask = ButtonPressMask | ExposureMask;
wa.override_redirect = True; wa.override_redirect = True;
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; wa.event_mask = ButtonPressMask|ExposureMask;
wa.background_pixel = 0;
wa.border_pixel = 0;
wa.colormap = cmap;
systray->win = XCreateWindow(dpy, root, x - xpad, m->by + ypad, w, bh, 0, depth,
InputOutput, visual,
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
XSelectInput(dpy, systray->win, SubstructureNotifyMask); XSelectInput(dpy, systray->win, SubstructureNotifyMask);
XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32, XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&netatom[NetSystemTrayOrientationHorz], 1); PropModeReplace, (unsigned char *)&systrayorientation, 1);
XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel, &wa); XChangeProperty(dpy, systray->win, netatom[NetSystemTrayVisual], XA_VISUALID, 32,
PropModeReplace, (unsigned char *)&visual->visualid, 1);
XChangeProperty(dpy, systray->win, netatom[NetWMWindowType], XA_ATOM, 32,
PropModeReplace, (unsigned char *)&netatom[NetWMWindowTypeDock], 1);
XMapRaised(dpy, systray->win); XMapRaised(dpy, systray->win);
XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime); XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) { if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
@ -2521,8 +2533,7 @@ updatesystray(void)
} }
} }
for (w = 0, i = systray->icons; i; i = i->next) { for (w = 0, i = systray->icons; i; i = i->next) {
/* make sure the background color stays the same */ wa.background_pixel = 0;
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa); XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
XMapRaised(dpy, i->win); XMapRaised(dpy, i->win);
w += systrayspacing; w += systrayspacing;
@ -2534,23 +2545,19 @@ updatesystray(void)
} }
w = w ? w + systrayspacing : 1; w = w ? w + systrayspacing : 1;
x -= w; x -= w;
XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh); XMoveResizeWindow(dpy, systray->win, x - xpad, m->by + ypad, w, bh);
wc.x = x; wc.x = x - xpad;
wc.y = y; wc.y = m->by + ypad;
wc.width = w; wc.width = w;
wc.height = bh; wc.height = bh;
wc.stack_mode = Above; wc.stack_mode = Above; wc.sibling = m->barwin;
wc.sibling = m->barwin;
XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc); XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
XMapWindow(dpy, systray->win); XMapWindow(dpy, systray->win);
XMapSubwindows(dpy, systray->win); XMapSubwindows(dpy, systray->win);
/* redraw background */
XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
// FIXME:
//XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
XSync(dpy, False); XSync(dpy, False);
if (updatebar)
drawbar(m);
} }
void void
updatetitle(Client *c) updatetitle(Client *c)
{ {
@ -2679,22 +2686,6 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return -1; return -1;
} }
Monitor *
systraytomon(Monitor *m) {
Monitor *t;
int i, n;
if(!systraypinning) {
if(!m)
return selmon;
return m == selmon ? m : NULL;
}
for(n = 1, t = mons; t && t->next; n++, t = t->next) ;
for(i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next) ;
if(systraypinningfailfirst && n < systraypinning)
return mons;
return t;
}
void void
xinitvisual() xinitvisual()
{ {