1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-25 22:50:35 +03:00
latte-dock/app/screenpool.h
Michail Vourlakos 60095bba3b fix #96,FEATURE:AllScreens and AllSecondaryScreens
--This is a HUGE FEATURE and so important for multi-screens
users. It is introduced as one single commit because it
reimplements plenty of infrastructure changes and it will
be easier to identify newly introduced bugs.
--Users can now choose for their docks and panels to belong
at various screen groups. The first two screen groups introduced
are AllScreens and AllSecondayScreens. In the future it might
be possible to provide CustomScreensGroup that the user will
be able to define specific screens in which a dock or panel
should be always present.
--Current solution specifies an Original dock or panel and clones/copies
itself automatically to other screens. So docks and panels in other screens
are just real docks and panels that reference themselves to original
docks and panels.
--Clones are destroyed during layout startup and are automaticaly
recreated. It is suggested to export your layouts through the
official Layouts Editor in order to share them because in that case
clones are not included in the new generated layout file. If in any
case you do not this and you share your layout with any previous
versions then your clones will just appear as separate docks and
panels that belong to specific screens.
--Automatic syncing was introduced in order to keep up-to-date
the configuration of Original docks and panels with their referenced
Clones.
--Automatic syncing currently works for all docks and panels settings,
for all normal applets configurations and for all subcontaiments
configuration such as systrays.
--Automatic syncing does not work for applets inside subcontainments
such as Group Plasmoid. In such case it is suggested to configure
your applets inside your Group Plasmoid in the original dock or panel
and afterwards to trigger a recreation for the relevant clones
--Manual recreation of clones is easily possible by just choosing
the dock or panel to be OnPrimary or OnSpecificScreen and rechoosing
afterwards the AllScreensGroup or AllSecondaryScreensGroup
2022-01-16 13:38:13 +02:00

87 lines
1.9 KiB
C++

/*
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef SCREENPOOL_H
#define SCREENPOOL_H
// local
#include "data/screendata.h"
// Qt
#include <QObject>
#include <QHash>
#include <QScreen>
#include <QString>
#include <QTimer>
#include <QAbstractNativeEventFilter>
// KDE
#include <KConfigGroup>
#include <KSharedConfig>
namespace Latte {
class ScreenPool : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
static const int FIRSTSCREENID = 10;
static const int NOSCREENID = -1;
ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr);
void load();
~ScreenPool() override;
bool hasScreenId(int screenId) const;
bool isScreenActive(int screenId) const;
int primaryScreenId() const;
QList<int> secondaryScreenIds() const;
void insertScreenMapping(const QString &connector);
void reload(QString path);
void removeScreens(const Latte::Data::ScreensTable &obsoleteScreens);
int id(const QString &connector) const;
QString connector(int id) const;
QScreen *screenForId(int id);
Latte::Data::ScreensTable screensTable();
signals:
void primaryPoolChanged();
void screenGeometryChanged();
protected:
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);
private:
void save();
void updateScreenGeometry(const int &screenId, const QRect &screenGeometry);
private:
Latte::Data::ScreensTable m_screensTable;
KConfigGroup m_configGroup;
//! used to workaround a bug under X11 when primary screen changes and no screenChanged signal is emitted
QString m_lastPrimaryConnector;
QTimer m_configSaveTimer;
};
}
#endif // SCREENPOOL_H