You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-office/libreoffice/files/libreoffice-4.3.5.2-DPI.patch

58 lines
2.0 KiB

Merged upstream commits for bug 523822:
a2d4bd6864e108a11d6ca2b69de5ebce265102dc "Refactor DPI settings validity check"
1964870db4ad1e4334e8fc5050795469dc1fb05e "[PATCH] Fallback DPI detection on X11"
diff -u b/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
--- b/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -120,6 +120,12 @@
return nBits;
}
+// check if the resolution is sane
+static bool sal_ValidDPI(long nDPI)
+{
+ return (nDPI >= 50) && (nDPI <= 500);
+}
+
static bool sal_GetVisualInfo( Display *pDisplay, XID nVID, XVisualInfo &rVI )
{
int nInfos;
@@ -555,7 +561,7 @@
const OString aValStr( pValStr );
const long nDPI = (long) aValStr.toDouble();
// guard against insane resolution
- if( (nDPI >= 50) && (nDPI <= 500) )
+ if( sal_ValidDPI(nDPI) )
{
aResolution_ = Pair( nDPI, nDPI );
bExactResolution = true;
@@ -569,7 +575,25 @@
}
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;