diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index e5acc1c4e..08ba04fd4 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -106,6 +106,8 @@ typedef enum _MetaExperimentalFeature void meta_init_backend (GType backend_gtype); +void meta_backend_display_opened (MetaBackend *backend); + ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend); MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend, @@ -172,4 +174,6 @@ void meta_backend_notify_keymap_changed (MetaBackend *backend); void meta_backend_notify_keymap_layout_group_changed (MetaBackend *backend, unsigned int locked_group); +void meta_backend_notify_ui_scaling_factor_changed (MetaBackend *backend); + #endif /* META_BACKEND_PRIVATE_H */ diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index f33e30088..7281a371d 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -43,6 +43,7 @@ #include "backends/meta-idle-monitor-private.h" #include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-dummy.h" +#include "ui/theme-private.h" enum { @@ -50,6 +51,7 @@ enum KEYMAP_LAYOUT_GROUP_CHANGED, LAST_DEVICE_CHANGED, EXPERIMENTAL_FEATURES_CHANGED, + UI_SCALING_FACTOR_CHANGED, N_SIGNALS }; @@ -556,6 +558,13 @@ meta_backend_class_init (MetaBackendClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + signals[UI_SCALING_FACTOR_CHANGED] = + g_signal_new ("ui-scaling-factor-changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); } static gboolean @@ -965,6 +974,28 @@ meta_clutter_init (void) meta_backend_post_init (_backend); } +static void +xft_dpi_changed (GtkSettings *settings, + GParamSpec *pspec, + MetaBackend *backend) +{ + meta_backend_notify_ui_scaling_factor_changed (backend); +} + +void +meta_backend_display_opened (MetaBackend *backend) +{ + /* + * gdk-window-scaling-factor is not exported to gtk-settings + * because it is handled inside gdk, so we use gtk-xft-dpi instead + * which also changes when the scale factor changes. + * + * TODO: Don't rely on GtkSettings for this + */ + g_signal_connect (gtk_settings_get_default (), "notify::gtk-xft-dpi", + G_CALLBACK (xft_dpi_changed), backend); +} + gboolean meta_is_stage_views_enabled (void) { @@ -1034,3 +1065,18 @@ meta_backend_notify_keymap_layout_group_changed (MetaBackend *backend, g_signal_emit (backend, signals[KEYMAP_LAYOUT_GROUP_CHANGED], 0, locked_group); } + +int +meta_backend_get_ui_scaling_factor (MetaBackend *backend) +{ + if (meta_is_stage_views_scaled ()) + return 1; + else + return meta_theme_get_window_scaling_factor (); +} + +void +meta_backend_notify_ui_scaling_factor_changed (MetaBackend *backend) +{ + g_signal_emit (backend, signals[UI_SCALING_FACTOR_CHANGED], 0); +} diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 85441f76e..7bd9afa71 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -537,6 +537,7 @@ experimental_features_changed (MetaBackend *backend, skeleton, is_config_manager_enabled); meta_monitor_manager_on_hotplug (manager); + meta_backend_notify_ui_scaling_factor_changed (backend); } } diff --git a/src/core/display.c b/src/core/display.c index 64c41d110..377954314 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -963,6 +963,8 @@ meta_display_open (void) meta_screen_init_workspaces (screen); + meta_backend_display_opened (meta_get_backend ()); + enable_compositor (display); meta_screen_create_guard_window (screen); diff --git a/src/meta/meta-backend.h b/src/meta/meta-backend.h index 152cfc116..3010fa5d3 100644 --- a/src/meta/meta-backend.h +++ b/src/meta/meta-backend.h @@ -48,6 +48,8 @@ void meta_backend_lock_layout_group (MetaBackend *backend, void meta_backend_set_numlock (MetaBackend *backend, gboolean numlock_state); +int meta_backend_get_ui_scaling_factor (MetaBackend *backend); + ClutterActor *meta_backend_get_stage (MetaBackend *backend); MetaDnd *meta_backend_get_dnd (MetaBackend *backend);