diff --git a/src/screen_xywh.cxx b/src/screen_xywh.cxx index 7b373819a..410e4eb9e 100644 --- a/src/screen_xywh.cxx +++ b/src/screen_xywh.cxx @@ -155,11 +155,15 @@ static void screen_init() { 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 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;