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

Systray composition support #3664

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xinhaoyuan
Copy link
Contributor

@xinhaoyuan xinhaoyuan commented Jul 22, 2022

This allows systray to be rendered consistently in the widget hierarchy with proper shape and transparency.

The default appearance should stay the same, while the newly introduced beautiful.systray_skip_bg allows skipping the boring systray background.

awesomeConfig.cmake Show resolved Hide resolved
@xinhaoyuan xinhaoyuan force-pushed the pr-systray-composite branch 2 times, most recently from d931a17 to d3c857a Compare July 22, 2022 22:19
systray.c Show resolved Hide resolved
@xinhaoyuan xinhaoyuan force-pushed the pr-systray-composite branch 2 times, most recently from 79b18a9 to 554a19d Compare July 22, 2022 22:42
@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Attention: Patch coverage is 70.94595% with 43 lines in your changes are missing coverage. Please review.

Project coverage is 91.18%. Comparing base (b7bac1d) to head (7464c8e).
Report is 266 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3664      +/-   ##
==========================================
+ Coverage   90.65%   91.18%   +0.53%     
==========================================
  Files         854      927      +73     
  Lines       54774    59629    +4855     
==========================================
+ Hits        49653    54372    +4719     
- Misses       5121     5257     +136     
Flag Coverage Δ
gcov 91.18% <70.94%> (+0.53%) ⬆️
luacov 93.88% <96.36%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
awesome.c 81.37% <100.00%> (+0.57%) ⬆️
common/xembed.h 27.27% <ø> (ø)
event.c 79.21% <100.00%> (+0.33%) ⬆️
globalconf.h 100.00% <ø> (ø)
lib/wibox/widget/systray.lua 92.43% <100.00%> (+1.00%) ⬆️
luaa.c 74.93% <ø> (ø)
objects/drawin.c 88.04% <100.00%> (+0.08%) ⬆️
spec/wibox/widget/systray_spec.lua 100.00% <100.00%> (ø)
tests/test-systray.lua 97.77% <95.00%> (-2.23%) ⬇️
systray.c 88.00% <78.37%> (-3.13%) ⬇️
... and 1 more

... and 248 files with indirect coverage changes

Copy link
Member

@psychon psychon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically 👍 but I do not understand where this "mess with the background pixel of tray windows" comes from. I do not think any spec allows this. Is there some program out there that required this specifically?

awesome.c Outdated Show resolved Hide resolved
awesome.c Outdated Show resolved Hide resolved
objects/drawin.c Show resolved Hide resolved
systray.c Outdated Show resolved Hide resolved
/* warn("Fixing the background of the systray window 0x%x possibly because the client does not support composition.", embed_win); */
xcb_change_window_attributes(globalconf.connection, embed_win, XCB_CW_BACK_PIXEL,
(const uint32_t []){ globalconf.systray.background_pixel });
xcb_clear_area(globalconf.connection, 1, embed_win, 0, 0, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, what? I do not understand the reason behind this whole code block. If some window has a different depth.... so be it. I do not see anything in https://specifications.freedesktop.org/systemtray-spec/systemtray-spec-0.3.html or https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html allowing to do this. Do other tray compositing managers do this?

(Basically same comment below to the code that handles changes to globalconf.systray.background_pixel)

Oh also: This might warrant a comment in the code. It just occurred to me that:

  • legacy systray clients use a ParentRelative backgroud
  • reparenting such a window into a window with a different depth does not work
  • thus, this is here to "make things work"

(But what about all the other window properties that are needed for a different depth window? According to https://stackoverflow.com/questions/3645632/how-to-create-a-window-with-a-bit-depth-of-32, one also needs to set a colormap and a border pixel/border pixmap. Why doesn't this code need that?)

systray.c Show resolved Hide resolved
XCB_ATOM_VISUALID, 0, 1),
NULL);
tray_visual_id = screen->root_visual;
if(xcb_get_property_value_length(tray_visual_r)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(tray_visual_r != NULL && xcb_get_property_value_length(tray_visual_r)) {

In theory, this also needs to check for a 32 bit value and length > 0... but, whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

tests/test-systray.lua Show resolved Hide resolved
@psychon
Copy link
Member

psychon commented Sep 18, 2022

Ah, right after pressing "submit", I find it: https://specifications.freedesktop.org/systemtray-spec/systemtray-spec-0.3.html#visuals

If convenient, the tray manager may set an appropriate background pixmap on the embedder window to provide the appearance of transparency. However, the preferred method of transparency is to use a visual with an alpha channel in _NET_SYSTEM_TRAY_VISUAL.

Okay. (I do not think there is much of a difference between background pixmap and background pixel, so, whatever.)

@xinhaoyuan xinhaoyuan force-pushed the pr-systray-composite branch 2 times, most recently from d765c49 to 7ed7b91 Compare September 24, 2022 04:53
psychon
psychon previously approved these changes Sep 24, 2022
Copy link
Member

@psychon psychon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

awesome.c Show resolved Hide resolved
…s without it. Add a beautiful.systray_skip_bg to skip background drawing, so it can blend nicely with other widgets.
@actionless
Copy link
Member

actionless commented Oct 4, 2022

oh wow, wasn't expecting someone to actually pick that, many thanks 🔥

? get_color(conn, cm, 0xffff, 0x9999, 0x0000)
: XCB_BACK_PIXMAP_PARENT_RELATIVE,
screen->black_pixel, cm
});
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, window, _XEMBED_INFO, _XEMBED_INFO, 32, 2, (uint32_t[]) { 0, 1 });

// Make our window a systray icon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess the comment itself should move together with the corresponding line

@actionless
Copy link
Member

restarting to unstuck the CI

@actionless actionless closed this Mar 24, 2024
@actionless actionless reopened this Mar 24, 2024
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

Successfully merging this pull request may close these issues.

None yet

5 participants