diff options
author | infirit <[email protected]> | 2014-11-04 19:58:45 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-04 22:08:50 +0100 |
commit | 89dc9f01e88055d61245024d2e414727982c63e4 (patch) | |
tree | f659832b4d92e71f531e3c6cccdce3306be8ea49 /mate-session/gsm-manager.c | |
parent | 5c371a408a4b71c718eb331c77edfc114fa4114f (diff) | |
download | mate-session-manager-89dc9f01e88055d61245024d2e414727982c63e4.tar.bz2 mate-session-manager-89dc9f01e88055d61245024d2e414727982c63e4.tar.xz |
manager: track full details of logout request
When we get a logout request, there are two bits of information
that come with the request:
1) Whether or not we should seek confirmation by default from the user
before proceeding
2) Whether or not individual applications should be given an
opportunity to ask us to seek confirmation from the user before
proceeding.
We track the latter in a boolean state variable (forceful_logout),
but not the former.
We already have an enumeration type (GsmManagerLogoutMode) that can
be used to track both bits, though.
This commit changes the boolean state variable to the enum type, so
the whether-we-should-confirmation information is available deeper
down in the logout process.
Based on gnome-session commit: d7adaa9111d0f42d11225c7e29a7ee1d37d74d2f
From: Ray Strode <[email protected]>
Diffstat (limited to 'mate-session/gsm-manager.c')
-rw-r--r-- | mate-session/gsm-manager.c | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 2af0902..66ae3a6 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -124,7 +124,7 @@ struct GsmManagerPrivate GsmManagerPhase phase; guint phase_timeout_id; GSList *pending_apps; - gboolean forceful_logout; + GsmManagerLogoutMode logout_mode; GSList *query_clients; guint query_timeout_id; /* This is used for GSM_MANAGER_PHASE_END_SESSION only at the moment, @@ -783,7 +783,7 @@ do_phase_end_session (GsmManager *manager) data.manager = manager; data.flags = 0; - if (manager->priv->forceful_logout) { + if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } if (auto_save_is_enabled (manager)) { @@ -816,7 +816,7 @@ do_phase_end_session_part_2 (GsmManager *manager) data.manager = manager; data.flags = 0; - if (manager->priv->forceful_logout) { + if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } if (auto_save_is_enabled (manager)) { @@ -1011,7 +1011,7 @@ cancel_end_session (GsmManager *manager) NULL); gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_RUNNING); - manager->priv->forceful_logout = FALSE; + manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; manager->priv->logout_type = GSM_MANAGER_LOGOUT_NONE; mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE); @@ -1244,7 +1244,7 @@ do_inhibit_dialog_action (GsmManager *manager, case GSM_LOGOUT_ACTION_SHUTDOWN: case GSM_LOGOUT_ACTION_REBOOT: case GSM_LOGOUT_ACTION_LOGOUT: - manager->priv->forceful_logout = TRUE; + manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE; end_phase (manager); break; default: @@ -1396,7 +1396,7 @@ _on_query_end_session_timeout (GsmManager *manager) /* Don't add "not responding" inhibitors if logout is forced */ - if (manager->priv->forceful_logout) { + if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { continue; } @@ -1442,7 +1442,7 @@ do_phase_query_end_session (GsmManager *manager) data.manager = manager; data.flags = 0; - if (manager->priv->forceful_logout) { + if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } /* We only query if an app is ready to log out, so we don't use @@ -1450,7 +1450,10 @@ do_phase_query_end_session (GsmManager *manager) */ debug_clients (manager); - g_debug ("GsmManager: sending query-end-session to clients forceful:%d", manager->priv->forceful_logout); + g_debug ("GsmManager: sending query-end-session to clients (logout mode: %s)", + manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL? "normal" : + manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE? "forceful": + "no confirmation"); gsm_store_foreach (manager->priv->clients, (GsmStoreFunc)_client_query_end_session, &data); @@ -2108,7 +2111,7 @@ _handle_client_end_session_response (GsmManager *manager, manager->priv->query_clients = g_slist_remove (manager->priv->query_clients, client); - if (! is_ok && !manager->priv->forceful_logout) { + if (! is_ok && !manager->priv->logout_mode != GSM_MANAGER_LOGOUT_MODE_FORCE) { guint cookie; GsmInhibitor *inhibitor; char *app_id; @@ -3081,12 +3084,12 @@ request_hibernate (GsmManager *manager) static void -request_logout (GsmManager *manager, - gboolean forceful_logout) +request_logout (GsmManager *manager, + GsmManagerLogoutMode mode) { g_debug ("GsmManager: requesting logout"); - manager->priv->forceful_logout = forceful_logout; + manager->priv->logout_mode = mode; manager->priv->logout_type = GSM_MANAGER_LOGOUT_LOGOUT; end_phase (manager); @@ -3124,6 +3127,11 @@ logout_dialog_response (GsmLogoutDialog *logout_dialog, guint response_id, GsmManager *manager) { + /* We should only be here if mode has already have been set from + * show_fallback_shutdown/logout_dialog + */ + g_assert (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL); + g_debug ("GsmManager: Logout dialog response: %d", response_id); gtk_widget_destroy (GTK_WIDGET (logout_dialog)); @@ -3152,7 +3160,14 @@ logout_dialog_response (GsmLogoutDialog *logout_dialog, request_reboot (manager); break; case GSM_LOGOUT_RESPONSE_LOGOUT: - request_logout (manager, FALSE); + /* We've already gotten confirmation from the user so + * initiate the logout in NO_CONFIRMATION mode. + * + * (it shouldn't matter whether we use NO_CONFIRMATION or stay + * with NORMAL, unless the shell happens to start after the + * user confirmed) + */ + request_logout (manager, GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION); break; default: g_assert_not_reached (); @@ -3170,6 +3185,8 @@ show_shutdown_dialog (GsmManager *manager) return; } + manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; + dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (), gtk_get_current_event_time ()); @@ -3190,6 +3207,8 @@ show_logout_dialog (GsmManager *manager) return; } + manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL; + dialog = gsm_get_logout_dialog (gdk_screen_get_default (), gtk_get_current_event_time ()); @@ -3201,9 +3220,8 @@ show_logout_dialog (GsmManager *manager) } static void -user_logout (GsmManager *manager, - gboolean show_confirmation, - gboolean forceful_logout) +user_logout (GsmManager *manager, + GsmManagerLogoutMode mode) { gboolean logout_prompt; @@ -3216,15 +3234,14 @@ user_logout (GsmManager *manager, g_settings_get_boolean (manager->priv->settings_session, "logout-prompt"); - /* Global settings overides input parameter in order to disable confirmation - * dialog accordingly. If we're shutting down, we always show the confirmation - * dialog */ - logout_prompt = (logout_prompt && show_confirmation); - - if (logout_prompt) { + /* If the shell isn't running, and this isn't a non-interative logout request, + * and the user has their settings configured to show a confirmation dialog for + * logout, then go ahead and show the confirmation dialog now. + */ + if (mode == GSM_MANAGER_LOGOUT_MODE_NORMAL && logout_prompt) { show_logout_dialog (manager); } else { - request_logout (manager, forceful_logout); + request_logout (manager, mode); } } @@ -3371,15 +3388,9 @@ gsm_manager_logout (GsmManager *manager, switch (logout_mode) { case GSM_MANAGER_LOGOUT_MODE_NORMAL: - user_logout (manager, TRUE, FALSE); - break; - case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION: - user_logout (manager, FALSE, FALSE); - break; - case GSM_MANAGER_LOGOUT_MODE_FORCE: - user_logout (manager, FALSE, TRUE); + user_logout (manager, logout_mode); break; default: @@ -3552,7 +3563,7 @@ gsm_manager_inhibit (GsmManager *manager, reason, flags); - if (manager->priv->forceful_logout) { + if (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { GError *new_error; new_error = g_error_new (GSM_MANAGER_ERROR, |