From 8d754cd644bcdf5303a6e8e359ab66518e8d2dfb Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 1 Jul 2024 09:53:43 +0200 Subject: [PATCH] systray + xrdb compatibility issue ref. #429 When changing colour scheme during runtime using xrdb the systray and icons would keep the original colours. To work around that the systray icon windows need to be redrawn after changing the background pixel value. Just calling XClearWindow for each systray window results in the systray icons disappearing, they do not automatically redraw. The solution is apparently to send an Expose event to each window which should in principle trigger a redraw from the application side. One way to achieve this is to move the window out of the drawable area. When the window is then brought back into view the X server will send the Expose event for the window. The "easiest" way to do this is to move the entire systray window out of view as part of the xrdb call. It is possible to do this in the draw_systray function itself, but we probably do not want to do this every single time the bar is drawn and it may also cause some noticeable flickering. This issue is isolated to using the systray without the alpha patch. --- patch/bar_systray.c | 6 ++++++ patch/xrdb.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/patch/bar_systray.c b/patch/bar_systray.c index be337e4..5d18e7c 100644 --- a/patch/bar_systray.c +++ b/patch/bar_systray.c @@ -94,6 +94,12 @@ draw_systray(Bar *bar, BarArg *a) i->mon = bar->mon; } + #if !BAR_ALPHA_PATCH + wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + XChangeWindowAttributes(dpy, systray->win, CWBackPixel, &wa); + XClearWindow(dpy, systray->win); + #endif // BAR_ALPHA_PATCH + 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; } diff --git a/patch/xrdb.c b/patch/xrdb.c index aa14969..640020a 100644 --- a/patch/xrdb.c +++ b/patch/xrdb.c @@ -132,6 +132,11 @@ xrdb(const Arg *arg) #endif // BAR_ALPHA_PATCH ColCount ); + #if BAR_SYSTRAY_PATCH && !BAR_ALPHA_PATCH + if (systray) { + XMoveWindow(dpy, systray->win, -32000, -32000); + } + #endif // BAR_SYSTRAY_PATCH arrange(NULL); focus(NULL); }