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
MacOS handles window opacity better #7928
Conversation
Window has opaque title bar and real border when config.window_opacity == 1.
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 you're looking for this functionality, it should be added to Winit.
IIRC we rejected such thing upstream because it was too specific and you can do it very easy downstream. it's also a bit opinionated since you can change the color pretty much arbitrary, so you need to define coloring APIs, etc. Maybe in the future it'll be a bit easier to manipulate things like that because the macOS stuff will be exposed directly, but for now I don't mind such change. Though, I'm not sure whether it's how the rest of the apps behave by default, since macOS tends to blend background color into decorations and what not. |
Is it not a standard thing to have transparent for transparent windows? I don't know how it actually works. If there's no such standard then I'd prefer just always keeping Alacritty's decorations opaque. |
FWIW, I didn't intend for this PR to be opinionated. It is applying MacOS's MacOS Here are some apps on a black background with Dark Mode on to illustrate how the windows are drawn: |
You can set arbitrary color for decorations. If winit will do so it could conflict with users doing so as well, since you can set a color with alpha iirc. Maybe winit should do that by default, but it's hard to understand what the default is... We could add it here and then try to upstream in a sane way, but I know that e.g. neovide uses this in a different manner with a custom color, etc... |
I might be misreading the effect of this PR, but it seems to be mostly setting things to a reasonable default for when there’s no transparency or custom colors desired. Seems like a great addition to winit without all that much macOS bullshit. Why would other applications like Alacritty not want this is the way I’d think about it. Just my two cents. |
The point is that other applications sometimes change this color on their own, so winit can't do that implicitly by default, it must be explicit, and making it explicit is a bit cumbersome because defining colors, etc sounds a bit out of place for winit. We could re-iterate it upstream, ofc, but I'm not sure in the current state things will be added upstream. |
I think the missing border is due to a call to Regarding transparency, maybe the problem is rather that Winit sets the background color to And then users can opt-in to a transparent window title bar using some other method, either the manual approach here, or using some API we provide in Winit? |
we call |
If you create a new Mac app in Xcode, it will automatically create an |
I've opened rust-windowing/winit#3657 to correct the behaviour in Winit - after that, the default background color is always The rejected PR for setting the background color is rust-windowing/winit#2314, btw. Still not that against it. |
Is this patch still needed after this #7935 ? |
After #7935, Alacritty still doesn't draw window borders. What's more, it also doesn't respect the config option I tried applying this PR to #7935, but it has a conflict: |
IDK, it seems to still be drawing a dark title bar, but no border as desired. I didn't follow the PRs in winit, so I'm not sure what I expect at the moment, but I think agree with the intentions of this PR at least. |
It should draw border though. |
@kchibisov seems like this PR is still functional. In fact it seems to improve the performance of the app switcher (Expose) since the window is now longer partially transparent. This was an outstanding issue for a while and may actually be a partial fix for #4474. |
@kchibisov leave me a day to recollect myself, I may have tested this wrong. Now when I compile |
In general, I'll re-look into this myself. Though, I'm limited to macOS 12.6 iirc. |
After
alacritty's transparency seems to be broken. |
I can confirm this, I noticed a few days ago, I don't see any issue in winit, not sure how to know whether this is an alacritty or winit issue. |
I've posted #7965 which extends upon this one with a few further fixes. |
Closing in favor of #7965. |
On MacOS, when the window is configured to be opaque, draw an opaque title bar and proper window border.
This is achieved by giving the window the standard background color when it is opaque.
The image below shows the current translucent drawing for an opaque window versus this pull request's opaque drawing.