mirror of
https://github.com/brl/mutter.git
synced 2025-01-23 01:48:55 +00:00
monitor-manager: Hook up config manager to display config confirmation
Make it possible to confirm or cancel the new configuration also when the new API is used. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
740436ab4d
commit
95d0117784
@ -36,6 +36,7 @@ struct _MetaMonitorConfigManager
|
||||
MetaMonitorConfigStore *config_store;
|
||||
|
||||
MetaMonitorsConfig *current_config;
|
||||
MetaMonitorsConfig *previous_config;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaMonitorConfigManager, meta_monitor_config_manager,
|
||||
@ -677,15 +678,32 @@ void
|
||||
meta_monitor_config_manager_set_current (MetaMonitorConfigManager *config_manager,
|
||||
MetaMonitorsConfig *config)
|
||||
{
|
||||
g_set_object (&config_manager->previous_config,
|
||||
config_manager->current_config);
|
||||
g_set_object (&config_manager->current_config, config);
|
||||
}
|
||||
|
||||
void
|
||||
meta_monitor_config_manager_save_current (MetaMonitorConfigManager *config_manager)
|
||||
{
|
||||
g_return_if_fail (config_manager->current_config);
|
||||
|
||||
meta_monitor_config_store_add (config_manager->config_store,
|
||||
config_manager->current_config);
|
||||
}
|
||||
|
||||
MetaMonitorsConfig *
|
||||
meta_monitor_config_manager_get_current (MetaMonitorConfigManager *config_manager)
|
||||
{
|
||||
return config_manager->current_config;
|
||||
}
|
||||
|
||||
MetaMonitorsConfig *
|
||||
meta_monitor_config_manager_get_previous (MetaMonitorConfigManager *config_manager)
|
||||
{
|
||||
return config_manager->previous_config;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_config_manager_dispose (GObject *object)
|
||||
{
|
||||
@ -693,6 +711,7 @@ meta_monitor_config_manager_dispose (GObject *object)
|
||||
META_MONITOR_CONFIG_MANAGER (object);
|
||||
|
||||
g_clear_object (&config_manager->current_config);
|
||||
g_clear_object (&config_manager->previous_config);
|
||||
|
||||
G_OBJECT_CLASS (meta_monitor_config_manager_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -88,6 +88,10 @@ void meta_monitor_config_manager_set_current (MetaMonitorConfigManager *config_m
|
||||
|
||||
MetaMonitorsConfig * meta_monitor_config_manager_get_current (MetaMonitorConfigManager *config_manager);
|
||||
|
||||
MetaMonitorsConfig * meta_monitor_config_manager_get_previous (MetaMonitorConfigManager *config_manager);
|
||||
|
||||
void meta_monitor_config_manager_save_current (MetaMonitorConfigManager *config_manager);
|
||||
|
||||
MetaMonitorsConfig * meta_monitors_config_new (GList *logical_monitor_configs,
|
||||
MetaLogicalMonitorLayoutMode layout_mode);
|
||||
|
||||
|
@ -260,6 +260,12 @@ struct _MetaOutputInfo
|
||||
gboolean is_underscanning;
|
||||
};
|
||||
|
||||
typedef enum _MetaMonitorConfigSystem
|
||||
{
|
||||
META_MONITOR_CONFIG_SYSTEM_LEGACY,
|
||||
META_MONITOR_CONFIG_SYSTEM_MANAGER
|
||||
} MetaMonitorConfigSystem;
|
||||
|
||||
#define META_TYPE_MONITOR_MANAGER (meta_monitor_manager_get_type ())
|
||||
#define META_MONITOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_MANAGER, MetaMonitorManager))
|
||||
#define META_MONITOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_MANAGER, MetaMonitorManagerClass))
|
||||
@ -308,7 +314,9 @@ struct _MetaMonitorManager
|
||||
|
||||
int dbus_name_id;
|
||||
|
||||
MetaMonitorConfigSystem pending_persistent_system;
|
||||
int persistent_timeout_id;
|
||||
|
||||
MetaMonitorConfig *legacy_config;
|
||||
|
||||
MetaMonitorConfigManager *config_manager;
|
||||
|
@ -1047,17 +1047,81 @@ legacy_restore_previous_config (MetaMonitorManager *manager)
|
||||
meta_monitor_config_restore_previous (manager->legacy_config, manager);
|
||||
}
|
||||
|
||||
static void
|
||||
restore_previous_config (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaMonitorsConfig *previous_config;
|
||||
GError *error = NULL;
|
||||
|
||||
previous_config =
|
||||
meta_monitor_config_manager_get_previous (manager->config_manager);
|
||||
|
||||
if (previous_config)
|
||||
{
|
||||
MetaMonitorsConfigMethod method;
|
||||
|
||||
method = META_MONITORS_CONFIG_METHOD_TEMPORARY;
|
||||
g_object_ref (previous_config);
|
||||
if (meta_monitor_manager_apply_monitors_config (manager,
|
||||
previous_config,
|
||||
method,
|
||||
&error))
|
||||
{
|
||||
g_object_unref (previous_config);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_unref (previous_config);
|
||||
g_warning ("Failed to restore previous configuration: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
meta_monitor_manager_ensure_configured (manager);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
save_config_timeout (gpointer user_data)
|
||||
{
|
||||
MetaMonitorManager *manager = user_data;
|
||||
|
||||
legacy_restore_previous_config (manager);
|
||||
switch (manager->pending_persistent_system)
|
||||
{
|
||||
case META_MONITOR_CONFIG_SYSTEM_LEGACY:
|
||||
legacy_restore_previous_config (manager);
|
||||
break;
|
||||
case META_MONITOR_CONFIG_SYSTEM_MANAGER:
|
||||
restore_previous_config (manager);
|
||||
break;
|
||||
}
|
||||
|
||||
manager->persistent_timeout_id = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_persistent_confirmation (MetaMonitorManager *manager)
|
||||
{
|
||||
g_source_remove (manager->persistent_timeout_id);
|
||||
manager->persistent_timeout_id = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
request_persistent_confirmation (MetaMonitorManager *manager,
|
||||
MetaMonitorConfigSystem system)
|
||||
{
|
||||
manager->pending_persistent_system = system;
|
||||
manager->persistent_timeout_id = g_timeout_add_seconds (20,
|
||||
save_config_timeout,
|
||||
manager);
|
||||
g_source_set_name_by_id (manager->persistent_timeout_id,
|
||||
"[mutter] save_config_timeout");
|
||||
|
||||
g_signal_emit (manager, signals[CONFIRM_DISPLAY_CHANGE], 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
@ -1276,10 +1340,7 @@ meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig *
|
||||
don't save it, but also don't queue for restoring it.
|
||||
*/
|
||||
if (manager->persistent_timeout_id && persistent)
|
||||
{
|
||||
g_source_remove (manager->persistent_timeout_id);
|
||||
manager->persistent_timeout_id = 0;
|
||||
}
|
||||
cancel_persistent_confirmation (manager);
|
||||
|
||||
meta_monitor_manager_apply_configuration (manager,
|
||||
(MetaCrtcInfo**)crtc_infos->pdata,
|
||||
@ -1298,11 +1359,8 @@ meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig *
|
||||
*/
|
||||
meta_monitor_config_update_current (manager->legacy_config, manager);
|
||||
if (persistent)
|
||||
{
|
||||
manager->persistent_timeout_id = g_timeout_add_seconds (20, save_config_timeout, manager);
|
||||
g_source_set_name_by_id (manager->persistent_timeout_id, "[mutter] save_config_timeout");
|
||||
g_signal_emit (manager, signals[CONFIRM_DISPLAY_CHANGE], 0);
|
||||
}
|
||||
request_persistent_confirmation (manager,
|
||||
META_MONITOR_CONFIG_SYSTEM_LEGACY);
|
||||
|
||||
meta_dbus_display_config_complete_apply_configuration (skeleton, invocation);
|
||||
return TRUE;
|
||||
@ -1919,6 +1977,9 @@ meta_monitor_manager_handle_apply_monitors_config (MetaDBusDisplayConfig *skelet
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (manager->persistent_timeout_id)
|
||||
cancel_persistent_confirmation (manager);
|
||||
|
||||
if (!meta_monitor_manager_apply_monitors_config (manager,
|
||||
config,
|
||||
method,
|
||||
@ -1932,6 +1993,11 @@ meta_monitor_manager_handle_apply_monitors_config (MetaDBusDisplayConfig *skelet
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (method == META_MONITORS_CONFIG_METHOD_PERSISTENT)
|
||||
request_persistent_confirmation (manager,
|
||||
META_MONITOR_CONFIG_SYSTEM_MANAGER);
|
||||
|
||||
|
||||
meta_dbus_display_config_complete_apply_monitors_config (skeleton, invocation);
|
||||
|
||||
return TRUE;
|
||||
@ -1952,6 +2018,16 @@ legacy_confirm_configuration (MetaMonitorManager *manager,
|
||||
meta_monitor_config_restore_previous (manager->legacy_config, manager);
|
||||
}
|
||||
|
||||
static void
|
||||
confirm_configuration (MetaMonitorManager *manager,
|
||||
gboolean confirmed)
|
||||
{
|
||||
if (confirmed)
|
||||
meta_monitor_config_manager_save_current (manager->config_manager);
|
||||
else
|
||||
restore_previous_config (manager);
|
||||
}
|
||||
|
||||
void
|
||||
meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
|
||||
gboolean ok)
|
||||
@ -1962,10 +2038,16 @@ meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
|
||||
return;
|
||||
}
|
||||
|
||||
g_source_remove (manager->persistent_timeout_id);
|
||||
manager->persistent_timeout_id = 0;
|
||||
|
||||
legacy_confirm_configuration (manager, ok);
|
||||
cancel_persistent_confirmation (manager);
|
||||
switch (manager->pending_persistent_system)
|
||||
{
|
||||
case META_MONITOR_CONFIG_SYSTEM_LEGACY:
|
||||
legacy_confirm_configuration (manager, ok);
|
||||
break;
|
||||
case META_MONITOR_CONFIG_SYSTEM_MANAGER:
|
||||
confirm_configuration (manager, ok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user