File indexing completed on 2025-01-19 05:01:18
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org> 0006 SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include <QDBusContext> 0014 #include <QDataStream> 0015 #include <QRect> 0016 #include <QStringList> 0017 #include <QTimer> 0018 0019 #include <KConfigGroup> 0020 0021 #include "effect/globals.h" 0022 #include <netwm_def.h> 0023 0024 namespace KWin 0025 { 0026 0027 class X11Window; 0028 struct SessionInfo; 0029 class XdgToplevelWindow; 0030 0031 class SessionManager : public QObject, public QDBusContext 0032 { 0033 Q_OBJECT 0034 public: 0035 enum SMSavePhase { 0036 SMSavePhase0, // saving global state in "phase 0" 0037 SMSavePhase2, // saving window state in phase 2 0038 SMSavePhase2Full, // complete saving in phase2, there was no phase 0 0039 }; 0040 0041 SessionManager(QObject *parent); 0042 ~SessionManager() override; 0043 0044 SessionState state() const; 0045 0046 void loadSubSessionInfo(const QString &name); 0047 void storeSubSession(const QString &name, QSet<QByteArray> sessionIds); 0048 0049 SessionInfo *takeSessionInfo(X11Window *); 0050 0051 Q_SIGNALS: 0052 void stateChanged(); 0053 0054 void loadSessionRequested(const QString &name); 0055 void prepareSessionSaveRequested(const QString &name); 0056 void finishSessionSaveRequested(const QString &name); 0057 0058 public Q_SLOTS: // DBus API 0059 void setState(uint state); 0060 void loadSession(const QString &name); 0061 void aboutToSaveSession(const QString &name); 0062 void finishSaveSession(const QString &name); 0063 bool closeWaylandWindows(); 0064 void quit(); 0065 0066 private: 0067 void setState(SessionState state); 0068 0069 void storeSession(const QString &sessionName, SMSavePhase phase); 0070 void storeClient(KConfigGroup &cg, int num, X11Window *c); 0071 void loadSessionInfo(const QString &sessionName); 0072 void addSessionInfo(KConfigGroup &cg); 0073 0074 SessionState m_sessionState = SessionState::Normal; 0075 0076 int m_sessionActiveClient; 0077 int m_sessionDesktop; 0078 0079 QList<SessionInfo *> session; 0080 QList<XdgToplevelWindow *> m_pendingWindows; 0081 QTimer m_closeTimer; 0082 std::unique_ptr<QObject> m_closingWindowsGuard; 0083 }; 0084 0085 struct SessionInfo 0086 { 0087 QByteArray sessionId; 0088 QString windowRole; 0089 QString wmCommand; 0090 QString wmClientMachine; 0091 QString resourceName; 0092 QString resourceClass; 0093 0094 QRect geometry; 0095 QRect restore; 0096 QRect fsrestore; 0097 int maximized; 0098 int fullscreen; 0099 int desktop; 0100 bool minimized; 0101 bool onAllDesktops; 0102 bool shaded; 0103 bool keepAbove; 0104 bool keepBelow; 0105 bool skipTaskbar; 0106 bool skipPager; 0107 bool skipSwitcher; 0108 bool noBorder; 0109 NET::WindowType windowType; 0110 QString shortcut; 0111 bool active; // means 'was active in the saved session' 0112 int stackingOrder; 0113 float opacity; 0114 0115 QStringList activities; 0116 }; 0117 0118 } // namespace