summaryrefslogtreecommitdiffstats
path: root/src/output.h
blob: 553444d50757b145ae5841b17696b2d51a4bfe37 (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
#ifndef OUTPUT_H
#define OUTPUT_H

#include <QDebug>
#include <QSet>

#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>

typedef struct _Resolution{
    unsigned int width;
    unsigned int height;
}Resolution;

inline bool operator==(const Resolution& lhs, const Resolution& rhs) {
    return lhs.width == rhs.width && lhs.height == rhs.height;
}

inline uint qHash(const Resolution &key)
{
    return qHash(key.width ^ key.height);
}

class Output
{
public:


    Output(Display *dpy, XRRScreenResources *resources, RROutput output);

    bool             hasEDID() const;
    bool             isProjector() const;
    Resolution       getCurrentMode() const;
    Resolution       getPreferredMode() const;
    QSet<Resolution> getSupportedModes() const;
    Resolution       addMode(Resolution) const;

private:

    Display            *dpy;
    XRRScreenResources *resources;
    RROutput           ID;

    Resolution         getResolution(RRMode) const;
};

#endif // OUTPUT_H