diff options
author | Giovanni Campagna <gcampagn@redhat.com> | 2013-07-29 10:12:24 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2013-08-18 00:47:53 +0200 |
commit | 5086626805df4151829a38286d7d03530cf941e5 (patch) | |
tree | b52b3d9d7ba6e71319f87102991a3ca58fe50f21 /src/core | |
parent | bbbcd8c631b280efa300886351af485ccd3fee0e (diff) | |
download | mutter-5086626805df4151829a38286d7d03530cf941e5.tar.gz |
MetaPlugin: add a UI hook for confirming display changes
We want to show a dialog when a display change happens from the
control center. To do so, add a new vfunc to MetaPlugin and
call it when a configuration change is requested via DBus.
https://bugzilla.gnome.org/show_bug.cgi?id=705670
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/monitor-private.h | 3 | ||||
-rw-r--r-- | src/core/monitor.c | 44 | ||||
-rw-r--r-- | src/core/util.c | 9 |
3 files changed, 49 insertions, 7 deletions
diff --git a/src/core/monitor-private.h b/src/core/monitor-private.h index 73eb8a12f..c5b80b2fe 100644 --- a/src/core/monitor-private.h +++ b/src/core/monitor-private.h @@ -242,6 +242,9 @@ void meta_monitor_manager_apply_configuration (MetaMonitorManager MetaOutputInfo **outputs, unsigned int n_outputs); +void meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager, + gboolean ok); + #define META_TYPE_MONITOR_CONFIG (meta_monitor_config_get_type ()) #define META_MONITOR_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_MONITOR_CONFIG, MetaMonitorConfig)) #define META_MONITOR_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_MONITOR_CONFIG, MetaMonitorConfigClass)) diff --git a/src/core/monitor.c b/src/core/monitor.c index e17dab109..85793a1bf 100644 --- a/src/core/monitor.c +++ b/src/core/monitor.c @@ -114,6 +114,7 @@ struct _MetaMonitorManagerClass enum { MONITORS_CHANGED, + CONFIRM_DISPLAY_CHANGE, SIGNALS_LAST }; @@ -1095,6 +1096,14 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); + signals[CONFIRM_DISPLAY_CHANGE] = + g_signal_new ("confirm-display-change", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); + g_object_class_override_property (object_class, PROP_POWER_SAVE_MODE, "power-save-mode"); } @@ -1562,8 +1571,9 @@ save_config_timeout (gpointer user_data) { MetaMonitorManager *manager = user_data; - meta_monitor_config_make_persistent (manager->config); + meta_monitor_config_restore_previous (manager->config, manager); + manager->persistent_timeout_id = 0; return G_SOURCE_REMOVE; } @@ -1766,7 +1776,7 @@ meta_monitor_manager_handle_apply_configuration (MetaDBusDisplayConfig *skeleto /* If we were in progress of making a persistent change and we see a new request, it's likely that the old one failed in some way, so - don't save it. + don't save it, but also don't queue for restoring it. */ if (manager->persistent_timeout_id && persistent) { @@ -1784,17 +1794,41 @@ meta_monitor_manager_handle_apply_configuration (MetaDBusDisplayConfig *skeleto g_ptr_array_unref (output_infos); /* Update MetaMonitorConfig data structures immediately so that we - don't revert the change at the next XRandR event, then wait 20 - seconds and save the change to disk + don't revert the change at the next XRandR event, then ask the plugin + manager (through MetaScreen) to confirm the display change with the + appropriate UI. Then wait 20 seconds and if not confirmed, revert the + configuration. */ meta_monitor_config_update_current (manager->config, manager); if (persistent) - manager->persistent_timeout_id = g_timeout_add_seconds (20, save_config_timeout, manager); + { + manager->persistent_timeout_id = g_timeout_add_seconds (20, save_config_timeout, manager); + g_signal_emit (manager, signals[CONFIRM_DISPLAY_CHANGE], 0); + } meta_dbus_display_config_complete_apply_configuration (skeleton, invocation); return TRUE; } +void +meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager, + gboolean ok) +{ + if (!manager->persistent_timeout_id) + { + /* too late */ + return; + } + + g_source_remove (manager->persistent_timeout_id); + manager->persistent_timeout_id = 0; + + if (ok) + meta_monitor_config_make_persistent (manager->config); + else + meta_monitor_config_restore_previous (manager->config, manager); +} + #ifdef HAVE_RANDR static void handle_change_backlight_xrandr (MetaMonitorManager *manager, diff --git a/src/core/util.c b/src/core/util.c index e36353f64..c3af1a7c4 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -639,8 +639,13 @@ meta_show_dialog (const char *type, append_argument (args, "zenity"); append_argument (args, type); - append_argument (args, "--display"); - append_argument (args, display); + + if (display) + { + append_argument (args, "--display"); + append_argument (args, display); + } + append_argument (args, "--class"); append_argument (args, "mutter-dialog"); append_argument (args, "--title"); |