File indexing completed on 2024-02-18 16:20:15

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 <QDataStream>
0014 #include <QRect>
0015 #include <QStringList>
0016 
0017 #include <KConfigGroup>
0018 
0019 #include <kwinglobals.h>
0020 #include <netwm_def.h>
0021 
0022 namespace KWin
0023 {
0024 
0025 class X11Window;
0026 struct SessionInfo;
0027 
0028 class SessionManager : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     enum SMSavePhase {
0033         SMSavePhase0, // saving global state in "phase 0"
0034         SMSavePhase2, // saving window state in phase 2
0035         SMSavePhase2Full, // complete saving in phase2, there was no phase 0
0036     };
0037 
0038     SessionManager(QObject *parent);
0039     ~SessionManager() override;
0040 
0041     SessionState state() const;
0042 
0043     void loadSubSessionInfo(const QString &name);
0044     void storeSubSession(const QString &name, QSet<QByteArray> sessionIds);
0045 
0046     SessionInfo *takeSessionInfo(X11Window *);
0047 
0048 Q_SIGNALS:
0049     void stateChanged();
0050 
0051     void loadSessionRequested(const QString &name);
0052     void prepareSessionSaveRequested(const QString &name);
0053     void finishSessionSaveRequested(const QString &name);
0054 
0055 public Q_SLOTS: // DBus API
0056     void setState(uint state);
0057     void loadSession(const QString &name);
0058     void aboutToSaveSession(const QString &name);
0059     void finishSaveSession(const QString &name);
0060     void quit();
0061 
0062 private:
0063     void setState(SessionState state);
0064 
0065     void storeSession(const QString &sessionName, SMSavePhase phase);
0066     void storeClient(KConfigGroup &cg, int num, X11Window *c);
0067     void loadSessionInfo(const QString &sessionName);
0068     void addSessionInfo(KConfigGroup &cg);
0069 
0070     SessionState m_sessionState = SessionState::Normal;
0071 
0072     int m_sessionActiveClient;
0073     int m_sessionDesktop;
0074 
0075     QList<SessionInfo *> session;
0076 };
0077 
0078 struct SessionInfo
0079 {
0080     QByteArray sessionId;
0081     QString windowRole;
0082     QString wmCommand;
0083     QString wmClientMachine;
0084     QString resourceName;
0085     QString resourceClass;
0086 
0087     QRect geometry;
0088     QRect restore;
0089     QRect fsrestore;
0090     int maximized;
0091     int fullscreen;
0092     int desktop;
0093     bool minimized;
0094     bool onAllDesktops;
0095     bool shaded;
0096     bool keepAbove;
0097     bool keepBelow;
0098     bool skipTaskbar;
0099     bool skipPager;
0100     bool skipSwitcher;
0101     bool noBorder;
0102     NET::WindowType windowType;
0103     QString shortcut;
0104     bool active; // means 'was active in the saved session'
0105     int stackingOrder;
0106     float opacity;
0107 
0108     QStringList activities;
0109 };
0110 
0111 } // namespace