Bug 461176 - Applications don't prompt to save unsaved work when logging out on Wayland, causing data loss
Summary: Applications don't prompt to save unsaved work when logging out on Wayland, c...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Session Management (show other bugs)
Version: 5.26.2
Platform: Arch Linux Linux
: NOR critical
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: usability, wayland
: 467142 472573 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-10-29 22:30 UTC by John Brooks
Modified: 2023-11-26 19:27 UTC (History)
27 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Brooks 2022-10-29 22:30:38 UTC
SUMMARY
When logging out of a Wayland session, applications do not display prompts to save unsaved work before proceeding with logging out.


STEPS TO REPRODUCE
1. Log in to a Wayland session
2. Open Kate, type some stuff, do not save it
3. Log out of the Wayland session

OBSERVED RESULT
The session ends and unsaved work is discarded with no prompts to save it first

EXPECTED RESULT
Applications should be able to ask to save work before logging out under Wayland, like they do under X11.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
KDE Plasma Version: 5.26.2
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.6
Graphics platform: Wayland

ADDITIONAL INFORMATION
I have been told that this is due to Wayland not having an API to tell applications that the session is ending. I'm not sure what is done on X11, or if there are any relevant protocol proposals for Wayland to enable this.
Comment 1 Nate Graham 2022-11-03 15:48:24 UTC
Can reproduce. Marking as Critical as this can cause unexpected data loss, and adding it to https://community.kde.org/Plasma/Wayland_Showstoppers.
Comment 2 John Brooks 2022-11-03 18:14:59 UTC
Thank you, Nate. Does anyone have an idea for a path forward for this?
Comment 3 John Brooks 2022-12-14 18:31:04 UTC
I believe this is what is responsible for shutdown handling functionality in Xorg: https://www.x.org/releases/current/doc/libSM/SMlib.html

Something similar needs to be standardized for Xorg-less environments.
Comment 4 Ilya Fedin 2023-01-07 09:25:46 UTC
Implementing missing parts of the Inhibit portal in xdg-desktop-portal-kde may be of good help to this. It currently supports inhibiting, but not monitoring state of the session.
https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.impl.portal.Inhibit
https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/inhibit.cpp

And maybe getting a client implementation of the Inhibit portal in Qt
https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Inhibit
Comment 5 Vlad Zahorodnii 2023-03-10 08:52:36 UTC
*** Bug 467142 has been marked as a duplicate of this bug. ***
Comment 6 Nate Graham 2023-08-04 19:39:39 UTC
*** Bug 472573 has been marked as a duplicate of this bug. ***
Comment 7 David Redondo 2023-11-20 15:09:23 UTC
Git commit 4cdf27e74c392f4e416dc87cc4a5385ccac4566c by David Redondo.
Committed on 20/11/2023 at 15:56.
Pushed by davidre into branch 'master'.

Expose a method to allow closing windows on shutdown.

This allows Plasma to gracefully close windows on shutdown by sending
xdg_toplevel.close. If after 10 seconds windows are still open because
they prompt for unsaved changes or similar cases, a notification is
shown to either prompt or logout regardless.

M  +3    -0    src/org.kde.KWin.Session.xml
M  +83   -1    src/sm.cpp
M  +8    -1    src/sm.h

https://invent.kde.org/plasma/kwin/-/commit/4cdf27e74c392f4e416dc87cc4a5385ccac4566c
Comment 8 David Redondo 2023-11-20 15:23:24 UTC
Git commit 23cca93b879d0fcf9f430b03a482dbca1e0a1d79 by David Redondo.
Committed on 20/11/2023 at 16:10.
Pushed by davidre into branch 'master'.

shutdown: Introduce support for KWin closing wayland windows

After ksmserver is done, KWin will now close (or not) open wayland
windows. Since this operation can also cancel the logout, ksmserver
gains a new hook to reset its state. This also means that it cannot
quit itself anymore but needs to be managed by plasma-shutdown.
Using this opportunity the  path for shutdown can be aligned between
X11 and Wayland. In the systemd-managed case we stop graphical-session.target,
otherwise plasma-shutdown quits KWin and ksmserver.
FIXED-IN: 6.0

M  +5    -1    ksmserver/logout.cpp
M  +3    -0    ksmserver/org.kde.KSMServerInterface.xml
M  +3    -0    ksmserver/org.kde.KWin.Session.xml
M  +1    -0    ksmserver/server.h
M  +31   -0    startkde/plasma-shutdown/shutdown.cpp
M  +1    -0    startkde/plasma-shutdown/shutdown.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/23cca93b879d0fcf9f430b03a482dbca1e0a1d79
Comment 9 Jakub 2023-11-26 19:24:51 UTC
Now plasma closes native Wayland apps, but still does not close Xwayland apps. Created separate bug report for that: https://bugs.kde.org/show_bug.cgi?id=477579