-
Notifications
You must be signed in to change notification settings - Fork 879
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 option to blur background on macOS #1667
base: master
Are you sure you want to change the base?
Conversation
Can this be triggered during runtime? I think like it could be done? Limiting it to be enabled only on startup seems a bit lacking for what its worth.
That's true, I'll ask if there's something not widely supported but still a known way to do things. on X11 there's no way to do it either, it just some compositors are doing it somehow(some of them just detect transparent background, some rely on properly being set on a window). You can do something for KDE, I guess, inside of winit, but that's it(not sure about GNOME here, maybe there's a way). Also, can you control the blur effect or it's just a generic blur? If so it'll be nice to provide some control over that to the users. |
Yes, I suppose this could be done at runtime, you can disable the blur by setting the state property. By the way, please don't merge this, the view doesn't resize with the window yet. |
I have no intent in merging non trivial code on a platforms I can't test, don't worry. But you should open as draft or mark as [WIP] in a title when you open things that you don't want being merged (you've updated that already, but saying for the future). Also, I'd like to wait for other backends maintainers to chime in and tell how the blur is working on their platforms ( I personally have no idea how it could work on Windows). cc @Osspial for blur on Windows. |
As for the Wayland, there's a https://github.com/KDE/kwayland/blob/master/src/client/protocols/blur.xml, which should be pretty straightforward to implement inside of winit( I can submit impl). In general it works in a way that you can request to blur some parts of the window, so if other platforms have such concept we may accept an array of rects (PhysicalPosition, PhysicalSize things) to set blur. |
Oh, and you may actually be interested in how the previous effort was going #568 , it had macOS bits working at least. |
Thanks for the tip 😉. The resizing works now. |
The thing is that transparency option doesn't mean that you will or won't have it, and users may draw with alpha 1, so the window will be opaque, however they'll be able to go for opacity only for certain regions, and for those regions they may want to have blur. Requesting blur without ever making blurring the window(user just doesn't trigger a state, where something transparent will be shown) seems strange, and the system may interpret it in a weird way. |
Not sure about that one, but I guess on macOS everyone is blurring even unfocused windows, so that could make a bit more sense? |
No, Finder for example only blurs when in focus. But I guess every app is handling that differently… |
Hm, fair enough. That part of when to blur seems macOS specific and could be passed a special window creation attribute for macOS, what do you think? |
Sure, that sounds fine. |
Yeah, it'll be nice to have such control exposed. However I'd like to see how platforms like Windows are working here, I'd assume that they use something very similar, but I can't say anything about it, since I'm not using it. |
Related to #538
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to usersThis PR adds
with_blurred_background
toWindowBuilderExtMacOS
which makes the view semi-transparent and blurs the background of the window using aNSVisualEffectView
.I think this feature could conflict with other cross-platform implementations, but as there is no standard for blurred backgrounds on Wayland or the web, these features would need to be platform-gated anyway.