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

MacOS: non-activating window #3894

Open
MatthiasGrandl opened this issue Aug 31, 2024 · 5 comments
Open

MacOS: non-activating window #3894

MatthiasGrandl opened this issue Aug 31, 2024 · 5 comments
Labels
DS - macos S - enhancement Wouldn't this be the coolest?

Comments

@MatthiasGrandl
Copy link

MatthiasGrandl commented Aug 31, 2024

Description

I am currently evaluating porting Loungy from GPUI to Iced and I noticed I can't replicate the window behavior I need in Winit. The important bit is this from GPUI codebase:

https://github.com/zed-industries/zed/blob/a850731b0ed61b0ef2a0173843b6daedf45327e8/crates/gpui/src/platform/mac/window.rs#L56

This basically prevents the Window from ever "activating", which is required to get a nicely behaving launcher window on MacOS. I realize this is very niche usecase, but it would be nice to have it supported on Winit.

Relevant platforms

MacOS

@MatthiasGrandl MatthiasGrandl added the S - enhancement Wouldn't this be the coolest? label Aug 31, 2024
@MatthiasGrandl
Copy link
Author

Disregard. I tried patching winit and it’s more complicated than that. this styleMask requires the use of NSPanel instead of NSWindow and then it’s still not quite behaving the way I want it to.

@madsmtm
Copy link
Member

madsmtm commented Aug 31, 2024

If all you end up needing is the ability to set a specific style mask, then I'd be fine with accepting a PR for that - if the solution is to use NSPanel, then I'm a bit more wary, but that could also be doable with a platform-specific window attribute.

@MatthiasGrandl
Copy link
Author

I got it to work the way I expect it to work, but there are multiple changes necessary. The one that took me the longest to find, was the focus_window function in window_delegate. It basically overrides the NSWindowStyleMask::NonactivatingPanel behavior. And yes sadly the styleMask is only supported on a NSPanel.

I'll try to cleanup my changes and open a PR, but given how niche this is, I am not sure it has a good chance of getting merged :(

@MatthiasGrandl
Copy link
Author

@madsmtm given the class based approach of WinitWindow being based on NSWindow, do you have any idea what the least intrusive way of conditionally flipping to NSPanel? In my MVP I just switched NSWindow to NSPanel altogether, but that obviously is not an acceptable solution.

@madsmtm
Copy link
Member

madsmtm commented Sep 1, 2024

Well, we don't really use WinitWindow for anything other than canBecomeMainWindow and canBecomeKeyWindow, and the use of those are IMO questionable anyhow.

So I think you could change occurrences of WinitWindow with NSWindow, and then inside new_window use Retained::into_super to convert Retained<WinitWindow> (or if the option has been specified to create NSPanel, Retained<NSPanel>) to Retained<NSWindow>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - macos S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

2 participants