summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <halfline@gmail.com>2018-08-08 14:16:33 +0000
committerRay Strode <halfline@gmail.com>2018-08-08 14:16:33 +0000
commit846ea879151d6bc6aec184b03fa2bb4e1f886175 (patch)
tree985397f633e501fb30b5700bcb75c79a90584818
parent8b163aac125a0c7a562c1b920288be4e174d63ff (diff)
parent8169cd4fc83beb5c3835a6ee1fafc6911a887a81 (diff)
downloadgdm-846ea879151d6bc6aec184b03fa2bb4e1f886175.tar.gz
Merge branch 'wip/fix-double-greeters' into 'master'
don't start two greeters at startup Closes #409 See merge request GNOME/gdm!28
-rw-r--r--daemon/gdm-local-display-factory.c44
-rw-r--r--daemon/gdm-session-worker.c22
2 files changed, 54 insertions, 12 deletions
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 8bf92b64..82169ce4 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -552,8 +552,10 @@ maybe_stop_greeter_display (GdmDisplay *display)
{
g_autofree char *display_session_type = NULL;
- if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED)
+ if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED) {
+ g_debug ("GdmLocalDisplayFactory: login window not in managed state, so ignoring");
return;
+ }
g_object_get (G_OBJECT (display),
"session-type", &display_session_type,
@@ -561,9 +563,12 @@ maybe_stop_greeter_display (GdmDisplay *display)
/* we can only stop greeter for wayland sessions, since
* X server would jump back on exit */
- if (g_strcmp0 (display_session_type, "wayland") != 0)
+ if (g_strcmp0 (display_session_type, "wayland") != 0) {
+ g_debug ("GdmLocalDisplayFactory: login window is running on Xorg, so ignoring");
return;
+ }
+ g_debug ("GdmLocalDisplayFactory: killing login window since its now unused");
gdm_display_stop_greeter_session (display);
gdm_display_unmanage (display);
gdm_display_finish (display);
@@ -583,6 +588,7 @@ on_vt_changed (GIOChannel *source,
const char *session_type = NULL;
int ret;
+ g_debug ("GdmLocalDisplayFactory: received VT change event");
g_io_channel_seek_position (source, 0, G_SEEK_SET, NULL);
if (condition & G_IO_PRI) {
@@ -604,21 +610,37 @@ on_vt_changed (GIOChannel *source,
}
}
- if ((condition & G_IO_ERR) || (condition & G_IO_HUP))
+ if ((condition & G_IO_ERR) || (condition & G_IO_HUP)) {
+ g_debug ("GdmLocalDisplayFactory: kernel hung up active vt watch");
return G_SOURCE_REMOVE;
+ }
- if (tty_of_active_vt == NULL)
+ if (tty_of_active_vt == NULL) {
+ g_debug ("GdmLocalDisplayFactory: unable to read active VT from kernel");
return G_SOURCE_CONTINUE;
+ }
g_strchomp (tty_of_active_vt);
/* don't do anything if we're on the same VT we were before */
- if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0)
+ if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0) {
+ g_debug ("GdmLocalDisplayFactory: VT changed to the same VT, ignoring");
return G_SOURCE_CONTINUE;
+ }
tty_of_previous_vt = g_steal_pointer (&factory->priv->tty_of_active_vt);
factory->priv->tty_of_active_vt = g_steal_pointer (&tty_of_active_vt);
+ /* don't do anything at start up */
+ if (tty_of_previous_vt == NULL) {
+ g_debug ("GdmLocalDisplayFactory: VT is %s at startup",
+ factory->priv->tty_of_active_vt);
+ return G_SOURCE_CONTINUE;
+ }
+
+ g_debug ("GdmLocalDisplayFactory: VT changed from %s to %s",
+ tty_of_previous_vt, factory->priv->tty_of_active_vt);
+
/* if the old VT was running a wayland login screen kill it
*/
if (gdm_get_login_window_session_id ("seat0", &login_session_id)) {
@@ -630,10 +652,13 @@ on_vt_changed (GIOChannel *source,
tty_of_login_window_vt = g_strdup_printf ("tty%u", vt);
+ g_debug ("GdmLocalDisplayFactory: tty of login window is %s", tty_of_login_window_vt);
if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
GdmDisplayStore *store;
GdmDisplay *display;
+ g_debug ("GdmLocalDisplayFactory: VT switched from login window");
+
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
display = gdm_display_store_find (store,
lookup_by_session_id,
@@ -641,6 +666,8 @@ on_vt_changed (GIOChannel *source,
if (display != NULL)
maybe_stop_greeter_display (display);
+ } else {
+ g_debug ("GdmLocalDisplayFactory: VT not switched from login window");
}
}
}
@@ -650,6 +677,7 @@ on_vt_changed (GIOChannel *source,
* jump to that login screen)
*/
if (strcmp (factory->priv->tty_of_active_vt, tty_of_initial_vt) != 0) {
+ g_debug ("GdmLocalDisplayFactory: active VT is not initial VT, so ignoring");
return G_SOURCE_CONTINUE;
}
@@ -660,13 +688,17 @@ on_vt_changed (GIOChannel *source,
ret = sd_session_get_state (active_session_id, &state);
/* if there's something already running on the active VT then bail */
- if (ret == 0 && g_strcmp0 (state, "closing") != 0)
+ if (ret == 0 && g_strcmp0 (state, "closing") != 0) {
+ g_debug ("GdmLocalDisplayFactory: initial VT is in use, so ignoring");
return G_SOURCE_CONTINUE;
+ }
}
if (gdm_local_display_factory_use_wayland ())
session_type = "wayland";
+ g_debug ("GdmLocalDisplayFactory: creating new display on seat0 because of VT change");
+
create_display (factory, "seat0", session_type, TRUE);
return G_SOURCE_CONTINUE;
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index c1d89cab..d211cdb1 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -968,6 +968,8 @@ jump_to_vt (GdmSessionWorker *worker,
{
int fd;
int active_vt_tty_fd;
+ int active_vt = -1;
+ struct vt_stat vt_state = { 0 };
g_debug ("GdmSessionWorker: jumping to VT %d", vt_number);
active_vt_tty_fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
@@ -993,12 +995,20 @@ jump_to_vt (GdmSessionWorker *worker,
handle_terminal_vt_switches (worker, fd);
- if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
- g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
- vt_number);
- } else if (ioctl (fd, VT_WAITACTIVE, vt_number) < 0) {
- g_debug ("GdmSessionWorker: couldn't finalize jump to VT %d: %m",
- vt_number);
+ if (ioctl (fd, VT_GETSTATE, &vt_state) <= 0) {
+ g_debug ("GdmSessionWorker: couldn't get current VT: %m");
+ } else {
+ active_vt = vt_state.v_active;
+ }
+
+ if (active_vt != vt_number) {
+ if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
+ g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
+ vt_number);
+ } else if (ioctl (fd, VT_WAITACTIVE, vt_number) < 0) {
+ g_debug ("GdmSessionWorker: couldn't finalize jump to VT %d: %m",
+ vt_number);
+ }
}
close (active_vt_tty_fd);