Conversation
We want to be notified when a window closes. For this to work we need to handle the destroy() method in WinHandler. After making this change, we ended up with two code paths for closing windows: one for when we were closing the window ourselves (for instance, when manually handling a menu command) and a second for when we were closed by the system, such as when the user clicked on the window's 'close' button. (all examples macOS). This unifies these two cases; when we want to close a window we call the WindowHandle's close method, which begins the platform close routine; as part of this we are called back (at destroy()) and then we have a single place to handle cleaning up state and posting the appropriate events.
|
I'm just starting my journey to understand druid internals, but I think the Windows platform code already triggers the destroying message. I've been looking for window closing related functionality in druid but as best as I can make out, significant parts of it are not implemented yet. Standardizing on one single place to handle cleanup is definitely a good step forward. I have some additional thoughts here but my knowledge is mostly Windows based and I may be lacking understanding of druid given that I just started learning it. Also I don't want to balloon the scope of this PR any more than necessary, but for now this seems like an on-topic place to comment. Exiting the
|
|
The reason a bunch of this stuff hasn't been implemented is because there are significant differences in expected behaviour on different platforms. on windows, yes, we should terminate the application when the last window closes. We could implement this today, specifically for windows, with little trouble. on mac, an application is not terminated by closing its windows; it can still be interacted with the menubar or the dock icon (and various other ways). Making this work correctly is what motivates #114. I'm not sure about other platforms, e.g. GTK. I agree that we want some sort of |
|
self approving this, would like to clear up the queue |
We want to be notified when a window closes. For this to work we need
to handle the destroy() method in WinHandler.
After making this change, we ended up with two code paths for closing
windows: one for when we were closing the window ourselves (for
instance, when manually handling a menu command) and a second for when
we were closed by the system, such as when the user clicked on the
window's 'close' button. (all examples macOS).
This unifies these two cases; when we want to close a window we
call the WindowHandle's close method, which begins the platform
close routine; as part of this we are called back (at destroy())
and then we have a single place to handle cleaning up state
and posting the appropriate events.
this was motivated by runebender stuff; I only want a glyph open in a single window at once, which means i need to accurately know when a window has closed.
This will likely require work on win and gtk; I'm not sure if either of those platforms is correctly posting
destroy().