swaywm / swaybg

Wallpaper tool for Wayland compositors
MIT License
490 stars 31 forks source link

Only submit XRGB buffers #53

Open mstoeckl opened 1 year ago

mstoeckl commented 1 year ago

These two commits resolve https://github.com/swaywm/swaybg/issues/26, by always submitting opaque buffers. This is done by painting the buffers submitted with a uniform color, before drawing the image on top. The default color is chosen to match Sway's default background color, so that most people invoking swaybg under Sway with a semi-transparent (or badly sized fit or center mode image) will see the same result as before.

I've been undecided about this change for a while, since there is an alternative which preserves the current behavior; to detect when the output image may be semi-transparent, as a function of the scaling mode, the image size, the presence of the --color flag, and whether the image has an alpha channel. However, I don't think allowing transparency in edge cases is a good behavior for a wallpaper program to have, and solving #26 while keeping the current behavior makes the buffer creation logic more complicated, making changes like submitting 10-bit buffers -- for which Cairo only supports the opaque RGB30 format -- harder to implement.

mstoeckl commented 4 months ago

I've rebased this to a) fix a merge conflict b) update the first commit to ensure that single-pixel-buffers are always opaque. I don't think any other changes made over the last two years would affect this code, but just to be sure this should probably be re-reviewed.