1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-15 10:50:15 +03:00
latte-dock/app/screenpool.h

84 lines
1.8 KiB
C
Raw Permalink Normal View History

2017-02-24 20:58:21 +02:00
/*
2021-05-27 15:01:00 +00:00
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
2017-02-24 20:58:21 +02:00
#ifndef SCREENPOOL_H
#define SCREENPOOL_H
2021-02-17 12:02:52 +02:00
// local
#include "data/screendata.h"
2018-12-02 02:05:52 +02:00
// Qt
2017-02-24 20:58:21 +02:00
#include <QObject>
#include <QHash>
#include <QScreen>
2017-02-24 20:58:21 +02:00
#include <QString>
#include <QTimer>
#include <QAbstractNativeEventFilter>
2017-02-24 20:58:21 +02:00
2018-12-02 02:05:52 +02:00
// KDE
2017-02-24 20:58:21 +02:00
#include <KConfigGroup>
#include <KSharedConfig>
namespace Latte {
2018-07-03 22:15:45 +03:00
class ScreenPool : public QObject, public QAbstractNativeEventFilter
{
2017-02-24 20:58:21 +02:00
Q_OBJECT
public:
2021-03-20 18:57:28 +02:00
static const int FIRSTSCREENID = 10;
2017-02-24 20:58:21 +02:00
ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr);
void load();
~ScreenPool() override;
2021-02-17 12:24:36 +02:00
bool hasScreenId(int screenId) const;
bool isScreenActive(int screenId) const;
int primaryScreenId() const;
void insertScreenMapping(const QString &connector);
void reload(QString path);
void removeScreens(const Latte::Data::ScreensTable &obsoleteScreens);
2017-02-24 20:58:21 +02:00
int id(const QString &connector) const;
QString connector(int id) const;
QScreen *screenForId(int id);
Latte::Data::ScreensTable screensTable();
signals:
void primaryPoolChanged();
protected:
2017-03-12 15:14:30 -05:00
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
int firstAvailableId() const;
private slots:
void updateScreenGeometry(const QScreen *screen);
void onScreenAdded(const QScreen *screen);
void onScreenRemoved(const QScreen *screen);
2017-02-24 20:58:21 +02:00
private:
void save();
void updateScreenGeometry(const int &screenId, const QRect &screenGeometry);
private:
2021-02-17 12:02:52 +02:00
Latte::Data::ScreensTable m_screensTable;
2017-02-24 20:58:21 +02:00
KConfigGroup m_configGroup;
//! used to workaround a bug under X11 when primary screen changes and no screenChanged signal is emitted
QString m_lastPrimaryConnector;
2021-02-17 12:24:36 +02:00
2017-02-24 20:58:21 +02:00
QTimer m_configSaveTimer;
};
}
2017-02-24 20:58:21 +02:00
#endif // SCREENPOOL_H