=== modified file 'debian/changelog'
--- debian/changelog	2017-10-11 11:20:42 +0000
+++ debian/changelog	2017-10-17 16:29:28 +0000
@@ -1,3 +1,12 @@
+gdm3 (3.26.1-3ubuntu3) UNRELEASED; urgency=medium
+
+  * debian/patches/ubuntu_ignore_sessions_xorg_suffix.patch: Ignore session
+    IDs ending with "-xorg" under X11. In combination with a gnome-session
+    patch, this ensures a proper fallback session is selected by gdm when
+    wayland is not enabled (LP: #1718446).
+
+ -- Olivier Tilloy <olivier.tilloy@canonical.com>  Wed, 11 Oct 2017 18:57:51 +0200
+
 gdm3 (3.26.1-3ubuntu2) artful; urgency=medium
 
   * debian/patches/ubuntu_dont_set_language_env.patch:

=== modified file 'debian/patches/series'
--- debian/patches/series	2017-10-09 22:22:46 +0000
+++ debian/patches/series	2017-10-17 16:29:28 +0000
@@ -10,3 +10,4 @@
 revert_override_LANG_with_accountservices.patch
 ubuntu_config_error_dialog.patch
 ubuntu_dont_set_language_env.patch
+ubuntu_ignore_sessions_xorg_suffix.patch

=== added file 'debian/patches/ubuntu_ignore_sessions_xorg_suffix.patch'
--- debian/patches/ubuntu_ignore_sessions_xorg_suffix.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/ubuntu_ignore_sessions_xorg_suffix.patch	2017-10-17 16:29:28 +0000
@@ -0,0 +1,44 @@
+Author: Olivier Tilloy <olivier.tilloy@canonical.com>
+Description: Ignore session IDs ending with "-xorg" under X11
+ This is done under the assumption that they are meant for Wayland only.
+ It is expected that a session called "foo" would have a "foo.desktop" file
+ under wayland-sessions/, a fallback "foo.desktop" under xsessions/, and
+ another "foo-xorg.desktop" under xsessions (that may simply be a symlink
+ to "foo.desktop") specifically for Wayland.
+Bug: https://bugzilla.gnome.org/show_bug.cgi?id=788552
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gdm3/+bug/1718446
+
+--- a/libgdm/gdm-sessions.c
++++ b/libgdm/gdm-sessions.c
+@@ -157,6 +157,9 @@ collect_sessions_from_directory (const c
+         GDir       *dir;
+         const char *filename;
+ 
++        gboolean is_x11 = g_getenv ("WAYLAND_DISPLAY") == NULL &&
++                          g_getenv ("RUNNING_UNDER_GDM") != NULL;
++
+         /* FIXME: add file monitor to directory */
+ 
+         dir = g_dir_open (dirname, 0, NULL);
+@@ -171,6 +174,21 @@ collect_sessions_from_directory (const c
+                 if (! g_str_has_suffix (filename, ".desktop")) {
+                         continue;
+                 }
++
++                if (is_x11 && g_str_has_suffix (filename, "-xorg.desktop")) {
++                        char *base_name = g_strndup (filename, strlen (filename) - strlen ("-xorg.desktop"));
++                        char *fallback_name = g_strconcat (base_name, ".desktop", NULL);
++                        g_free (base_name);
++                        char *fallback_path = g_build_filename (dirname, fallback_name, NULL);
++                        g_free (fallback_name);
++                        if (g_file_test (fallback_path, G_FILE_TEST_EXISTS)) {
++                                g_free (fallback_path);
++                                g_debug ("Running under X11, ignoring %s", filename);
++                                continue;
++                        }
++                        g_free (fallback_path);
++                }
++
+                 id = g_strndup (filename, strlen (filename) - strlen (".desktop"));
+ 
+                 full_path = g_build_filename (dirname, filename, NULL);

