]> git.tdb.fi Git - libs/gui.git/commitdiff
Try to guess the primary monitor if xrandr isn't making any sense
authorMikko Rasa <tdb@tdb.fi>
Thu, 26 Sep 2013 22:01:28 +0000 (01:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 26 Sep 2013 22:01:28 +0000 (01:01 +0300)
source/graphics/x11/display.cpp

index 368b67cecdc5b6953db9e113664e16f30bed9889..6f677c3048d7a7ee96b1db5f585847490503f7f8 100644 (file)
@@ -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<Monitor>::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