monitor-manager/kms: Move global ui scaling setting to MetaSettings
It'll be used elsewhere, so shouldn't be in MetaMonitorManagerKms. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
2718699ccc
commit
0bc312a54b
@ -44,6 +44,9 @@ void meta_settings_post_init (MetaSettings *settings);
|
||||
|
||||
void meta_settings_update_ui_scaling_factor (MetaSettings *settings);
|
||||
|
||||
gboolean meta_settings_get_global_scaling_factor (MetaSettings *settings,
|
||||
int *scaing_factor);
|
||||
|
||||
gboolean meta_settings_is_experimental_feature_enabled (MetaSettings *settings,
|
||||
MetaExperimentalFeature feature);
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
enum
|
||||
{
|
||||
UI_SCALING_FACTOR_CHANGED,
|
||||
GLOBAL_SCALING_FACTOR_CHANGED,
|
||||
EXPERIMENTAL_FEATURES_CHANGED,
|
||||
|
||||
N_SIGNALS
|
||||
@ -46,9 +47,11 @@ struct _MetaSettings
|
||||
|
||||
MetaBackend *backend;
|
||||
|
||||
GSettings *interface_settings;
|
||||
GSettings *mutter_settings;
|
||||
|
||||
int ui_scaling_factor;
|
||||
int global_scaling_factor;
|
||||
|
||||
MetaExperimentalFeature experimental_features;
|
||||
gboolean experimental_features_overridden;
|
||||
@ -164,6 +167,49 @@ meta_settings_get_ui_scaling_factor (MetaSettings *settings)
|
||||
return settings->ui_scaling_factor;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_global_scaling_factor (MetaSettings *settings)
|
||||
{
|
||||
int global_scaling_factor;
|
||||
|
||||
global_scaling_factor =
|
||||
(int) g_settings_get_uint (settings->interface_settings,
|
||||
"scaling-factor");
|
||||
|
||||
if (settings->global_scaling_factor != global_scaling_factor)
|
||||
{
|
||||
settings->global_scaling_factor = global_scaling_factor;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_settings_get_global_scaling_factor (MetaSettings *settings,
|
||||
int *out_scaling_factor)
|
||||
{
|
||||
if (settings->global_scaling_factor == 0)
|
||||
return FALSE;
|
||||
|
||||
*out_scaling_factor = settings->global_scaling_factor;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
interface_settings_changed (GSettings *interface_settings,
|
||||
const char *key,
|
||||
MetaSettings *settings)
|
||||
{
|
||||
if (g_str_equal (key, "scaling-factor"))
|
||||
{
|
||||
if (update_global_scaling_factor (settings))
|
||||
g_signal_emit (settings, signals[GLOBAL_SCALING_FACTOR_CHANGED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_settings_is_experimental_feature_enabled (MetaSettings *settings,
|
||||
MetaExperimentalFeature feature)
|
||||
@ -274,6 +320,7 @@ meta_settings_dispose (GObject *object)
|
||||
MetaSettings *settings = META_SETTINGS (object);
|
||||
|
||||
g_clear_object (&settings->mutter_settings);
|
||||
g_clear_object (&settings->interface_settings);
|
||||
|
||||
G_OBJECT_CLASS (meta_settings_parent_class)->dispose (object);
|
||||
}
|
||||
@ -281,11 +328,20 @@ meta_settings_dispose (GObject *object)
|
||||
static void
|
||||
meta_settings_init (MetaSettings *settings)
|
||||
{
|
||||
settings->interface_settings = g_settings_new ("org.gnome.desktop.interface");
|
||||
g_signal_connect (settings->interface_settings, "changed",
|
||||
G_CALLBACK (interface_settings_changed),
|
||||
settings);
|
||||
settings->mutter_settings = g_settings_new ("org.gnome.mutter");
|
||||
g_signal_connect (settings->mutter_settings, "changed",
|
||||
G_CALLBACK (mutter_settings_changed),
|
||||
settings);
|
||||
|
||||
/* Chain up inter-dependent settings. */
|
||||
g_signal_connect (settings, "global-scaling-factor-changed",
|
||||
G_CALLBACK (meta_settings_update_ui_scaling_factor), NULL);
|
||||
|
||||
update_global_scaling_factor (settings);
|
||||
update_experimental_features (settings);
|
||||
}
|
||||
|
||||
@ -310,6 +366,14 @@ meta_settings_class_init (MetaSettingsClass *klass)
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[GLOBAL_SCALING_FACTOR_CHANGED] =
|
||||
g_signal_new ("global-scaling-factor-changed",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[EXPERIMENTAL_FEATURES_CHANGED] =
|
||||
g_signal_new ("experimental-features-changed",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "meta-monitor-config-manager.h"
|
||||
#include "meta-backend-private.h"
|
||||
#include "meta-renderer-native.h"
|
||||
#include "backends/meta-input-settings-private.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -115,8 +116,6 @@ struct _MetaMonitorManagerKms
|
||||
GUdevClient *udev;
|
||||
guint uevent_handler_id;
|
||||
|
||||
GSettings *desktop_settings;
|
||||
|
||||
gboolean page_flips_not_supported;
|
||||
|
||||
int max_buffer_width;
|
||||
@ -1639,8 +1638,6 @@ meta_monitor_manager_kms_init (MetaMonitorManagerKms *manager_kms)
|
||||
G_IO_IN | G_IO_ERR);
|
||||
manager_kms->source->manager_kms = manager_kms;
|
||||
g_source_attach (source, NULL);
|
||||
|
||||
manager_kms->desktop_settings = g_settings_new ("org.gnome.desktop.interface");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1908,12 +1905,11 @@ meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manag
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode)
|
||||
{
|
||||
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (manager);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
int global_scale;
|
||||
|
||||
global_scale = g_settings_get_uint (manager_kms->desktop_settings,
|
||||
"scaling-factor");
|
||||
if (global_scale > 0)
|
||||
if (meta_settings_get_global_scaling_factor (settings, &global_scale))
|
||||
return global_scale;
|
||||
else
|
||||
return compute_scale (monitor, monitor_mode);
|
||||
@ -1996,7 +1992,6 @@ meta_monitor_manager_kms_dispose (GObject *object)
|
||||
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (object);
|
||||
|
||||
g_clear_object (&manager_kms->udev);
|
||||
g_clear_object (&manager_kms->desktop_settings);
|
||||
|
||||
G_OBJECT_CLASS (meta_monitor_manager_kms_parent_class)->dispose (object);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user