diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-07-13 16:12:11 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-07-17 08:50:38 +0900 |
commit | 2a19bb85cbe83aa031871a3689b9ff03629da548 (patch) | |
tree | 9494344a7d2db692f98b68448b97ee508789ea00 | |
parent | 07ff2841ccf6d4f93941838305248f7048fec803 (diff) |
GTK3 HiDPI: disable window scaling and get display DPI via GTK3
Change-Id: I66b92146757352408a331f9e23289839f443ff79
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/gtk/app/gtkdata.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 18 |
3 files changed, 38 insertions, 0 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 80de62b40a3b..b533cb44ed03 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 df4470ba09ba..6e0f711eece0 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 9e054324b5aa..0e3b0f627887 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -2100,4 +2100,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: */ |