File indexing completed on 2024-05-12 16:59:21

0001 /*
0002  *   SPDX-FileCopyrightText: 2010-2016 Ivan Cukic <ivan.cukic@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef RESOURCES_P_H
0008 #define RESOURCES_P_H
0009 
0010 // Self
0011 #include "Resources.h"
0012 
0013 // Qt
0014 #include <QString>
0015 #include <QWindow> // for WId
0016 
0017 // Local
0018 #include "resourcesadaptor.h"
0019 
0020 class Resources::Private : public QThread
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     Private(Resources *parent);
0026     ~Private() override;
0027 
0028     void run() override;
0029 
0030     // Inserts the event directly into the queue
0031     void insertEvent(const Event &newEvent);
0032 
0033     // Processes the event and inserts it into the queue
0034     void addEvent(const QString &application, WId wid, const QString &uri, int type);
0035 
0036     // Processes the event and inserts it into the queue
0037     void addEvent(const Event &newEvent);
0038 
0039     QStringList resourcesLinkedToActivity(const QString &activity) const;
0040 
0041 public Q_SLOTS:
0042     // Reacting to window manager signals
0043     void windowClosed(WId windowId);
0044 
0045     void activeWindowChanged(WId windowId);
0046 
0047 private:
0048     struct WindowData {
0049         QSet<QString> resources;
0050         QString focussedResource;
0051         QString application;
0052     };
0053 
0054     Event lastEvent;
0055 
0056     QHash<WId, WindowData> windows;
0057     WId focussedWindow;
0058 
0059     Resources *const q;
0060 };
0061 
0062 #endif // RESOURCES_P_H