X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fx11%2Fdisplay.cpp;h=634e91096f38cf7ce78a4c47e177e3bab8c0c7e8;hb=5089eb26984313f3a28ca7d941de97c509a45281;hp=15c69a9c604495132718adb1d526408f4a209441;hpb=5b06f17bd09b4aaaa295f167566ca52f70db5c27;p=libs%2Fgui.git diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index 15c69a9..634e910 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -1,4 +1,3 @@ -#include #include #ifdef WITH_XRANDR #include @@ -96,6 +95,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 +108,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) @@ -123,6 +123,7 @@ Display::Display(const string &disp_name): monitors.push_back(Monitor()); Monitor &monitor = monitors.back(); monitor.index = monitors.size()-1; + monitor.name.assign(output->name, output->nameLen); priv->monitors.push_back(res->outputs[i]); if(crtc) @@ -147,8 +148,8 @@ Display::Display(const string &disp_name): VideoMode mode(info->width, info->height); mode.index = modes.size(); mode.monitor = &monitor; - mode.rate = info->dotClock/(info->hTotal*info->vTotal); - if(find_mode(mode)) + mode.rate = static_cast(info->dotClock)/(info->hTotal*info->vTotal); + if(find_mode(mode, 0.01f)) continue; modes.push_back(mode); @@ -218,8 +219,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);