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

New commits:
commit 1964870db4ad1e4334e8fc5050795469dc1fb05e
Author: Giuseppe Bilotta <giuseppe.bilo...@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.sherloc...@gmail.com>
    Tested-by: Chris Sherlock <chris.sherloc...@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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to