File indexing completed on 2024-05-12 05:29:23

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 #pragma once
0008 
0009 // Self
0010 #include "Resources.h"
0011 
0012 // Qt
0013 #include <QString>
0014 #include <QWindow> // for WId
0015 
0016 // Local
0017 #include "resourcesadaptor.h"
0018 
0019 class Resources::Private : public QThread
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     Private(Resources *parent);
0025     ~Private() override;
0026 
0027     void run() override;
0028 
0029     // Inserts the event directly into the queue
0030     void insertEvent(const Event &newEvent);
0031 
0032     // Processes the event and inserts it into the queue
0033     void addEvent(const QString &application, WId wid, const QString &uri, int type);
0034 
0035     // Processes the event and inserts it into the queue
0036     void addEvent(const Event &newEvent);
0037 
0038     QStringList resourcesLinkedToActivity(const QString &activity) const;
0039 
0040 public Q_SLOTS:
0041     // Reacting to window manager signals
0042     void windowClosed(WId windowId);
0043 
0044     void activeWindowChanged(WId windowId);
0045 
0046 private:
0047     struct WindowData {
0048         QSet<QString> resources;
0049         QString focussedResource;
0050         QString application;
0051     };
0052 
0053     Event lastEvent;
0054 
0055     QHash<WId, WindowData> windows;
0056     WId focussedWindow;
0057 
0058     Resources *const q;
0059 };