|
|
e0b6b0 |
From fe680d77cff9272843cb171c7e590c239f7afe5a Mon Sep 17 00:00:00 2001
|
|
|
c90517 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
c90517 |
Date: Thu, 9 Aug 2018 12:32:31 -0400
|
|
|
e0b6b0 |
Subject: [PATCH 19/51] local-display-factory: don't jump to failed display
|
|
|
c90517 |
|
|
|
c90517 |
Since commit 5e737a57 `create_display` will jump to any
|
|
|
c90517 |
already running login screen if it can find one.
|
|
|
c90517 |
|
|
|
c90517 |
Right now if a display fails we call `create_display` to
|
|
|
c90517 |
create a new one. It will look for any already running
|
|
|
c90517 |
login screen and find the recently failed display.
|
|
|
c90517 |
|
|
|
c90517 |
This commit make sure we never jump to a display that isn't
|
|
|
c90517 |
in good working order.
|
|
|
c90517 |
---
|
|
|
c90517 |
daemon/gdm-local-display-factory.c | 19 +++++++++++++++----
|
|
|
c90517 |
1 file changed, 15 insertions(+), 4 deletions(-)
|
|
|
c90517 |
|
|
|
c90517 |
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
index 9f377ba9a..c58de9c17 100644
|
|
|
c90517 |
--- a/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
+++ b/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
@@ -60,60 +60,63 @@ struct GdmLocalDisplayFactoryPrivate
|
|
|
c90517 |
guint num_failures;
|
|
|
c90517 |
|
|
|
c90517 |
guint seat_new_id;
|
|
|
c90517 |
guint seat_removed_id;
|
|
|
c90517 |
|
|
|
c90517 |
#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
c90517 |
char *tty_of_active_vt;
|
|
|
c90517 |
guint active_vt_watch_id;
|
|
|
c90517 |
#endif
|
|
|
c90517 |
};
|
|
|
c90517 |
|
|
|
c90517 |
enum {
|
|
|
c90517 |
PROP_0,
|
|
|
c90517 |
};
|
|
|
c90517 |
|
|
|
c90517 |
static void gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass);
|
|
|
c90517 |
static void gdm_local_display_factory_init (GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
static void gdm_local_display_factory_finalize (GObject *object);
|
|
|
c90517 |
|
|
|
c90517 |
static GdmDisplay *create_display (GdmLocalDisplayFactory *factory,
|
|
|
c90517 |
const char *seat_id,
|
|
|
c90517 |
const char *session_type,
|
|
|
c90517 |
gboolean initial_display);
|
|
|
c90517 |
|
|
|
c90517 |
static void on_display_status_changed (GdmDisplay *display,
|
|
|
c90517 |
GParamSpec *arg1,
|
|
|
c90517 |
GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
|
|
|
c90517 |
static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
static gpointer local_display_factory_object = NULL;
|
|
|
c90517 |
+static gboolean lookup_by_session_id (const char *id,
|
|
|
c90517 |
+ GdmDisplay *display,
|
|
|
c90517 |
+ gpointer user_data);
|
|
|
c90517 |
|
|
|
c90517 |
G_DEFINE_TYPE (GdmLocalDisplayFactory, gdm_local_display_factory, GDM_TYPE_DISPLAY_FACTORY)
|
|
|
c90517 |
|
|
|
c90517 |
GQuark
|
|
|
c90517 |
gdm_local_display_factory_error_quark (void)
|
|
|
c90517 |
{
|
|
|
c90517 |
static GQuark ret = 0;
|
|
|
c90517 |
if (ret == 0) {
|
|
|
c90517 |
ret = g_quark_from_static_string ("gdm_local_display_factory_error");
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
return ret;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
listify_hash (gpointer key,
|
|
|
c90517 |
GdmDisplay *display,
|
|
|
c90517 |
GList **list)
|
|
|
c90517 |
{
|
|
|
c90517 |
*list = g_list_prepend (*list, key);
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static int
|
|
|
c90517 |
sort_nums (gpointer a,
|
|
|
c90517 |
gpointer b)
|
|
|
c90517 |
{
|
|
|
c90517 |
guint32 num_a;
|
|
|
c90517 |
guint32 num_b;
|
|
|
c90517 |
|
|
|
c90517 |
num_a = GPOINTER_TO_UINT (a);
|
|
|
c90517 |
@@ -370,66 +373,74 @@ lookup_by_seat_id (const char *id,
|
|
|
c90517 |
|
|
|
c90517 |
g_object_get (G_OBJECT (display), "seat-id", ¤t, NULL);
|
|
|
c90517 |
|
|
|
c90517 |
res = g_strcmp0 (current, looking_for) == 0;
|
|
|
c90517 |
|
|
|
c90517 |
g_free(current);
|
|
|
c90517 |
|
|
|
c90517 |
return res;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static GdmDisplay *
|
|
|
c90517 |
create_display (GdmLocalDisplayFactory *factory,
|
|
|
c90517 |
const char *seat_id,
|
|
|
c90517 |
const char *session_type,
|
|
|
c90517 |
gboolean initial)
|
|
|
c90517 |
{
|
|
|
c90517 |
GdmDisplayStore *store;
|
|
|
c90517 |
GdmDisplay *display = NULL;
|
|
|
c90517 |
char *active_session_id = NULL;
|
|
|
c90517 |
int ret;
|
|
|
c90517 |
|
|
|
c90517 |
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
|
|
|
c90517 |
|
|
|
c90517 |
ret = sd_seat_get_active (seat_id, &active_session_id, NULL);
|
|
|
c90517 |
|
|
|
c90517 |
if (ret == 0) {
|
|
|
c90517 |
char *login_session_id = NULL;
|
|
|
c90517 |
|
|
|
c90517 |
/* If we already have a login window, switch to it */
|
|
|
c90517 |
if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
|
|
|
c90517 |
- if (g_strcmp0 (active_session_id, login_session_id) != 0) {
|
|
|
c90517 |
- gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
|
|
|
c90517 |
+ GdmDisplay *display;
|
|
|
c90517 |
+
|
|
|
c90517 |
+ display = gdm_display_store_find (store,
|
|
|
c90517 |
+ lookup_by_session_id,
|
|
|
c90517 |
+ (gpointer) login_session_id);
|
|
|
c90517 |
+ if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
|
|
|
c90517 |
+ if (g_strcmp0 (active_session_id, login_session_id) != 0) {
|
|
|
c90517 |
+ gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
|
|
|
c90517 |
+ }
|
|
|
c90517 |
+ g_clear_pointer (&login_session_id, g_free);
|
|
|
c90517 |
+ g_clear_pointer (&active_session_id, g_free);
|
|
|
c90517 |
+ return NULL;
|
|
|
c90517 |
}
|
|
|
c90517 |
g_clear_pointer (&login_session_id, g_free);
|
|
|
c90517 |
- g_clear_pointer (&active_session_id, g_free);
|
|
|
c90517 |
- return NULL;
|
|
|
c90517 |
}
|
|
|
c90517 |
g_clear_pointer (&active_session_id, g_free);
|
|
|
c90517 |
} else if (!sd_seat_can_multi_session (seat_id)) {
|
|
|
c90517 |
/* Ensure we don't create the same display more than once */
|
|
|
c90517 |
display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id);
|
|
|
c90517 |
|
|
|
c90517 |
if (display != NULL) {
|
|
|
c90517 |
return NULL;
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
|
|
|
c90517 |
|
|
|
c90517 |
#ifdef ENABLE_USER_DISPLAY_SERVER
|
|
|
c90517 |
if (g_strcmp0 (seat_id, "seat0") == 0) {
|
|
|
c90517 |
display = gdm_local_display_new ();
|
|
|
c90517 |
if (session_type != NULL) {
|
|
|
c90517 |
g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
#endif
|
|
|
c90517 |
|
|
|
c90517 |
if (display == NULL) {
|
|
|
c90517 |
guint32 num;
|
|
|
c90517 |
|
|
|
c90517 |
num = take_next_display_number (factory);
|
|
|
c90517 |
|
|
|
c90517 |
display = gdm_legacy_display_new (num);
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
--
|
|
|
e0b6b0 |
2.27.0
|
|
|
c90517 |
|