-
Notifications
You must be signed in to change notification settings - Fork 920
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
feat: WIP Custom menu builder #1921
Conversation
Yes, let’s make this happen. |
I understand that this was asked for in #1583, but an API like this runs counter to Winit's current stated scope. From FEATURES.md:
I wasn't there when this decision was made, but I'd like to see a strong argument as to why this must be implemented inside Winit, rather than having it live in a separate crate. From what I can tell (and have been told), the way Winit currently forwards events, plus the way the native macOS APIs work, should enable anyone to add their own native macOS menus without modifying Winit. Additionally, this touches the cross-platform API, so what other platforms can do must be taken into consideration. AFAIK, Linux (X11 & Wayland, really) has no real notion of native menus, and there are two major GUI libraries which are generally used to provide a "native" look and feel: GTK and QT. If we tried supporting this on Linux, then we'd probably have to link against GTK and QT dynamically, and that doesn't even get into how these frameworks tend to want to control the windows themselves. cc @casperstorm @LoganDark @madsmtm (you guys seem like you know a thing or two about macOS) |
I agree fully with @maroider - though I know this is a very desired feature (!), it is a hard problem to tackle, and not one I think is appropriate for Also, a proper menu library would not only handle the menu bar, but also context menus and the dock menu. See also a previous issue on this, #427, which was closed due to being "out of scope". (Background: I'm privately slowly working on a separate crate for exactly this, hence the reason I made |
What's the reasoning for why this is a bad idea? That Linux doesn't support it? Who wrote the FEATURES.md file by the way? I think that this is a feature that a non-trivial percentage of the users are expecting. Putting it in a separate crate will cause fragmentation and like reimplementing the same things over and over. I think it makes sense to do it in winit considering for example how on macOS, you have to do some black magic to get the macOS menu working on the first start (#1918). The feature is small enough that I think it has a place in winit. @madsmtm what about this feature is hard? Druid-shell has this menus. Context menus are something else entirely. Those are not a part of the windowing per se. |
Hey guys! We had a test PR in wry our window management library built on top of winit for tauri. Since this PR prevents us to register a menu correctly as your menu is always registered after. Didn't want to make a tweak to cover it. I thought it'll be great to make it for the whole project instead of trying to tweak all windows inside our app. Also, your menu didn't cover basic functions like copy paste etc... also, it can't be disabled. It's why I thought a Windows / macOS version would be great. Otherwise, we need to make a lot of tweaks, etc... and I think it would personally be beneficial for the whole community. I personally think this is a major issue that should be addressed. I'm open to any discussion and would really love to see the project moving forward but personally, I'm really scared... Anyways..... not here to fight if it's good or not. |
It's because the Winit project has a (somewhat) well-defined scope. Winit tries to avoid adding features which can be implemented outside of Winit, and the consensus seems to be that native menus is one such feature.
Mostly the Winit maintainers at the time it was written, it seems. See #695.
I'm fine with that. I'd also be fine with there being such a crate under the
Winit isn't druid-shell. druid-shell exists in part because Raph Levien didn't believe that the approach Winit is taking would suit the Druid project. druid-shell doesn't try to be Winit either (to my knowledge). |
I'm sorry if I came across as aggressive, definitely not my intention! I was simply just trying to weigh in with my opinion 😁. The relevant part of The primary reasoning, I think, is that it can be done outside True, we did have to do some black magic to get menus to work, but that was clearly a bug in Thanks for the background information, always helps! I did raise the concern that the menu couldn't be disabled, see #1583 (review), so if that's a real issue multiple people are having we could add a switch for it in Sorry that you're scared, Open Source shouldn't be that! We'll talk about it as humans 😉 |
Welp, I was going to write more, but @madsmtm just about covered what I wanted to cover. Anyway, @lemarier, I didn't come with the intention to be some scary person blocking progress, and I'm sorry if I made you feel that way. Getting involved with Winit for the first time was a daunting experience for me, so I can imagine that it is discouraging to have your first PR against the repo be criticized (not quite sure it this is the right word). |
I'll close the PR as it's out of scope for winit. |
First of all, good job @lemarier. I think it's a tough decision of what fits into
And I agree @maroider suggestion. I think this would fit well:
@madsmtm , Regarding:
IMHO we should be able to disable it when we have an alternative way of adding a menu, eg. with a separate crate or similar. |
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to users