Add a 'quit' message that is app-wide, as opposed to mir_event_type_close_surface

Bug #1624407 reported by Olivier Tilloy
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mir
Triaged
Medium
Unassigned
mir (Ubuntu)
Triaged
Medium
Unassigned
qtmir (Ubuntu)
Confirmed
Medium
Unassigned
unity8 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Currently in unity8, when requesting to "Quit" a running application from the launcher, what happens is that qtmir goes through all its associated windows/surfaces, and closes them one by one. Supposedly, when the last window is closed, the application terminates itself (but this is not necessarily the case, see https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop).

This prevents application authors from doing proper cleanup before the app is closed. For example in Qt, the QCoreApplication::aboutToQuit() signal is emitted only after all windows have been closed, so the application doesn’t get a chance to e.g. save the list of open windows (real use case for multi-window browser application which saves the current session).

This is similar to unity7’s implementation by the way, but I think it’s wrong. Surely there must be a way (maybe toolkit-specific) to request an app to terminate itself (and fall back to closing all windows if not).

Tags: clientapi
Revision history for this message
Olivier Tilloy (osomon) wrote :

Just marked unity7 also affected, as its implementation is similar (it’s Bamf windows instead of Mir surfaces, but essentially it behaves the same).

summary: Closing an application doesn’t actually close it, it merely requests all
- its surfaces to be closed
+ its windows to be closed
Revision history for this message
Olivier Tilloy (osomon) wrote : Re: Closing an application doesn’t actually close it, it merely requests all its windows to be closed

And also marked unity8 affected, because the wording of the action in the context menu is confusing wrt the actual implementation: if we don’t change the actual implementation, we might want to rename "Quit" to "Close all windows".

Revision history for this message
Olivier Tilloy (osomon) wrote :

Windows appears to have a WM_QUIT message¹ that’s used to request quitting an application, and Qt handles it correctly in QEventDispatcherWin32::processEvents(). I guess we need something similar for Mir?

¹ https://msdn.microsoft.com/en-us/library/windows/desktop/ms632641(v=vs.85).aspx

Revision history for this message
Gerry Boland (gerboland) wrote :

AFAICS Mir has means to ask clients to close windows, but I don't see an API to ask the client itself to quit.

no longer affects: unity (Ubuntu)
Changed in qtmir (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

AFAIK Mir follows the same model as X11 (which has the WM_DELETE_WINDOW message but no WM_QUIT). I guess you could kill(pid, SIGTERM)?

Revision history for this message
Olivier Tilloy (osomon) wrote :

Given that, unlike X11, we have some control over Mir’s design and implementation, maybe this is something that we could consider adding? Or is that out of place?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

It is not out of place at all - just an enhancement request.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in unity8 (Ubuntu):
status: New → Confirmed
Changed in mir:
importance: Undecided → Medium
Changed in mir (Ubuntu):
importance: Undecided → Medium
summary: - Closing an application doesn’t actually close it, it merely requests all
- its windows to be closed
+ Add a 'quit' message that is app-wide, as opposed to
+ mir_event_type_close_surface
Changed in mir:
status: New → Triaged
Changed in mir (Ubuntu):
status: New → Triaged
tags: added: clientapi
Revision history for this message
Gerry Boland (gerboland) wrote :

Does Mir provide enough api to allow application ask user a question before shutdown? In Unity7, typically that is requesting focus and popping up a dialog - should be ok, but good to think about it.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Clicking on a window's close button sends the app mir_event_type_close_window. That's just an informational message that apps are meant to act on (e.g. pop up a dialog if not terminate themselves).

If you mean logout however, then I guess the right answer is that shells should send mir_event_type_{close_window,quit_app} to all apps on logout, and wait until the apps are no longer running (user responds to dialogs from apps with unsaved work or some timeout expires).

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Maybe a fix for bug 1674749 is what you want.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m not sure how a fix for bug #1674749 would address the use case in the description: a multi-window application (such as web browser) wants to distinguish between:

 - please close all windows one by one without retaining state for them

 - please quit the app, and save the state for all windows and tabs in them

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Generally speaking fixing bug 1674749 (now bug 1671424) should be enough for most apps in the short term.

I'm reminded of how Microsoft handles this problem...

WM_CLOSE: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632617(v=vs.85).aspx

WM_QUIT: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632641(v=vs.85).aspx
"The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure."

WM_POWERBROADCAST: https://msdn.microsoft.com/en-us/library/windows/desktop/aa373247(v=vs.85).aspx

WM_ENDSESSION: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376889(v=vs.85).aspx

Each has a valid use case, and I don't think we can get away from similarly wanting a 'quit' message in Mir eventually.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.