-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add transparency support #96
Conversation
This fixes #71. |
Very nice! Did you test this on which platform? X11 might need RGBA bits set on window creation. Wayland i think would work without any changes. |
Just fixed up clearing the cairo surface, missed pushing that up. I've only tested on wayland, I can take a look at X tomorrow morning. |
If you are willing to do X support as well. I'll wait until that before merging this. Looks good. |
Also note that X11 most likely won't work without a compositor. Fake transparency could be done for non compositor support. But that could as very well be another feature, another pr. |
if (sscanf(nhex,"#%2x%2x%2x", &r, &b, &g) != 3) | ||
unsigned int r, g, b, a = 255; | ||
int matched = sscanf(nhex, "#%2x%2x%2x%2x", &r, &b, &g, &a); | ||
if (matched != 3 && matched != 4) |
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.
if (matched != 3 && matched != 4) | |
if (matched < 3) |
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.
That would make it accept color codes with more than 4 components, so not sure if that's good idea 🤔
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'm fine with either way, but only checking < 3 will allow extra characters to slip by.
I have no experience with Xlib, so if you'd rather handle that I will defer to you. But I'm also willing to learn a bit. :) |
https://gist.github.com/je-so/903479/834dfd78705b16ec5f7bbd10925980ace4049e17#file-testprogram-c-L53-L55 |
I think if you are testing in XWayland, that should already be composed (by the wayland composer), so RGBA should work fine there. |
I've pushed what I believe to be the correct solution. However, I'm unable to test properly because even current master refuses to start for me in Xwayland with I was able to test that it still runs correctly under native X, but I don't have an X compositor installed to see if it really becomes transparent. |
Compton is something you could use to test the X11 side quickly. https://github.com/chjj/compton |
Now developed in this fork: https://github.com/yshui/picom |
Tested it! Seems to work. |
if I do |
Also, the transparency seems to work even without a compositor. I guess either cairo or x11 does the fake transparency for you. |
Hmm, I thought this was fixed in ffd773f. Maybe cairo behaves differently when using the X backend? |
I'm not sure that dc33df1 fixes the redrawing issue on X, but it makes more sense to use CAIRO_OPERATOR_CLEAR to clear either way. :) |
The good news is I got transparency to work in X, not sure what I was doing wrong before. The bad news is that I've been bashing my head against |
Why do you need to edit |
Ah, I just tested your new code. I see the issue now. Lemme send you a patch that should fix it in a moment. |
This should do it. It will only work with compositor. Doing pseudo-transparency would involve using XCopyArea or other tricks. But that would be separate thing. |
Note with latest diff. Not sure if the clearing and such is needed in cairo render, but maybe they are still for wayland? |
(Sorry, have been busy with other things. Will get back to this soon!) |
Alright! With your patch and picom running, looks good on X. I think this is ready to go. Do you want me to squash things into a nicer set of commits, or will you handle that when merging? |
Lets see how github's "squash and merge" works |
Merged, thank you! |
Thanks for your help! |
This was a much smaller diff than anticipated! Colors are now accepted with or without a fourth pair of hex values for alpha. Without alpha specified, it defaults to FF as you would expect.