[PATCH 4/4] HACK: xfree86: modes: Recompute DPI when the screen size changes
Thierry Reding
thierry.reding at avionic-design.de
Thu Nov 8 05:50:32 PST 2012
The X server start up with the assumption that the display has 96 DPI
unless configured otherwise. However under the proper circumstances, it
can compute the correct value from the information provided by output
resources.
This commit adds this computation directly in xf86RandR12ScreenSetSize()
because it is the only place where enough information is available. The
xf86SetDpi() helper cannot be reused because it is based on the
assumption that the DPI is either configured (on the command-line or via
the configuration file) or computes it based on EDID data only.
Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
---
hw/xfree86/modes/xf86RandR12.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index e18f357..dfbeb8d 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -723,6 +723,21 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
xf86SetViewport(pScreen, pScreen->width - 1, pScreen->height - 1);
xf86SetViewport(pScreen, 0, 0);
+ /* HACK: recompute DPI */
+ if (mmWidth > 0 && mmHeight > 0) {
+ pScrn->xDpi = (width * 254) / (mmWidth * 10);
+ pScrn->yDpi = (height * 254) / (mmHeight * 10);
+
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DPI set to (%d, %d)\n",
+ pScrn->xDpi, pScrn->yDpi);
+ }
+
finish:
update_desktop_dimensions();
--
1.8.0
More information about the xorg-devel
mailing list