From: Mikko Rasa Date: Thu, 26 Sep 2013 22:01:28 +0000 (+0300) Subject: Try to guess the primary monitor if xrandr isn't making any sense X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e3edc65a604e02dbb3d9c8f8a66b59e73b0ce09f;p=libs%2Fgui.git Try to guess the primary monitor if xrandr isn't making any sense --- diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index 368b67c..6f677c3 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -175,6 +175,22 @@ Display::Display(const string &disp_name): prev_enabled->next_right = &*i; prev_enabled = &*i; } + + if(!primary_monitor || !primary_monitor->desktop_mode) + { + // XRandR didn't give a sensible primary monitor. Try to guess one. + unsigned largest = 0; + for(list::iterator i=monitors.begin(); i!=monitors.end(); ++i) + if(i->desktop_mode) + { + unsigned size = i->desktop_mode->width*i->desktop_mode->height; + if(size>largest) + { + largest = size; + primary_monitor = &*i; + } + } + } } } #endif