-
Notifications
You must be signed in to change notification settings - Fork 14
Description
The HiDPI calculation assumes the physical size of the monitor corresponds to the display width and height. If, however, you have a vertically rotated monitor then the physical size doesn't change, but you need to swap mm_width and mm_height around. The attached patch checks the crcInfo->rotation to detect the monitor orientation.
Here's the debugging output with the patch applied:
Output: DisplayPort-2
Resolution: 2560x1440 pixels
Physical size: 23.50x13.23 inches (horizontal orientation)
DPI: 108.92 x 108.86
Output: DisplayPort-3
Resolution: 1440x2560 pixels
Physical size: 13.23x23.50 inches (vertical orientation)
DPI: 108.86 x 108.92
Without the patch, the vertical monitor outputs:
DPI: 61.27 x 193.52
and so triggers the HiDPI setting of dpiMult=2;
$ git diff
diff --git a/src/xv.c b/src/xv.c
index 4496495..05636fa 100644
--- a/src/xv.c
+++ b/src/xv.c
@@ -447,8 +447,9 @@ int main(int argc, char **argv)
crtcInfo = XRRGetCrtcInfo(theDisp, screenRes, outputInfo->crtc);
/* Physical size in inches */
- double width_in = outputInfo->mm_width / 25.4;
- double height_in = outputInfo->mm_height / 25.4;
+ int horiz = crtcInfo->rotation & (RR_Rotate_0|RR_Rotate_180);
+ double width_in = (horiz ? outputInfo->mm_width : outputInfo->mm_height) / 25.4;
+ double height_in = (horiz ? outputInfo->mm_height : outputInfo->mm_width) / 25.4;
/* Screen resolution in pixels */
int width_px = crtcInfo->width;
@@ -464,7 +465,7 @@ int main(int argc, char **argv)
/* Print the DPI values */
fprintf(stderr, "Output: %s\n", outputInfo->name);
fprintf(stderr, "Resolution: %dx%d pixels\n", width_px, height_px);
- fprintf(stderr, "Physical size: %.2fx%.2f inches\n", width_in, height_in);
+ fprintf(stderr, "Physical size: %.2fx%.2f inches (%s orientation)\n", width_in, height_in, horiz ? "horizontal" : "vertical");
fprintf(stderr, "DPI: %.2f x %.2f\n", dpi_x, dpi_y);
#endif