[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - vcl/inc vcl/unx

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Aug 7 00:41:59 PDT 2015


 vcl/inc/unx/gtk/gtkgdi.hxx                    |    1 +
 vcl/unx/gtk/app/gtkdata.cxx                   |   19 +++++++++++++++++++
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |   18 ++++++++++++++++++
 3 files changed, 38 insertions(+)

New commits:
commit c0b75759ace5d0aca033504bc1cb2179fcce47d1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Jul 13 16:12:11 2015 +0900

    GTK3 HiDPI: disable window scaling and get display DPI via GTK3
    
    Change-Id: I66b92146757352408a331f9e23289839f443ff79
    (cherry picked from commit 2a19bb85cbe83aa031871a3689b9ff03629da548)
    Reviewed-on: https://gerrit.libreoffice.org/17553
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 80de62b..b533cb4 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -61,6 +61,7 @@ public:
 
     cairo_t* getCairoContext() const;
 
+    virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) SAL_OVERRIDE;
 private:
     GtkWidget       *mpWindow;
     static GtkStyleContext *mpButtonStyle;
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index df1546a..2d8e26c 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -46,6 +46,12 @@
 
 #include <vcl/svapp.hxx>
 
+#if GTK_CHECK_VERSION(3,10,0)
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+#endif
+
 using namespace vcl_sal;
 
 /***************************************************************
@@ -87,6 +93,19 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
 #else
     m_bX11Display = true;
 #endif
+
+#if GTK_CHECK_VERSION(3,10,0)
+#ifdef GDK_WINDOWING_X11
+    if (m_bX11Display)
+    {
+        if (!getenv("GDK_SCALE"))
+        {
+            gdk_x11_display_set_window_scale(m_pGdkDisplay, 1);
+        }
+    }
+#endif
+#endif
+
 }
 
 GtkSalDisplay::~GtkSalDisplay()
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 5c71040..402c17d 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -2097,4 +2097,22 @@ cairo_t* GtkSalGraphics::getCairoContext() const
     return mpFrame->getCairoContext();
 }
 
+void GtkSalGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY)
+{
+    GdkScreen* pScreen = gtk_widget_get_screen(mpWindow);
+    double fResolution = -1.0;
+    g_object_get(pScreen, "resolution", &fResolution, nullptr);
+
+    int nScaleFactor = 1;
+
+#if GTK_CHECK_VERSION(3, 10, 0)
+    nScaleFactor = gdk_window_get_scale_factor(widget_get_window(mpWindow));
+#endif
+
+    if (fResolution > 0.0)
+        rDPIX = rDPIY = sal_Int32(fResolution * nScaleFactor);
+    else
+        rDPIX = rDPIY = 96;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list