[Libreoffice-commits] core.git: vcl/unx

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Wed Sep 10 04:24:24 PDT 2014


 vcl/unx/generic/app/saldisp.cxx |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 1964870db4ad1e4334e8fc5050795469dc1fb05e
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date:   Tue Sep 9 21:34:45 2014 +0200

    Fallback DPI detection on X11
    
    When the Xft.dpi setting is not found, and if only one screen is
    available, fall back to detecting the screen DPI from the reported
    resolution and monitor size.
    
    Change-Id: I1481d94b5dc4072c1f8da4659a221dfc7971080b
    Reviewed-on: https://gerrit.libreoffice.org/11377
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 7c97a24..ee6aad7 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -569,7 +569,25 @@ void SalDisplay::Init()
     }
     if( bExactResolution == false )
     {
-        aResolution_ = Pair( 96, 96 );
+        /*  if Xft.dpi is not set, try and find the DPI from the
+         *  reported screen sizes and resolution. If there are multiple
+         *  screens, just fall back to the default 96x96
+         */
+        long xDPI = 96;
+        long yDPI = 96;
+        if (m_aScreens.size() == 1) {
+            xDPI = (long)round(DisplayWidth(pDisp_, 0)*25.4/DisplayWidthMM(pDisp_, 0));
+            yDPI = (long)round(DisplayHeight(pDisp_, 0)*25.4/DisplayHeightMM(pDisp_, 0));
+            // if either is invalid set it equal to the other
+            if (!sal_ValidDPI(xDPI) && sal_ValidDPI(yDPI))
+                xDPI = yDPI;
+            if (!sal_ValidDPI(yDPI) && sal_ValidDPI(xDPI))
+                yDPI = xDPI;
+            // if both are invalid, reset them to the default
+            if (!sal_ValidDPI(xDPI) && !sal_ValidDPI(yDPI))
+                xDPI = yDPI = 96;
+        }
+        aResolution_ = Pair( xDPI, yDPI );
     }
 
     nMaxRequestSize_    = XExtendedMaxRequestSize( pDisp_ ) * 4;


More information about the Libreoffice-commits mailing list