Author: AlbrechtS
Date: 2011-05-23 12:16:16 -0700 (Mon, 23 May 2011)
New Revision: 8727
Log:
src/screen_xywh.cxx: Fix STR #2637, part 1.
Fix array bounds error when Xinerama and Xlib disagree about number of screens.
Fix setting vertical resolution (dpi) of different monitors.


Modified:
   branches/branch-1.3/src/screen_xywh.cxx

Modified: branches/branch-1.3/src/screen_xywh.cxx
===================================================================
--- branches/branch-1.3/src/screen_xywh.cxx     2011-05-23 18:32:47 UTC (rev 
8726)
+++ branches/branch-1.3/src/screen_xywh.cxx     2011-05-23 19:16:16 UTC (rev 
8727)
@@ -155,11 +155,15 @@
   if (XineramaIsActive(fl_display)) {
     screens = XineramaQueryScreens(fl_display, &num_screens);
     int i;
+    // Xlib and Xinerama may disagree on the screen count. Sigh...
+    // Use the minimum of the reported counts.
+    // Use the previous screen's info for non-existent ones.
+    int sc = ScreenCount(fl_display); // Xlib screen count
     for (i=0; i<num_screens; i++) {
-      int mm = DisplayWidthMM(fl_display, i);
-      dpi[i][0] = mm ? screens[i].width*25.4f/mm : 0.0f;
-      mm = DisplayHeightMM(fl_display, fl_screen);
-      dpi[i][1] = mm ? screens[i].height*25.4f/mm : dpi[i][0];
+      int mm = (i < sc) ? DisplayWidthMM(fl_display, i) : 0;
+      dpi[i][0] = mm ? screens[i].width*25.4f/mm : (i > 0) ? dpi[i-1][0] : 
0.0f;
+      mm = (i < sc) ? DisplayHeightMM(fl_display, i) : 0;
+      dpi[i][1] = mm ? screens[i].height*25.4f/mm : (i > 0) ? dpi[i-1][1] : 
0.0f;
     }
   } else { // ! XineramaIsActive()
     num_screens = 1;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to