backend: Add API to get UI scaling
The UI scaling depends on whether the framebuffers are scaled. Enable the caller to determine the what scale its UI should be drawn in, in relation to the stage coordinate space by calling this function. A new singal "ui-scaling-factor-changed" is added in order to liston for for changes. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
20fcb88632
commit
1bdadfa3e1
5 changed files with 55 additions and 0 deletions
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue