summaryrefslogtreecommitdiff
path: root/src/waylandentries.h
blob: ce98adeee201703d27e7118dc60af37d045cbcc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef WAYLANDENTRIES_H
#define WAYLANDENTRIES_H

#include <QAbstractListModel>
#include <QRecursiveMutex>
#include <QObject>

class QWaylandXdgSurface;

class WaylandEntries : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(int nbApps READ nbApps NOTIFY nbAppsChanged)


    QList<QWaylandXdgSurface *> m_surfaces;
    QList<QWaylandXdgSurface *> m_surfaces_hidden;
    QList<qint64> m_hidden;
    mutable QRecursiveMutex m_lock;

public:
    explicit WaylandEntries(QObject *parent = nullptr);

    enum WaylandEntryRoles {
        SurfaceRole = Qt::UserRole + 1,
        TitleRole,
        PidRole,
        AppIdRole
    };

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QHash<int, QByteArray> roleNames() const override;

    static WaylandEntries* getInstance();

    int nbApps() const;
    void setNbApps(int newNbApps);

public slots:
    void addSurface(QObject *obj);
    void addHidePid(qint64 pid);
    void surfaceDestroyed();
    void stop(int pid);
    QObject *getSurface(int pid);

signals:
    void nbAppsChanged();
    void topWindowRegistered(QObject *surface, QString appid);
    void topWindowDestroyed(QObject *surface, QString appid);
};

#endif // WAYLANDENTRIES_H