Comments (13)
I mean, if all of an application's windows are closed there isn't a whole lot you can sensibly do besides terminate the entire application and its children.
On Mac OS, it's long been common for applications to stay open after all windows close, because of the menu bar's persistence outside of any window's lifetime.
For example, in a simple word processor, where a window corresponds to an open document, a user may close all of their documents and then want later to create a new document or open an existing one. It's possible (even likely) they'd leave the application running with no open windows, then switch to it, probably using the Dock, and finally select the appropriate thing from the menu bar to open a new window.
from winit.
on Mac, closing a window (or pressing cmd+W is pretty ubiquitously interpreted as "hide the program but do not end the process". cmd+Q on the other hand usually means "please end the process". programs often ask if you want to save, etc., in response to cmd+Q.
imo, the tricky thing here is that the behavior (in response to closing the window, or Alt+F4) is kind of mixed on Windows and Linux. some programs end their process and others simply hide. however, it seems like the "default" behavior on the Windows and Linux side is to exit completely.
i'm not sure what all this currently looks like in winit, but i agree with francesca. a separate QuitRequested value should be defined. i think any solution that can support all of the above behaviors should be fine.
from winit.
@ryanisaacg I mean, if all of an application's windows are closed there isn't a whole lot you can sensibly do besides terminate the entire application and its children.
from winit.
Just tested the window example on OS X 10.10.5 and can confirm CMD
+Q
does not quit (or print any special events). Not sure if that's still something we'd want to handle in winit - I imagine we did, we'd at least still want some way to handle the request to close the window.
from winit.
Can confirm that this is still the case; CMD
+ Q
on Mac doesn't quit or close the window.
One can easily add it oneself though by checking VirtualKeyCode::Q
and modifiers.logo
, which is what I've done.
But would be nice if it was automatic in Winit and generate WindowEvent::Closed
, but no big deal.
from winit.
With the new CloseRequested
behavior, implementing this would be (functionally) pretty innocuous, though I don't believe it's a good precedent to set.
from winit.
I've been using winit (through glutin) and I was wondering if it would be appreciated if I tried to add this behavior (personally it feels inconsistent that I can request a close through Alt+F4
on Windows but not through CMD+W
or CMD+Q
on Mac)
from winit.
I suppose that there's not any case where Cmd+Q shouldn't trigger CloseRequested
, since it's not like winit's goal is to support making horribly non-compliant applications. So, if you want it, then feel free to add it, and I'll merge it.
from winit.
Actually, Cmd+Q shouldn't send CloseRequested
, but a new top-level QuitRequested
variant or something, shouldn't it?
from winit.
I'm not too sure; I'm pretty new to the Mac world. That definitely sounds right though.
from winit.
QuitRequested
could also be useful for handling alacritty/alacritty#675
from winit.
Reviving this issue from the dead: FWIW, I'm against adding new events to Event
or WindowEvent
that only ever get implemented on a single platform, since it makes it unlikely that those events will actually get used downstream. Would it be reasonably compliant to have cmd+Q
send a CloseRequested
event to every window in the application?
from winit.
@Osspial CMD+Q should also kill any background processes for the application, but I'm not sure how in-scope for Winit that is. I think sending a close to all windows would come the closest to getting the "correct" behavior.
from winit.
Related Issues (20)
- Better ways of initializing an ApplicationHandler HOT 1
- Web: Add Force Touch support to Safari
- Chinese IME punctuation behaviour is reveresed on macOS
- iOS. High CPU usage when application does nothing. HOT 6
- WindowEvent::ReceivedCharacter(char) returns empty char when Ctrl is pressed HOT 2
- Exposing the existing `AndroidApp` in the public API
- Missing "key_binding" example HOT 1
- Pointer Event Overhaul HOT 9
- System Theme vs Window Theme HOT 3
- Consider using x11 crate (static linking) instead of x11-dl or provide a feature to use x11
- Extension to report "primary" pointer up/down events on Android? HOT 1
- Get physical size of a monitor/window in millimeters HOT 1
- Add support for xdg-toplevel-icon v1
- Cursor icon doesn't follow system cursor theme HOT 5
- Scaling broke on Wayland (between version `0.28.7` and `0.29.15`): the window is twice the size it should be when the scaling factor is `2` HOT 1
- Opaque/On-Demand Data HOT 2
- X11_BACKEND.lock() fails
- Web: make use of `PointerEvent.persistentDeviceId`
- IME callback crashes application HOT 2
- Documentation doesn't explain how to create an ActiveEventLoop HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winit.