Kaydet (Commit) 2a19bb85 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

GTK3 HiDPI: disable window scaling and get display DPI via GTK3

Change-Id: I66b92146757352408a331f9e23289839f443ff79
üst 07ff2841
...@@ -61,6 +61,7 @@ public: ...@@ -61,6 +61,7 @@ public:
cairo_t* getCairoContext() const; cairo_t* getCairoContext() const;
virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) SAL_OVERRIDE;
private: private:
GtkWidget *mpWindow; GtkWidget *mpWindow;
static GtkStyleContext *mpButtonStyle; static GtkStyleContext *mpButtonStyle;
......
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
#include <vcl/svapp.hxx> #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; using namespace vcl_sal;
/*************************************************************** /***************************************************************
...@@ -87,6 +93,19 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) : ...@@ -87,6 +93,19 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
#else #else
m_bX11Display = true; m_bX11Display = true;
#endif #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() GtkSalDisplay::~GtkSalDisplay()
......
...@@ -2100,4 +2100,22 @@ cairo_t* GtkSalGraphics::getCairoContext() const ...@@ -2100,4 +2100,22 @@ cairo_t* GtkSalGraphics::getCairoContext() const
return mpFrame->getCairoContext(); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment