diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2017-07-14 09:53:28 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2017-07-15 04:34:46 +0300 |
commit | af845b0d0c910a8d27090744e5e6a193ddf01d03 (patch) | |
tree | 655c1a5abf58fc6455953de2932a077e756507c8 | |
parent | 7bae6925a92e08d420b7f6f699470734324ed26a (diff) | |
download | ConsoleKit2-af845b0d0c910a8d27090744e5e6a193ddf01d03.tar.gz |
fix: Allow changing to VTs we don't have a session for
As an example, this allows you to be on VT2 and switch to VT5
which isn't currently being used for anything.
-rw-r--r-- | src/ck-seat.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/ck-seat.c b/src/ck-seat.c index ef2373c..1028d60 100644 --- a/src/ck-seat.c +++ b/src/ck-seat.c @@ -417,20 +417,31 @@ dbus_switch_to (ConsoleKitSeat *ckseat, g_return_val_if_fail (CK_IS_SEAT (ckseat), FALSE); + /* See if there's a session on the seat with that vtnr and activate it */ session = g_hash_table_find (seat->priv->sessions, (GHRFunc)find_session_by_vt, &arg_vtnr); - - if (session == NULL) { - throw_error (invocation, CK_SEAT_ERROR_GENERAL, _("Unable to find session for VT")); - return TRUE; + if (session != NULL) { + if (ck_session_get_id (session, &ssid, NULL)) { + dbus_activate_session (ckseat, invocation, ssid); + g_free (ssid); + return TRUE; + } } - if (ck_session_get_id (session, &ssid, NULL)) { - dbus_activate_session (ckseat, invocation, ssid); - g_free (ssid); + /* Otherwise, if we have a VT monitor then attempt to activate the + * VT that way. + */ + if (seat->priv->vt_monitor != NULL) { + GError *error = NULL; + if (ck_vt_monitor_set_active (seat->priv->vt_monitor, arg_vtnr, &error)) { + console_kit_seat_complete_switch_to (ckseat, invocation); + return TRUE; + } + throw_error (invocation, CK_SEAT_ERROR_FAILED, error->message); return TRUE; } - throw_error (invocation, CK_SEAT_ERROR_GENERAL, _("Unable to get ssid for session")); + /* The seat may not support VTs at all */ + throw_error (invocation, CK_SEAT_ERROR_GENERAL, _("Unable to change VT for seat")); return TRUE; } |