Changeset View
Changeset View
Standalone View
Standalone View
sm.cpp
Show All 21 Lines | |||||
22 | #include "sm.h" | 22 | #include "sm.h" | ||
23 | 23 | | |||
24 | #include <unistd.h> | 24 | #include <unistd.h> | ||
25 | #include <cstdlib> | 25 | #include <cstdlib> | ||
26 | #include <pwd.h> | 26 | #include <pwd.h> | ||
27 | #include <kconfig.h> | 27 | #include <kconfig.h> | ||
28 | 28 | | |||
29 | #include "workspace.h" | 29 | #include "workspace.h" | ||
30 | #include "client.h" | 30 | #include "x11client.h" | ||
31 | #include <QDebug> | 31 | #include <QDebug> | ||
32 | #include <QFile> | 32 | #include <QFile> | ||
33 | #include <QSocketNotifier> | 33 | #include <QSocketNotifier> | ||
34 | #include <QSessionManager> | 34 | #include <QSessionManager> | ||
35 | 35 | | |||
36 | namespace KWin | 36 | namespace KWin | ||
37 | { | 37 | { | ||
38 | 38 | | |||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | |||||
127 | */ | 127 | */ | ||
128 | void Workspace::storeSession(KConfig* config, SMSavePhase phase) | 128 | void Workspace::storeSession(KConfig* config, SMSavePhase phase) | ||
129 | { | 129 | { | ||
130 | KConfigGroup cg(config, "Session"); | 130 | KConfigGroup cg(config, "Session"); | ||
131 | int count = 0; | 131 | int count = 0; | ||
132 | int active_client = -1; | 132 | int active_client = -1; | ||
133 | 133 | | |||
134 | for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { | 134 | for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { | ||
135 | Client* c = (*it); | 135 | X11Client *c = (*it); | ||
136 | if (c->windowType() > NET::Splash) { | 136 | if (c->windowType() > NET::Splash) { | ||
137 | //window types outside this are not tooltips/menus/OSDs | 137 | //window types outside this are not tooltips/menus/OSDs | ||
138 | //typically these will be unmanaged and not in this list anyway, but that is not enforced | 138 | //typically these will be unmanaged and not in this list anyway, but that is not enforced | ||
139 | continue; | 139 | continue; | ||
140 | } | 140 | } | ||
141 | QByteArray sessionId = c->sessionId(); | 141 | QByteArray sessionId = c->sessionId(); | ||
142 | QByteArray wmCommand = c->wmCommand(); | 142 | QByteArray wmCommand = c->wmCommand(); | ||
143 | if (sessionId.isEmpty()) | 143 | if (sessionId.isEmpty()) | ||
Show All 19 Lines | 160 | } else if (phase == SMSavePhase2) { | |||
163 | cg.writeEntry("desktop", session_desktop); | 163 | cg.writeEntry("desktop", session_desktop); | ||
164 | } else { // SMSavePhase2Full | 164 | } else { // SMSavePhase2Full | ||
165 | cg.writeEntry("count", count); | 165 | cg.writeEntry("count", count); | ||
166 | cg.writeEntry("active", session_active_client); | 166 | cg.writeEntry("active", session_active_client); | ||
167 | cg.writeEntry("desktop", VirtualDesktopManager::self()->current()); | 167 | cg.writeEntry("desktop", VirtualDesktopManager::self()->current()); | ||
168 | } | 168 | } | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | void Workspace::storeClient(KConfigGroup &cg, int num, Client *c) | 171 | void Workspace::storeClient(KConfigGroup &cg, int num, X11Client *c) | ||
172 | { | 172 | { | ||
173 | c->setSessionActivityOverride(false); //make sure we get the real values | 173 | c->setSessionActivityOverride(false); //make sure we get the real values | ||
174 | QString n = QString::number(num); | 174 | QString n = QString::number(num); | ||
175 | cg.writeEntry(QLatin1String("sessionId") + n, c->sessionId().constData()); | 175 | cg.writeEntry(QLatin1String("sessionId") + n, c->sessionId().constData()); | ||
176 | cg.writeEntry(QLatin1String("windowRole") + n, c->windowRole().constData()); | 176 | cg.writeEntry(QLatin1String("windowRole") + n, c->windowRole().constData()); | ||
177 | cg.writeEntry(QLatin1String("wmCommand") + n, c->wmCommand().constData()); | 177 | cg.writeEntry(QLatin1String("wmCommand") + n, c->wmCommand().constData()); | ||
178 | cg.writeEntry(QLatin1String("resourceName") + n, c->resourceName().constData()); | 178 | cg.writeEntry(QLatin1String("resourceName") + n, c->resourceName().constData()); | ||
179 | cg.writeEntry(QLatin1String("resourceClass") + n, c->resourceClass().constData()); | 179 | cg.writeEntry(QLatin1String("resourceClass") + n, c->resourceClass().constData()); | ||
Show All 26 Lines | |||||
206 | 206 | | |||
207 | void Workspace::storeSubSession(const QString &name, QSet<QByteArray> sessionIds) | 207 | void Workspace::storeSubSession(const QString &name, QSet<QByteArray> sessionIds) | ||
208 | { | 208 | { | ||
209 | //TODO clear it first | 209 | //TODO clear it first | ||
210 | KConfigGroup cg(KSharedConfig::openConfig(), QLatin1String("SubSession: ") + name); | 210 | KConfigGroup cg(KSharedConfig::openConfig(), QLatin1String("SubSession: ") + name); | ||
211 | int count = 0; | 211 | int count = 0; | ||
212 | int active_client = -1; | 212 | int active_client = -1; | ||
213 | for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { | 213 | for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { | ||
214 | Client* c = (*it); | 214 | X11Client *c = (*it); | ||
215 | if (c->windowType() > NET::Splash) { | 215 | if (c->windowType() > NET::Splash) { | ||
216 | continue; | 216 | continue; | ||
217 | } | 217 | } | ||
218 | QByteArray sessionId = c->sessionId(); | 218 | QByteArray sessionId = c->sessionId(); | ||
219 | QByteArray wmCommand = c->wmCommand(); | 219 | QByteArray wmCommand = c->wmCommand(); | ||
220 | if (sessionId.isEmpty()) | 220 | if (sessionId.isEmpty()) | ||
221 | // remember also applications that are not XSMP capable | 221 | // remember also applications that are not XSMP capable | ||
222 | // and use the obsolete WM_COMMAND / WM_SAVE_YOURSELF | 222 | // and use the obsolete WM_COMMAND / WM_SAVE_YOURSELF | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
289 | } | 289 | } | ||
290 | 290 | | |||
291 | void Workspace::loadSubSessionInfo(const QString &name) | 291 | void Workspace::loadSubSessionInfo(const QString &name) | ||
292 | { | 292 | { | ||
293 | KConfigGroup cg(KSharedConfig::openConfig(), QLatin1String("SubSession: ") + name); | 293 | KConfigGroup cg(KSharedConfig::openConfig(), QLatin1String("SubSession: ") + name); | ||
294 | addSessionInfo(cg); | 294 | addSessionInfo(cg); | ||
295 | } | 295 | } | ||
296 | 296 | | |||
297 | static bool sessionInfoWindowTypeMatch(Client* c, SessionInfo* info) | 297 | static bool sessionInfoWindowTypeMatch(X11Client *c, SessionInfo* info) | ||
298 | { | 298 | { | ||
299 | if (info->windowType == -2) { | 299 | if (info->windowType == -2) { | ||
300 | // undefined (not really part of NET::WindowType) | 300 | // undefined (not really part of NET::WindowType) | ||
301 | return !c->isSpecialWindow(); | 301 | return !c->isSpecialWindow(); | ||
302 | } | 302 | } | ||
303 | return info->windowType == c->windowType(); | 303 | return info->windowType == c->windowType(); | ||
304 | } | 304 | } | ||
305 | 305 | | |||
306 | /** | 306 | /** | ||
307 | * Returns a SessionInfo for client \a c. The returned session | 307 | * Returns a SessionInfo for client \a c. The returned session | ||
308 | * info is removed from the storage. It's up to the caller to delete it. | 308 | * info is removed from the storage. It's up to the caller to delete it. | ||
309 | * | 309 | * | ||
310 | * This function is called when a new window is mapped and must be managed. | 310 | * This function is called when a new window is mapped and must be managed. | ||
311 | * We try to find a matching entry in the session. | 311 | * We try to find a matching entry in the session. | ||
312 | * | 312 | * | ||
313 | * May return 0 if there's no session info for the client. | 313 | * May return 0 if there's no session info for the client. | ||
314 | */ | 314 | */ | ||
315 | SessionInfo* Workspace::takeSessionInfo(Client* c) | 315 | SessionInfo* Workspace::takeSessionInfo(X11Client *c) | ||
316 | { | 316 | { | ||
317 | SessionInfo *realInfo = nullptr; | 317 | SessionInfo *realInfo = nullptr; | ||
318 | QByteArray sessionId = c->sessionId(); | 318 | QByteArray sessionId = c->sessionId(); | ||
319 | QByteArray windowRole = c->windowRole(); | 319 | QByteArray windowRole = c->windowRole(); | ||
320 | QByteArray wmCommand = c->wmCommand(); | 320 | QByteArray wmCommand = c->wmCommand(); | ||
321 | QByteArray resourceName = c->resourceName(); | 321 | QByteArray resourceName = c->resourceName(); | ||
322 | QByteArray resourceClass = c->resourceClass(); | 322 | QByteArray resourceClass = c->resourceClass(); | ||
323 | 323 | | |||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | |||||
505 | { | 505 | { | ||
506 | if (conn != nullptr) | 506 | if (conn != nullptr) | ||
507 | IceProcessMessages(SmcGetIceConnection(conn), nullptr, nullptr); | 507 | IceProcessMessages(SmcGetIceConnection(conn), nullptr, nullptr); | ||
508 | } | 508 | } | ||
509 | 509 | | |||
510 | void Workspace::sessionSaveDone() | 510 | void Workspace::sessionSaveDone() | ||
511 | { | 511 | { | ||
512 | session_saving = false; | 512 | session_saving = false; | ||
513 | foreach (Client * c, clients) { | 513 | foreach (X11Client *c, clients) { | ||
514 | c->setSessionActivityOverride(false); | 514 | c->setSessionActivityOverride(false); | ||
515 | } | 515 | } | ||
516 | } | 516 | } | ||
517 | 517 | | |||
518 | } // namespace | 518 | } // namespace | ||
519 | 519 | |