Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAR_SYSTRAY_PATCH and XRDB_PATCH colour issue #429

Open
Ampnbsp opened this issue Jun 30, 2024 · 5 comments
Open

BAR_SYSTRAY_PATCH and XRDB_PATCH colour issue #429

Ampnbsp opened this issue Jun 30, 2024 · 5 comments

Comments

@Ampnbsp
Copy link
Contributor

Ampnbsp commented Jun 30, 2024

When I update dwm colours with dwmc xrdb, the system tray icons keep the old background colour, but not the new one.

@bakkeby
Copy link
Owner

bakkeby commented Jun 30, 2024

I can imagine that happening. I take it that this is specifically when not using the alpha patch?

@Ampnbsp
Copy link
Contributor Author

Ampnbsp commented Jul 1, 2024

Yes, my full patchlist is:

#define BAR_DWMBLOCKS_PATCH 1
#define BAR_LAYOUTMENU_PATCH 1
#define BAR_LTSYMBOL_PATCH 1
#define BAR_STATUS_PATCH 1
#define BAR_STATUSCMD_PATCH 1
#define BAR_SYSTRAY_PATCH 1
#define BAR_TAGS_PATCH 1
#define BAR_WINTITLE_PATCH 1
#define BAR_EXTRASTATUS_PATCH 1
#define BAR_EWMHTAGS_PATCH 1
#define BAR_HIDEVACANTTAGS_PATCH 1
#define BAR_NO_COLOR_EMOJI_PATCH 1
#define BAR_STATUSALLMONS_PATCH 1
#define ALWAYSCENTER_PATCH 1
#define AUTOSTART_PATCH 1
#define AUTORESIZE_PATCH 1
#define CFACTS_PATCH 1
#define DRAGCFACT_PATCH 1
#define DRAGMFACT_PATCH 1
#define DWMC_PATCH 1
#define FAKEFULLSCREEN_CLIENT_PATCH 1
#define FOCUSONCLICK_PATCH 1
#define FOCUSONNETACTIVE_PATCH 1
#define LOSEFULLSCREEN_PATCH 1
#define MONITOR_RULES_PATCH 1
#define MOVESTACK_PATCH 1
#define NET_CLIENT_LIST_STACKING_PATCH 1
#define NODMENU_PATCH 1
#define NO_MOD_BUTTONS_PATCH 1
#define NO_TRANSPARENT_BORDERS_PATCH 1
#define PERTAG_PATCH 1
#define PLACEMOUSE_PATCH 1
#define RENAMED_SCRATCHPADS_PATCH 1
#define RESIZEPOINT_PATCH 1
#define RESTARTSIG_PATCH 1
#define SAVEFLOATS_PATCH 1
#define SEAMLESS_RESTART_PATCH 1
#define SELFRESTART_PATCH 1
#define SENDMON_CENTER_PATCH 1
#define SENDMON_KEEPFOCUS_PATCH 1
#define SHIFTTAG_PATCH 1
#define SHIFTVIEW_CLIENTS_PATCH 1
#define STEAM_PATCH 1
#define STICKY_PATCH 1
#define SWALLOW_PATCH 1
#define SWAPFOCUS_PATCH 1
#define SWITCHTAG_PATCH 1
#define TAGMONFIXFS_PATCH 1
#define TOGGLEFULLSCREEN_PATCH 1
#define VIEW_HISTORY_PATCH 1
#define WINVIEW_PATCH 1
#define XRDB_PATCH 1
#define ZOOMSWAP_PATCH 1
#define BSTACKHORIZ_LAYOUT 1
#define DECK_LAYOUT 1
#define GAPPLESSGRID_LAYOUT 1
#define TILE_LAYOUT 1
#define MONOCLE_LAYOUT 1

bakkeby added a commit that referenced this issue Jul 1, 2024
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.
@bakkeby
Copy link
Owner

bakkeby commented Jul 1, 2024

It is an interesting problem. I added some proposed changes, let me know if that works for you.

Happy to discuss if someone has better ideas for how to address systray icon window redraw issues.

@Ampnbsp
Copy link
Contributor Author

Ampnbsp commented Jul 2, 2024

I tried this fix, but it did not help. Background updates only when the icon updates (e.g. new unread message counter update in Telegram), but not with xrdb instantly.

@bakkeby
Copy link
Owner

bakkeby commented Jul 3, 2024

I tried with Telegram and I was not able to replicate. Maybe it depends on how it is installed and if it is packaged (for me telegram-desktop is installed as a straight binary, Arch AUR).

In any case the window manager does not have any direct control over the content of windows, so if the application does not redraw the systray icon following an Expose event then I am not sure if there is anything that can be done to force a redraw of the icon.

You should be able to test this by using the keybinding of MOD+b to hide the bar and once more to show the bar again. If the systray icon does not update then it is possible that the application does not react to Expose events for the systray icon. Worth checking with multiple systray applications to see if only one is affected or all of them.

There are two workarounds that I can think of:

  • use the alpha patch and a compositor; the systray should be fully transparent showing the bar beneath (you can still have a fully opaque bar of course) or
  • use a fixed colour scheme for the systray background that does not change with Xresources (for example the systray background is always fluorescent bright pink)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants