summaryrefslogtreecommitdiffstats
path: root/src/xx.h
blob: a17d4b70abadd6d8bf21f6fea9852f53d2bde603 (plain) (blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef XRANDR_H
#define XRANDR_H

#include <QList>
#include <QString>
#include <QSize>

struct ScreenInfo;
class XPrivate;

typedef QVector<QSize>                    ResolutionVector;

///////////////////////////////////////////////////////////////////////////

enum class ScreenMode
{
	Single,
	Clone,
	Dual,
	Advanced,
};

struct ScreenInfo
{
	int position;
	QString name;
	QString output;
	QSize currentResolution;
	QSize preferredResolution;
	bool isProjector;
	ResolutionVector modes;
};

class ScreenSetup
{
public:
	void         updateScreenResources();
	void         initModes();
	ScreenMode   getCurrentMode();
	ScreenMode   setDefaultMode(bool dryRun = false);
	bool         createMode(unsigned int resX, unsigned int resY, float refresh, QString name);
	void         revertChanges();
	bool         setClone(const QSize &resolution);
	bool         setCustom(const QList<QPair<QSize, QList<QString>>> &list);
	ResolutionVector getCommonModes() const;
	int getOutputCount() const;
	QMap<QString, ScreenInfo> getScreenPositions() const;
	const ResolutionVector &getVirtualResolutions() const;

	// Singleton
	inline static ScreenSetup*             inst() {
		if (_instance == nullptr) _instance = new ScreenSetup();
		return _instance;
	}

private:
	ScreenSetup();
	~ScreenSetup();

	static ScreenSetup *     _instance;
	XPrivate *a;
};

///////////////////////////////////////////////////////////////////////////

#endif // XRANDR_H