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

Fix transparency on macOS #260

Merged
merged 2 commits into from
Sep 29, 2023
Merged

Fix transparency on macOS #260

merged 2 commits into from
Sep 29, 2023

Conversation

wusyong
Copy link
Member

@wusyong wusyong commented Sep 19, 2023

Unlike other platforms, macOS adds another opaque layer on CALayer.
This makes the window opaque even if winit window is set to transparent.

Edit: needs #261 to fix CI.

Unlike other platforms, macOS add another opaque layer on CALayer.
This makes the window opaque even if winit window is set to transparent.
@jdm
Copy link
Member

jdm commented Sep 19, 2023

I wonder if we should add a field to NativeWidget that makes these calls configurable? The docs at https://developer.apple.com/documentation/quartzcore/calayer/1410763-opaque suggest that this could have performance implications for the system compositor.

@wusyong
Copy link
Member Author

wusyong commented Sep 19, 2023

Sure, I can look into adding a method to toggle it. But it'll probably only matter to macOS just like how glutin works.
glutin's x11/wayland/Windows transparency is more on winit's config.
I'm on vacation soon. I'll resume the work once I get back next week.

@wusyong
Copy link
Member Author

wusyong commented Sep 29, 2023

Sorry for the late update. My laptop was broken after vacation and took me a few days to fix.
I added an opaque field to the NativeWidget. It's determined by NSWindow's opaque property.
So if the raw window hand or winit window sets the transparency, it will make the layer transparent as well.
Otherwise, normal usage is still the same.

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

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

Nice!

@jdm jdm added this pull request to the merge queue Sep 29, 2023
Merged via the queue into servo:master with commit a90f783 Sep 29, 2023
24 checks passed
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.

2 participants