diff options
Diffstat (limited to 'src/displaymanager.cpp')
-rw-r--r-- | src/displaymanager.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/displaymanager.cpp b/src/displaymanager.cpp new file mode 100644 index 0000000..61f35ea --- /dev/null +++ b/src/displaymanager.cpp @@ -0,0 +1,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; +} |