blob: d3e95c5460e11caebaedcb8015ef3d14e2fb6c15 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
//===========================================
// Lumina-DE source code
// Copyright (c) 2017, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
// This class governs all the xcb/randr interactions
// and provides simpler Qt-based functions for use elsewhere
//===========================================
#ifndef _LUMINA_LIBRARY_RANDR_MONITORS_H
#define _LUMINA_LIBRARY_RANDR_MONITORS_H
//Qt includes
#include <QSize>
#include <QString>
#include <QPoint>
#include <QRect>
#include <QList>
#include <QObject>
#include <QDebug>
#include <QX11Info>
// XCB
#include "xcb/randr.h"
#include "xcb/xcb_atom.h"
struct p_objects{
//public:
xcb_atom_t monitor_atom; //This is the index used to identify particular monitors (unique ID)
//Cached Information
bool primary, automatic;
QRect geometry;
QList<QSize> resolutions;
QSize physicalSizeMM;
QString name;
QList<xcb_randr_output_t> outputs;
QList<xcb_randr_mode_t> modes;
/*p_objects(){
// Set the defaults for non-default-constructed variables
primary = automatic = false;
monitor_atom = 0;
}*/
};
class OutputDevice{
public:
// EXPANSIONS TO-DO
//Refresh Rate
//int cHz; //current refresh rate
//QList<int> availHz; //available refresh rates
//Expand this later to include:
// panning (current/possible)
// rotation (current/possible)
//Global Listing of Devices
static QList<OutputDevice> availableMonitors();
//FUNCTIONS (do not use directly - use the static list function instead)
OutputDevice(QString id);
~OutputDevice();
//Information
QString ID();
bool isEnabled();
bool isPrimary();
bool isAutomatic();
QList<QSize> availableResolutions();
QSize currentResolution(); //could be different from geometry.size() if things like panning/rotation are enabled
QRect currentGeometry();
QSize physicalSizeMM();
//Modification
bool setAsPrimary(bool);
bool disable();
void enable(QRect geom = QRect()); //if no geom provided, will add as the right-most screen at optimal resolution
void changeResolution(QSize);
void changeGeometry(QRect); //move a currently-enabled screen to another place
void updateInfoCache(); //Run this after all modification functions to refresh the current info for this device
//Now define a simple public_objects class so that each implementation
// has a storage container for placing semi-private objects as needed
//class p_objects; //forward declaration - defined in the .cpp file
p_objects p_obj;
};
class OutputDeviceList{
private:
QList<OutputDevice> out_devs;
public:
OutputDeviceList();
~OutputDeviceList();
int length(){ return out_devs.length(); }
OutputDevice* at(int i){
if(i<out_devs.length()){ return &out_devs[i]; }
return 0;
}
//Simplification functions for dealing with multiple monitors
void setPrimaryMonitor(QString id);
void disableMonitor(QString id);
//void enableMonitor(QString id, QRect geom);
};
#endif
|