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

Improve transparency on macOS #7965

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

madsmtm
Copy link

@madsmtm madsmtm commented May 10, 2024

Extension upon #7928, see that for discussion. I've improved a bit on the window background, by setting the alpha channel to follow the window opacity.

When window.opacity < 1, we do two things:

  • Set the title bar as transparent (new).
  • Disable window border shadows (existing behaviour).

Copy link
Member

@chrisduerr chrisduerr left a comment

Choose a reason for hiding this comment

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

Missing changelog entry.

alacritty/src/display/window.rs Outdated Show resolved Hide resolved
alacritty/src/display/window.rs Outdated Show resolved Hide resolved
alacritty/src/display/window.rs Outdated Show resolved Hide resolved
alacritty/src/display/window.rs Outdated Show resolved Hide resolved
alacritty/src/display/window.rs Outdated Show resolved Hide resolved
alacritty/src/display/window.rs Outdated Show resolved Hide resolved
@sfsam
Copy link

sfsam commented May 10, 2024

I'm seeing the same thing I observed in the discussion of #7928: No borders and a white title bar even though decorations_theme_variant = "Dark" is set. I think this is due to something that was changed in the move to winit 0.3.0. I'm on MacOS Sonoma 14.4.1. FWIW, my window config:

[window]
decorations_theme_variant = "Dark"
decorations = "full"
option_as_alt = "OnlyLeft"
resize_increments = true
dimensions = { columns = 100, lines = 24 }

@nixpulvis
Copy link
Contributor

nixpulvis commented May 14, 2024

Set the title bar as transparent (new)

Seems to me this may be undesired. I hate to think we need yet another macOS specific configuration for it though.

Screenshot 2024-05-14 at 9 47 41 AM

@kchibisov
Copy link
Member

The end window opacity is not as it should be, it's just generally more opaque compared to what it was before or glitches.

Window has opaque title bar and real border when
config.window_opacity == 1.
We set the transparency explicitly using `Window::set_transparent`
further below, so this is no longer needed on macOS after:
rust-windowing/winit#3657
@madsmtm
Copy link
Author

madsmtm commented Jun 6, 2024

I've updated the PR and reverted some of the changes I probably mistakenly thought were for the better, though I'm too unsure of what the desired behaviour is (I don't like transparent windows myself, and don't use Alacritty).

The first two commits should bring Alacritty back in line with what it was pre winit 0.30.

Would be happy if someone else would take over for the rest.

@nixpulvis
Copy link
Contributor

nixpulvis commented Jun 10, 2024

I should be able to finish testing and implementing this PR, though my macOS API knowledge is limited and it may take me a little while to get around to everything. Right now it seems the main things that need changing are with respect to the titlebar and fixing whatever is causing #7969. At first I didn't notice that issue myself, but now transparency is broken for me as well.

I assume the best way to do this would be to make a new PR with the current state of this one and push to that myself as I make progress?

@chrisduerr
Copy link
Member

I assume the best way to do this would be to make a new PR with the current state of this one and push to that myself as I make progress?

Probably easiest this way, yes.

@nixpulvis
Copy link
Contributor

So after catching up on this issue, it seems like rust-windowing/winit#3722 fixes the main issue (#7969), so what's left is to figure out what we actually want, if anything.

I'm unsure that having a transparent titlebar is the right default because it can be achieved with window.decorations = "Transparent" (however, I still think that could use with some improvement so the content area doesn't overlap with the titlebar buttons, but that's an existing concern).

I also don't know if it's better to have drop shadows or not with a transparent background. My instinct would be to have them, but given that we don't have them already, I'm fine leaving it as is.

Looking back at #7928, it seems like everything there has been addressed.

Here's a screenshot of an alacritty window (opacity = 0.75) from master with winit pointing to rust-windowing/winit#3722:

Screenshot 2024-06-10 at 10 35 02 AM

and here's one without opacity set:

Screenshot 2024-06-10 at 10 40 00 AM

Yes the transparent window's titlebar is a less dark color, but I don't see the red bleeding into it like it appears to be in the original PR and I believe this behavior looks reasonable.

@madsmtm
Copy link
Author

madsmtm commented Jun 11, 2024

I'll note another option: Use -[NSWindow setAlphaValue:], this also sets the opacity of all the decorations (the border and the title bar) (in this mode, the application should internally render as-if it was opaque)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants