Changeset View
Changeset View
Standalone View
Standalone View
src/kmainwindow.cpp
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Line(s) | |||||
169 | void KMWSessionManager::commitData(QSessionManager &sm) | 169 | void KMWSessionManager::commitData(QSessionManager &sm) | ||
170 | { | 170 | { | ||
171 | if (!sm.allowsInteraction()) { | 171 | if (!sm.allowsInteraction()) { | ||
172 | return; | 172 | return; | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | /* | 175 | /* | ||
176 | Purpose of this exercise: invoke queryClose() without actually closing the | 176 | Purpose of this exercise: invoke queryClose() without actually closing the | ||
177 | windows, because | 177 | application, because | ||
178 | - queryClose() may contain session management code, so it must be invoked | | |||
179 | - actually closing windows may quit the application - cf. | | |||
180 | QGuiApplication::quitOnLastWindowClosed() | | |||
181 | - quitting the application and thus closing the session manager connection | 178 | - quitting the application and thus closing the session manager connection | ||
182 | violates the X11 XSMP protocol. | 179 | violates the X11 XSMP protocol. | ||
183 | The exact requirement of XSMP that would be broken is, | 180 | The exact requirement of XSMP that would be broken is, | ||
184 | in the description of the client's state machine: | 181 | in the description of the client's state machine: | ||
185 | 182 | | |||
186 | save-yourself-done: (changing state is forbidden) | 183 | save-yourself-done: (changing state is forbidden) | ||
187 | 184 | | |||
188 | Closing the session manager connection causes a state change. | 185 | Closing the session manager connection causes a state change. | ||
189 | Worst of all, that is a real problem with ksmserver - it will not save | 186 | Worst of all, that is a real problem with ksmserver - it will not save | ||
190 | applications that quit on their own in state save-yourself-done. | 187 | applications that quit on their own in state save-yourself-done. | ||
191 | */ | 188 | */ | ||
189 | QGuiApplication::setQuitOnLastWindowClosed(false); | ||||
192 | const auto windows = KMainWindow::memberList(); | 190 | const auto windows = KMainWindow::memberList(); | ||
193 | for (KMainWindow *window : windows) { | 191 | for (KMainWindow *window : windows) { | ||
194 | if (window->testAttribute(Qt::WA_WState_Hidden)) { | 192 | if (window->testAttribute(Qt::WA_WState_Hidden)) { | ||
195 | continue; | 193 | continue; | ||
196 | } | 194 | } | ||
197 | QCloseEvent e; | 195 | if (!window->close()) { | ||
198 | QApplication::sendEvent(window, &e); | | |||
199 | if (!e.isAccepted()) { | | |||
200 | sm.cancel(); | 196 | sm.cancel(); | ||
201 | return; | 197 | break; | ||
202 | } | 198 | } | ||
203 | } | 199 | } | ||
200 | QGuiApplication::setQuitOnLastWindowClosed(true); | ||||
204 | } | 201 | } | ||
205 | 202 | | |||
206 | Q_GLOBAL_STATIC(KMWSessionManager, ksm) | 203 | Q_GLOBAL_STATIC(KMWSessionManager, ksm) | ||
207 | Q_GLOBAL_STATIC(QList<KMainWindow *>, sMemberList) | 204 | Q_GLOBAL_STATIC(QList<KMainWindow *>, sMemberList) | ||
208 | 205 | | |||
209 | KMainWindow::KMainWindow(QWidget *parent, Qt::WindowFlags f) | 206 | KMainWindow::KMainWindow(QWidget *parent, Qt::WindowFlags f) | ||
210 | : QMainWindow(parent, f), k_ptr(new KMainWindowPrivate) | 207 | : QMainWindow(parent, f), k_ptr(new KMainWindowPrivate) | ||
211 | { | 208 | { | ||
▲ Show 20 Lines • Show All 742 Lines • Show Last 20 Lines |