monitor-manager: Apply privacy monitor settings on changes
When both a setting change and a monitor change happens we need to ensure that the monitor settings are applied. This is currently only related to privacy settings, but will in future also handle other monitor parameters such as brightness. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
This commit is contained in:
parent
55469fda78
commit
f96a167aea
@ -229,6 +229,9 @@ struct _MetaMonitorManagerClass
|
|||||||
unsigned short *green,
|
unsigned short *green,
|
||||||
unsigned short *blue);
|
unsigned short *blue);
|
||||||
|
|
||||||
|
gboolean (* set_privacy_screen_enabled) (MetaMonitorManager *manager,
|
||||||
|
gboolean enabled);
|
||||||
|
|
||||||
void (* tiled_monitor_added) (MetaMonitorManager *manager,
|
void (* tiled_monitor_added) (MetaMonitorManager *manager,
|
||||||
MetaMonitor *monitor);
|
MetaMonitor *monitor);
|
||||||
|
|
||||||
|
@ -1006,6 +1006,95 @@ experimental_features_changed (MetaSettings *settings,
|
|||||||
meta_settings_update_ui_scaling_factor (settings);
|
meta_settings_update_ui_scaling_factor (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
meta_monitor_manager_real_set_privacy_screen_enabled (MetaMonitorManager *manager,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = manager->monitors; l; l = l->next)
|
||||||
|
{
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
MetaMonitor *monitor = l->data;
|
||||||
|
|
||||||
|
if (!meta_monitor_set_privacy_screen_enabled (monitor, enabled, &error))
|
||||||
|
{
|
||||||
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_warning ("Failed to set privacy screen setting on monitor %s: %s",
|
||||||
|
meta_monitor_get_display_name (monitor), error->message);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
set_privacy_screen_enabled (MetaMonitorManager *manager,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
MetaMonitorManagerClass *manager_class =
|
||||||
|
META_MONITOR_MANAGER_GET_CLASS (manager);
|
||||||
|
|
||||||
|
return manager_class->set_privacy_screen_enabled (manager, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ensure_monitors_settings (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
MetaSettings *settings = meta_backend_get_settings (manager->backend);
|
||||||
|
|
||||||
|
return set_privacy_screen_enabled (
|
||||||
|
manager, meta_settings_is_privacy_screen_enabled (settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
static MetaPrivacyScreenState
|
||||||
|
get_global_privacy_screen_state (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
MetaPrivacyScreenState global_state = META_PRIVACY_SCREEN_UNAVAILABLE;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = manager->monitors; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaMonitor *monitor = l->data;
|
||||||
|
MetaPrivacyScreenState monitor_state;
|
||||||
|
|
||||||
|
if (!meta_monitor_is_active (monitor))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
monitor_state = meta_monitor_get_privacy_screen_state (monitor);
|
||||||
|
if (monitor_state == META_PRIVACY_SCREEN_UNAVAILABLE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (monitor_state & META_PRIVACY_SCREEN_DISABLED)
|
||||||
|
return META_PRIVACY_SCREEN_DISABLED;
|
||||||
|
|
||||||
|
if (monitor_state & META_PRIVACY_SCREEN_ENABLED)
|
||||||
|
global_state = META_PRIVACY_SCREEN_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return global_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_privacy_screen_settings (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
MetaSettings *settings = meta_backend_get_settings (manager->backend);
|
||||||
|
MetaPrivacyScreenState privacy_screen_state =
|
||||||
|
get_global_privacy_screen_state (manager);
|
||||||
|
|
||||||
|
if (privacy_screen_state == META_PRIVACY_SCREEN_UNAVAILABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!!(privacy_screen_state & META_PRIVACY_SCREEN_ENABLED) ==
|
||||||
|
meta_settings_is_privacy_screen_enabled (settings))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ensure_monitors_settings (manager);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_panel_orientation_managed (MetaMonitorManager *manager)
|
update_panel_orientation_managed (MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
@ -1077,6 +1166,8 @@ meta_monitor_manager_setup (MetaMonitorManager *manager)
|
|||||||
|
|
||||||
meta_monitor_manager_ensure_initial_config (manager);
|
meta_monitor_manager_ensure_initial_config (manager);
|
||||||
|
|
||||||
|
apply_privacy_screen_settings (manager);
|
||||||
|
|
||||||
manager->in_init = FALSE;
|
manager->in_init = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,6 +1185,11 @@ meta_monitor_manager_constructed (GObject *object)
|
|||||||
G_CALLBACK (experimental_features_changed),
|
G_CALLBACK (experimental_features_changed),
|
||||||
manager, 0);
|
manager, 0);
|
||||||
|
|
||||||
|
g_signal_connect_object (settings,
|
||||||
|
"privacy-screen-changed",
|
||||||
|
G_CALLBACK (apply_privacy_screen_settings),
|
||||||
|
manager, G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
monitor_manager_setup_dbus_config_handlers (manager);
|
monitor_manager_setup_dbus_config_handlers (manager);
|
||||||
|
|
||||||
g_signal_connect_object (manager->display_config, "notify::power-save-mode",
|
g_signal_connect_object (manager->display_config, "notify::power-save-mode",
|
||||||
@ -1223,6 +1319,8 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
|||||||
|
|
||||||
klass->read_edid = meta_monitor_manager_real_read_edid;
|
klass->read_edid = meta_monitor_manager_real_read_edid;
|
||||||
klass->read_current_state = meta_monitor_manager_real_read_current_state;
|
klass->read_current_state = meta_monitor_manager_real_read_current_state;
|
||||||
|
klass->set_privacy_screen_enabled =
|
||||||
|
meta_monitor_manager_real_set_privacy_screen_enabled;
|
||||||
|
|
||||||
signals[MONITORS_CHANGED] =
|
signals[MONITORS_CHANGED] =
|
||||||
g_signal_new ("monitors-changed",
|
g_signal_new ("monitors-changed",
|
||||||
@ -3356,6 +3454,8 @@ meta_monitor_manager_rebuild (MetaMonitorManager *manager,
|
|||||||
|
|
||||||
meta_monitor_manager_update_logical_state (manager, config);
|
meta_monitor_manager_update_logical_state (manager, config);
|
||||||
|
|
||||||
|
ensure_monitors_settings (manager);
|
||||||
|
|
||||||
meta_monitor_manager_notify_monitors_changed (manager);
|
meta_monitor_manager_notify_monitors_changed (manager);
|
||||||
|
|
||||||
g_list_free_full (old_logical_monitors, g_object_unref);
|
g_list_free_full (old_logical_monitors, g_object_unref);
|
||||||
|
Loading…
Reference in New Issue
Block a user