Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

Transparency not working for transparent --button #140

Closed Tomas-M closed 2 years ago

Tomas-M commented 2 years ago

I'm not sure if this affects all use cases. When I specify --button with a transparent PNG image at the same time as --backgroundcolor 000000 for example, while having a background image on my desktop (root window), xlunch starts at black screen (due to the background 000000, this is correct), but the transparent button has original desktop image as its background. App icons are drawn properly even if transparent, so only buttons have this problem. I have to look into this but I am not sure if I am able to find a solution to fix it, so @PMunch please if you have some time, you can as well look into it, thank you very much :)

PMunch commented 2 years ago

They do indeed seem to treat alpha differently. Should be an easy matter of copying the code from the icon rendering part over into the button rendering part. Or maybe it's a good idea to split this into it's own draw_image function to avoid this kind of difference.

Tomas-M commented 2 years ago

This patch seems to be causing the problem: https://github.com/Tomas-M/xlunch/commit/0511c6540a978e2100a0609f6d86aa269f863943

If I revert it, everything seems working fine. Using xlunch version 4.7.1 I have no idea why I pushed this patch 3 years ago, it apparently fixed the same issue for me then, this is very strange why it needs to be removed now to fix.

@PMunch if you're interested in testing, would you please verify that buttons are not transparent in current xlunch version, and reverthing this patch fixes it?

Very strange

Tomas-M commented 2 years ago

Hm, seems like it's somehow related to the case when background is specified (works differently if user provides background file, and differently when root window is background aka transparency). I will give it some more time.

PMunch commented 2 years ago

I did some testing and I believe I understand what has happened. So if you set the background to #000000 with the current master, the image shows what's behind xlunch through the window. If the commit is removed then the image shows as transparent over the black background.

But if we set the background to #00000000 (ie. make the entire background transparent) the image now shows transparent over the background as before, but if the commit is removed it shows with a white border (which is the same as what the icons do.

What these settings seems to do is control how things are drawn over the window background. Currently buttons look better on a completely transparent background than the icons, since their transparency is handled correctly with regards to what is behind xlunch. This, I believe, is what you tried to fix with your patch initially. I believe the correct way to fix this is to draw everything in xlunch into a buffer with transparency, and then draw that buffer onto the window the same way buttons are currently drawn to it. This would compose the transparencies correctly in the first buffer (making buttons blend with the background of xlunch) but still make transparent elements render correctly over the background of the window. This would solve the current issue of icons not having proper transparency over the background of the window as well.

Tomas-M commented 2 years ago

I believe the correct way to fix this is to draw everything in xlunch into a buffer with transparency, and then draw that buffer onto the window the same way buttons are currently drawn to it

Yeah! :) I came to the same conclusion. The above mentioned patch should be reverted indeed, Yet I am unsure if I can fix this properly myself. Do you have some time for this or should I give it a shot? (bad idea most likely) :)))

PMunch commented 2 years ago

Had a poke at it and I think I found a good solution, see the linked PR.

Tomas-M commented 2 years ago

I tested it and it works very well, good job, thank you very much! :)