]> git.tdb.fi Git - libs/gui.git/commitdiff
Store the root window's ID in display private data
authorMikko Rasa <tdb@tdb.fi>
Sun, 20 Dec 2015 13:15:15 +0000 (15:15 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 20 Dec 2015 13:15:15 +0000 (15:15 +0200)
source/graphics/x11/display.cpp
source/graphics/x11/display_platform.h
source/graphics/x11/window.cpp

index 8f022f7957a8af1c5df81d5844fe7e7683d2a7d9..24bb53f479657cf78dfded9e4b4b1b43217e6fea 100644 (file)
@@ -96,6 +96,8 @@ Display::Display(const string &disp_name):
 
        XSetErrorHandler(x_error_handler);
 
+       priv->root_window = DefaultRootWindow(priv->display);
+
        err_dialog = new ErrorDialog(this);
 
 #ifdef WITH_XRANDR
@@ -107,9 +109,8 @@ Display::Display(const string &disp_name):
                XRRQueryVersion(priv->display, &major, &minor);
                if(major>1 || (major==1 && minor>=2))
                {
-                       WindowHandle root = DefaultRootWindow(priv->display);
-                       XRRScreenResources *res = XRRGetScreenResources(priv->display, root);
-                       RROutput primary = XRRGetOutputPrimary(priv->display, root);
+                       XRRScreenResources *res = XRRGetScreenResources(priv->display, priv->root_window);
+                       RROutput primary = XRRGetOutputPrimary(priv->display, priv->root_window);
 
                        map<RRMode, XRRModeInfo *> modes_by_id;
                        for(int i=0; i<res->nmode; ++i)
@@ -219,8 +220,7 @@ void Display::set_mode(const VideoMode &requested_mode, bool exclusive)
        if(requested_rotation==ROTATE_ANY)
                requested_rotation = mode->monitor->desktop_rotation;
 
-       WindowHandle root = DefaultRootWindow(priv->display);
-       XRRScreenResources *res = XRRGetScreenResources(priv->display, root);
+       XRRScreenResources *res = XRRGetScreenResources(priv->display, priv->root_window);
        RROutput output = priv->monitors[mode->monitor->index];
        XRROutputInfo *output_info = XRRGetOutputInfo(priv->display, res, output);
 
index 4335f1cac3a5de89c52386f5e3e26baaa7b90e3f..974f9c07d7ebfd1e1abc6d982bef46ca2ea99ce4 100644 (file)
@@ -5,6 +5,7 @@
 #ifdef WITH_XRANDR
 #include <X11/extensions/Xrandr.h>
 #endif
+#include "window_private.h"
 
 namespace Msp {
 namespace Graphics {
@@ -13,6 +14,7 @@ typedef ::Display *DisplayHandle;
 
 struct PlatformDisplayPrivate
 {
+       WindowHandle root_window;
 #ifdef WITH_XRANDR
        std::vector<RROutput> monitors;
        std::vector<RRMode> modes;
index fbaf36c287a90928efe34dfa4dbaa3c7a887ff78..2c03bf745570f7d2680257e30491e4fd56af2403 100644 (file)
@@ -32,7 +32,7 @@ void Window::platform_init()
        attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask|ExposureMask;
 
        priv->window = XCreateWindow(dpy,
-               DefaultRootWindow(dpy),
+               display.get_private().root_window,
                0, 0,
                options.width, options.height,
                0,