forked from AuroraMiddleware/gtk
inspector: Respect text-scaling-factor value initially
This was pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=774893
This commit is contained in:
parent
593b75fb69
commit
1af817e254
@ -37,6 +37,9 @@
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include "x11/gdkx.h"
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include "wayland/gdkwayland.h"
|
||||
#endif
|
||||
|
||||
#include "gdk/gdk-private.h"
|
||||
|
||||
@ -140,14 +143,46 @@ redraw_everything (void)
|
||||
g_list_free (toplevels);
|
||||
}
|
||||
|
||||
static double
|
||||
get_font_scale (GtkInspectorVisual *vis)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
|
||||
{
|
||||
int dpi_int;
|
||||
|
||||
g_object_get (gtk_settings_get_default (),
|
||||
"gtk-xft-dpi", &dpi_int,
|
||||
NULL);
|
||||
|
||||
return dpi_int / (96.0 * 1024.0);
|
||||
}
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
|
||||
{
|
||||
int dpi_int;
|
||||
|
||||
g_object_get (gtk_settings_get_default (),
|
||||
"gtk-xft-dpi", &dpi_int,
|
||||
NULL);
|
||||
|
||||
return dpi_int / (96.0 * 1024.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static void
|
||||
update_font_scale (GtkInspectorVisual *vis,
|
||||
gdouble factor,
|
||||
gboolean update_adjustment,
|
||||
gboolean update_entry)
|
||||
{
|
||||
g_object_set (gtk_settings_get_default (), "gtk-xft-dpi",
|
||||
(gint)(factor * 96 * 1024), NULL);
|
||||
g_object_set (gtk_settings_get_default (),
|
||||
"gtk-xft-dpi", (gint)(factor * 96 * 1024),
|
||||
NULL);
|
||||
|
||||
if (update_adjustment)
|
||||
gtk_adjustment_set_value (vis->priv->font_scale_adjustment, factor);
|
||||
@ -547,8 +582,10 @@ init_font (GtkInspectorVisual *vis)
|
||||
static void
|
||||
init_font_scale (GtkInspectorVisual *vis)
|
||||
{
|
||||
/* There is no backend agnostic way to get the default value, so use 1.0 */
|
||||
update_font_scale (vis, 1.0, TRUE, TRUE);
|
||||
double scale;
|
||||
|
||||
scale = get_font_scale (vis);
|
||||
update_font_scale (vis, scale, TRUE, TRUE);
|
||||
g_signal_connect (vis->priv->font_scale_adjustment, "value-changed",
|
||||
G_CALLBACK (font_scale_adjustment_changed), vis);
|
||||
g_signal_connect (vis->priv->font_scale_entry, "activate",
|
||||
|
Loading…
Reference in New Issue
Block a user