소스 검색

X11: Assume 96 DPI if RandR monitor size is zero

This falls back to calculating the monitor physical size from the
current resolution and the default X11 DPI when the physical size
returned by RandR is zero.

(cherry picked from commit e96dc5d2199032d565b55c4177820ab28b1d67c9)
Camilla Löwy 5 년 전
부모
커밋
7c33fb22fd
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      src/x11_monitor.c

+ 10 - 0
src/x11_monitor.c

@@ -161,6 +161,16 @@ void _glfwPollMonitorsX11(void)
                 heightMM = oi->mm_height;
                 heightMM = oi->mm_height;
             }
             }
 
 
+            if (widthMM <= 0 || heightMM <= 0)
+            {
+                // HACK: If RandR does not provide a physical size, assume the
+                //       X11 default 96 DPI and calcuate from the CRTC viewport
+                // NOTE: These members are affected by rotation, unlike the mode
+                //       info and output info members
+                widthMM  = (int) (ci->width * 25.4f / 96.f);
+                heightMM = (int) (ci->height * 25.4f / 96.f);
+            }
+
             _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
             _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
             monitor->x11.output = sr->outputs[i];
             monitor->x11.output = sr->outputs[i];
             monitor->x11.crtc   = oi->crtc;
             monitor->x11.crtc   = oi->crtc;