From e3edc65a604e02dbb3d9c8f8a66b59e73b0ce09f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 27 Sep 2013 01:01:28 +0300 Subject: [PATCH] Try to guess the primary monitor if xrandr isn't making any sense --- source/graphics/x11/display.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 2.45.2