1 --- ConsoleKit-0.4.1/src/ck-seat.c-orig 2011-07-28 01:25:03.688403859 -0500
2 +++ ConsoleKit-0.4.1/src/ck-seat.c 2011-07-28 01:27:24.076536756 -0500
3 @@ -951,9 +951,32 @@ find_possible_session_to_activate (CkSea
4 ck_session_is_open (value, &is_open, NULL);
7 + GError *vt_error = NULL;
13 - change_active_session (seat, value);
16 + g_debug ("Found open session.");
18 + switch (seat->priv->kind) {
19 + case CK_SEAT_KIND_STATIC:
21 + ck_session_get_x11_display_device (value, &device, NULL);
23 + if (device != NULL) {
24 + ret = ck_get_console_num_from_device (device, &num);
26 + g_debug ("Activating VT %d", num);
27 + ck_vt_monitor_set_active (seat->priv->vt_monitor, num, &vt_error);
31 + case CK_SEAT_KIND_DYNAMIC:
32 + change_active_session (seat, value);
37 ck_session_get_session_type (value, &session_type, NULL);
38 @@ -1037,6 +1060,11 @@ ck_seat_remove_session (CkSeat *
39 CkSession *orig_session;
42 + GHashTableIter iter;
43 + gpointer key, value;
44 + gboolean found_login = FALSE;
46 + char *session_type = NULL;
48 g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
50 @@ -1076,7 +1104,48 @@ ck_seat_remove_session (CkSeat *
51 g_signal_emit (seat, signals [SESSION_REMOVED], 0, ssid);
53 /* try to change the active session */
54 - maybe_update_active_session (seat);
56 + /* On session exit, first try to switch to any active login sessions */
57 + g_hash_table_iter_init (&iter, seat->priv->sessions);
58 + if (seat->priv->kind == CK_SEAT_KIND_STATIC) {
59 + while (seat->priv->kind == CK_SEAT_KIND_STATIC && g_hash_table_iter_next (&iter, &key, &value)) {
60 + CkSession *login_session = value;
61 + ck_session_get_session_type (login_session, &session_type, NULL);
62 + ck_session_is_open (login_session, &is_open, NULL);
64 + if (is_open && IS_STR_SET (session_type) &&
65 + g_str_equal (session_type, "LoginWindow")) {
66 + GError *vt_error = NULL;
70 + g_debug ("Found a LoginWindow");
72 + ck_session_get_x11_display_device (login_session, &device, NULL);
74 + if (device != NULL) {
75 + ret = ck_get_console_num_from_device (device, &num);
77 + g_debug ("Setting active to %d", num);
79 + ck_vt_monitor_set_active (seat->priv->vt_monitor, num, &vt_error);
81 + g_debug ("The LoginWindow device has no console number, not using.");
84 + g_debug ("The LoginWindow display has no x11 display device, not using.");
87 + if (session_type != NULL)
88 + g_free (session_type);
92 + /* Otherwise, look for an active session */
93 + if (found_login == FALSE) {
94 + g_debug ("Login not found. Maybe update active session");
95 + maybe_update_active_session (seat);
98 if (orig_session != NULL) {
99 g_object_unref (orig_session);
100 @@ -1345,8 +1412,6 @@ active_vt_changed (CkVtMonitor *vt_mo
103 g_debug ("Active vt changed: %u", num);
105 - update_active_vt (seat, num);