From: Mikko Rasa Date: Sun, 20 Dec 2015 13:15:15 +0000 (+0200) Subject: Store the root window's ID in display private data X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=eb1a0ac27179962b8719a729c483549a9cca971a;p=libs%2Fgui.git Store the root window's ID in display private data --- diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index 8f022f7..24bb53f 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -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 modes_by_id; for(int i=0; inmode; ++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); diff --git a/source/graphics/x11/display_platform.h b/source/graphics/x11/display_platform.h index 4335f1c..974f9c0 100644 --- a/source/graphics/x11/display_platform.h +++ b/source/graphics/x11/display_platform.h @@ -5,6 +5,7 @@ #ifdef WITH_XRANDR #include #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 monitors; std::vector modes; diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index fbaf36c..2c03bf7 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -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,