mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-04 09:40:19 +00:00
Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
inspector: handle differences in DPI between backends See merge request GNOME/gtk!2857
This commit is contained in:
commit
6b475aacd2
@ -52,6 +52,9 @@
|
|||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
#include "wayland/gdkwayland.h"
|
#include "wayland/gdkwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef GDK_WINDOWING_MACOS
|
||||||
|
#include "macos/gdkmacos.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "gdk/gdk-private.h"
|
#include "gdk/gdk-private.h"
|
||||||
|
|
||||||
@ -172,35 +175,28 @@ redraw_everything (void)
|
|||||||
g_list_free (toplevels);
|
g_list_free (toplevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
get_dpi_ratio (GtkInspectorVisual *vis)
|
||||||
|
{
|
||||||
|
#ifdef GDK_WINDOWING_MACOS
|
||||||
|
if (GDK_IS_MACOS_DISPLAY (vis->display))
|
||||||
|
return 72.0 * 1024.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 96.0 * 1024.0;
|
||||||
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
get_font_scale (GtkInspectorVisual *vis)
|
get_font_scale (GtkInspectorVisual *vis)
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_X11
|
double ratio = get_dpi_ratio (vis);
|
||||||
if (GDK_IS_X11_DISPLAY (vis->display))
|
int dpi_int;
|
||||||
{
|
|
||||||
int dpi_int;
|
|
||||||
|
|
||||||
g_object_get (gtk_settings_get_for_display (vis->display),
|
g_object_get (gtk_settings_get_for_display (vis->display),
|
||||||
"gtk-xft-dpi", &dpi_int,
|
"gtk-xft-dpi", &dpi_int,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return dpi_int / (96.0 * 1024.0);
|
return dpi_int / ratio;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
|
||||||
if (GDK_IS_WAYLAND_DISPLAY (vis->display))
|
|
||||||
{
|
|
||||||
int dpi_int;
|
|
||||||
|
|
||||||
g_object_get (gtk_settings_get_for_display (vis->display),
|
|
||||||
"gtk-xft-dpi", &dpi_int,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return dpi_int / (96.0 * 1024.0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -209,8 +205,10 @@ update_font_scale (GtkInspectorVisual *vis,
|
|||||||
gboolean update_adjustment,
|
gboolean update_adjustment,
|
||||||
gboolean update_entry)
|
gboolean update_entry)
|
||||||
{
|
{
|
||||||
|
double ratio = get_dpi_ratio (vis);
|
||||||
|
|
||||||
g_object_set (gtk_settings_get_for_display (vis->display),
|
g_object_set (gtk_settings_get_for_display (vis->display),
|
||||||
"gtk-xft-dpi", (int)(factor * 96 * 1024),
|
"gtk-xft-dpi", (int)(factor * ratio),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (update_adjustment)
|
if (update_adjustment)
|
||||||
|
Loading…
Reference in New Issue
Block a user