summaryrefslogtreecommitdiffstats
path: root/oldsrc/displaymanager.cpp
blob: 61f35ead5303915852adf2705011f6eb307ad80f (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
#include "displaymanager.h"


DisplayManager * DisplayManager::Instance = NULL;

DisplayManager::DisplayManager()
{
    dpy = NULL;
    resources = NULL;


    // Get initial data (to be freed)
    dpy = XOpenDisplay(NULL);
    resources = XRRGetScreenResourcesCurrent(dpy, DefaultRootWindow(dpy));

    // Get outputs
    for (int i = 0; i < resources->noutput; ++i) {
        XRROutputInfo *info = XRRGetOutputInfo (dpy, resources, resources->outputs[i]);
        if (info->connection == RR_Connected)
            Outputs.push_back(Output(dpy, resources, resources->outputs[i]));
        XRRFreeOutputInfo(info);
    }
}

DisplayManager::~DisplayManager()
{
    XCloseDisplay(dpy);
    XRRFreeScreenResources(resources);
}

DisplayManager *DisplayManager::Inst()
{
    if (Instance == 0)
        Instance = new DisplayManager();
    return Instance;
}