-
-
Notifications
You must be signed in to change notification settings - Fork 593
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
fix binding the root background pixmap in case of depth mismatch #984
fix binding the root background pixmap in case of depth mismatch #984
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## next #984 /- ##
==========================================
Coverage 36.46% 36.57% 0.10%
==========================================
Files 50 50
Lines 11523 11533 10
==========================================
Hits 4202 4218 16
Misses 7321 7315 -6
|
src/picom.c
Outdated
ps->root_image = ps->backend_data->ops->bind_pixmap( | ||
ps->backend_data, pixmap, x_get_visual_info(ps->c, ps->vis), false); | ||
ps->backend_data, pixmap, | ||
x_get_visual_info(ps->c, x_get_visual_for_depth(ps->c, r->depth)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i had to do some research to figure out why we couldn't do the same as win_bind_pixmap
and use the pixmap's visual directly.
turns out the visual is part of the window's attributes, and GetWindowAttributes doesn't work with a pixmap. can you add a comment to record this fact? thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've tried to add a descriptive comment of what we are doing and why.
In
|
I can confirm ChangeWindowAttributes has this check as well. how is xfdesktop even able to set the background pixmap to a pixmap with a different depth? |
xfce tricks ;) i think that the root pixmap atom could point to any pixmap, not only the one that is associated with the root window (if i understand how it all works correctly). when setting background with
i wonder what other des do to set the desktop background. i suspect it may be a common practice, except that they're setting visuals matching display's screen.
|
Ah I suppose it sets that's evil :'( |
i believe that |
07f9516
to
64683b7
Compare
makes sense.
|
i thought that we could compare the root back pixmap's depth and the root depth and use the root visual if they match. but imho it adds complexity to the code and i doubt that we're winning anything because |
64683b7
to
c2cc510
Compare
c2cc510
to
ee80fc8
Compare
thanks. there is one more thing i am worried about. a visual with the matching depth is not necessarily the right visual. e.g. 32-bit depth can be ARGB8, or RGB10A2. is there no chance of fixing this on xfdesktop's side? obviously there is no standard/specification to say who is actually correct here, but i can't think of a non-hacky way of fixing this on our side. |
that's a good point. but if the
we could try to report this behavior upstream but you've reminded me about a funny xfdesktop's option when setting a background called transparent. if you set a 1920x1080 wallpaper with this option it will be set just fine but if you then set a, say, 640x480 wallpaper, it will overlap the previous one. i believe it's transparent to the root window, so you can set a wallpaper with
in the end, this fix reduces the chance of a root back pixmap binding failure. if you really want to eliminate it you may ping-pong a visual between |
I don't want to rely on this assumption.
I think this is irrelevant. What they put in
There's no way for picom to know. The pixmap might bind successfully but will look wrong. (like if you bind a ARGB8 pixmap with a RGB10A2 visual) |
ikr, you can never trust the x.org.
unfortunately, looks like it's not only xfce. talking about the "contract": is
there is a way. we won't rely on the pixmap binding failure as a search criteria for the right visual. instead we could
that's what i've meant with
|
there are more 😱 ?!
unfortunately no.
no this isn't reliable either. when the pixmap is detached from the root window, we can't assume anything. the component size can be different too. |
ee80fc8
to
1f12f87
Compare
1f12f87
to
faa92d9
Compare
it returns the first found visual for the given depth
faa92d9
to
18cb511
Compare
rebased on top of the latest commit in the next branch and refactored. x: add the x_get_visual_for_depth functionit returns the first found visual for the given depth picom: fix binding the root background pixmap in case of depth mismatchif the root background pixmap's depth doesn't match the root window's render: fix binding the root background pixmap in case of depth mismatchfix the same issue in the legacy backends, see the previous commit for |
if the root background pixmap's depth doesn't match the root window's depth, find a suitable visual for the root background pixmap's depth and use it instead of the root window's visual
fix the same issue in the legacy backends, see the previous commit for details. this commit also removes the x_validate_pixmap function because it was used only in the get_root_tile function and the fix pretty much implies and embeds it.
18cb511
to
4a79e7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
previously we were using atoms set by other utilities to obtain the root back pixmap and the root's visual for it. however, their depths may mismatch. in this case picom will fail to bind the root back pixmap what causes errors, warnings and weird behavior on all backends:
now we're using the root back pixmap's depth to obtain a suitable visual for it.
i've tested
feh
,hsetroot
andnitrogen
and they're all setting the right depth for the root back pixmap. however, at leastxfdesktop
(a part of the xfce desktop environment) always sets root back pixmap's depth to 32, when common root's depth is 24.we could report this behavior upstream, but:
xfdesktop
is completely wrong;xfdesktop
is the only one who does this;if you think that this approach is wrong and there is a better way to workaround this, feel free to close this pull request. otherwise, feel free to request changes, i'll see what i can do.
related xfdesktop's code: https://github.com/xfce-mirror/xfdesktop/blob/f196763ba04211c7a3b21edba37c3b8f56b25516/src/xfce-desktop.c#L372-L374
related polybar's issue: polybar/polybar#2798
p.s. this pull request doesn't include a fix for legacy backends. it's an easy and pretty much the same fix for the legacy xrender backend, but legacy glx backend makes me doubt that fixing this worths the effort. if you want a fix for the legacy xrender backend included, hmu.