]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Allow XMir to run on the xlocal seat using the new x-server-backend=mir option
authorRobert Ancell <robert.ancell@canonical.com>
Sun, 19 Jun 2016 23:50:39 +0000 (11:50 +1200)
committerRobert Ancell <robert.ancell@canonical.com>
Sun, 19 Jun 2016 23:50:39 +0000 (11:50 +1200)
data/lightdm.conf
src/seat-xlocal.c
tests/Makefile.am
tests/scripts/xmir-autologin.conf [new file with mode: 0644]
tests/scripts/xmir-login.conf [new file with mode: 0644]
tests/scripts/xmir-switch.conf [new file with mode: 0644]
tests/test-xmir-autologin [new file with mode: 0755]
tests/test-xmir-login [new file with mode: 0755]
tests/test-xmir-switch [new file with mode: 0755]

index d8498f9c83f864812018eefbfe6380c82a012746..ddc2229035e4a2b34b5494c99c41968abba8d5a7 100644 (file)
@@ -46,6 +46,7 @@
 # pam-service = PAM service to use for login
 # pam-autologin-service = PAM service to use for autologin
 # pam-greeter-service = PAM service to use for greeters
+# xserver-backend = X backend to use (mir)
 # xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
 # xmir-command = Xmir server command to run (can also contain arguments e.g. Xmir -special-option)
 # xserver-config = Config file to pass to X server
@@ -88,6 +89,7 @@
 #pam-service=lightdm
 #pam-autologin-service=lightdm-autologin
 #pam-greeter-service=lightdm-greeter
+#xserver-backend=
 #xserver-command=X
 #xmir-command=Xmir
 #xserver-config=
index 7d1b1ddb3e29ce07b88e4ef8fe3cc73a7fd1187c..765c9e80e8a7fb9c5e50e24486579ef1230f0e1e 100644 (file)
@@ -14,6 +14,7 @@
 #include "seat-xlocal.h"
 #include "configuration.h"
 #include "x-server-local.h"
+#include "x-server-xmir.h"
 #include "unity-system-compositor.h"
 #include "wayland-session.h"
 #include "plymouth.h"
@@ -27,6 +28,9 @@ struct SeatXLocalPrivate
     /* Session currently active on compositor */
     Session *active_compositor_session;
 
+    /* Counter for Mir IDs to use */
+    int next_xmir_id;
+
     /* X server being used for XDMCP */
     XServerLocal *xdmcp_x_server;
 };
@@ -214,6 +218,7 @@ get_unity_system_compositor (SeatXLocal *seat)
         return seat->priv->compositor;
 
     seat->priv->compositor = create_unity_system_compositor (seat);
+    seat->priv->next_xmir_id = 0;
     g_signal_connect (seat->priv->compositor, DISPLAY_SERVER_SIGNAL_STOPPED, G_CALLBACK (compositor_stopped_cb), seat);
 
     return seat->priv->compositor;
@@ -222,31 +227,57 @@ get_unity_system_compositor (SeatXLocal *seat)
 static XServerLocal *
 create_x_server (SeatXLocal *seat)
 {
+    const gchar *x_server_backend;
     XServerLocal *x_server;
     gchar *number;
     XAuthority *cookie;
-    const gchar *command = NULL, *layout = NULL, *config_file = NULL;
+    const gchar *layout = NULL, *config_file = NULL;
     gboolean allow_tcp;
     gint vt;
 
-    x_server = x_server_local_new ();
+    x_server_backend = seat_get_string_property (SEAT (seat), "xserver-backend");
+    if (g_strcmp0 (x_server_backend, "mir") == 0)
+    {
+        UnitySystemCompositor *compositor;
+        const gchar *command;
+        gchar *id;
+
+        compositor = get_unity_system_compositor (SEAT_XLOCAL (seat));
+        x_server = X_SERVER_LOCAL (x_server_xmir_new (compositor));
 
-    vt = get_vt (seat, DISPLAY_SERVER (x_server));
-    if (vt >= 0)
-        x_server_local_set_vt (x_server, vt);
+        command = seat_get_string_property (SEAT (seat), "xmir-command");
+        if (command)
+            x_server_local_set_command (x_server, command);
 
-    if (vt > 0)
-        l_debug (seat, "Starting local X display on VT %d", vt);
+        id = g_strdup_printf ("x-%d", seat->priv->next_xmir_id);
+        seat->priv->next_xmir_id++;
+        x_server_xmir_set_mir_id (X_SERVER_XMIR (x_server), id);
+        x_server_xmir_set_mir_socket (X_SERVER_XMIR (x_server), unity_system_compositor_get_socket (compositor));
+        g_free (id);
+    }
     else
-        l_debug (seat, "Starting local X display");
+    {
+        const gchar *command = NULL;
 
-    /* If running inside an X server use Xephyr instead */
-    if (g_getenv ("DISPLAY"))
-        command = "Xephyr";
-    if (!command)
-        command = seat_get_string_property (SEAT (seat), "xserver-command");
-    if (command)
-        x_server_local_set_command (x_server, command);
+        x_server = x_server_local_new ();
+
+        vt = get_vt (seat, DISPLAY_SERVER (x_server));
+        if (vt >= 0)
+            x_server_local_set_vt (x_server, vt);
+
+        if (vt > 0)
+            l_debug (seat, "Starting local X display on VT %d", vt);
+        else
+            l_debug (seat, "Starting local X display");
+
+        /* If running inside an X server use Xephyr instead */
+        if (g_getenv ("DISPLAY"))
+            command = "Xephyr";
+        if (!command)
+            command = seat_get_string_property (SEAT (seat), "xserver-command");
+        if (command)
+            x_server_local_set_command (x_server, command);
+    }
 
     number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (x_server)));
     cookie = x_authority_new_local_cookie (number);
@@ -361,10 +392,16 @@ seat_xlocal_set_active_session (Seat *s, Session *session)
         vt_set_active (vt);
 
     g_clear_object (&seat->priv->active_compositor_session);
-    if (IS_UNITY_SYSTEM_COMPOSITOR (display_server)) {
+    if (IS_UNITY_SYSTEM_COMPOSITOR (display_server))
+    {
         unity_system_compositor_set_active_session (UNITY_SYSTEM_COMPOSITOR (display_server), session_get_env (session, "MIR_SERVER_NAME"));
         seat->priv->active_compositor_session = g_object_ref (session);
     }
+    if (IS_X_SERVER_XMIR (display_server))
+    {
+        unity_system_compositor_set_active_session (seat->priv->compositor, x_server_xmir_get_mir_id (X_SERVER_XMIR (display_server)));
+        seat->priv->active_compositor_session = g_object_ref (session);
+    }
 
     SEAT_CLASS (seat_xlocal_parent_class)->set_active_session (s, session);
 }
@@ -401,12 +438,19 @@ seat_xlocal_get_active_session (Seat *s)
 static void
 seat_xlocal_set_next_session (Seat *seat, Session *session)
 {
+    DisplayServer *display_server;
     const gchar *id = NULL;
 
     if (!session)
         return;
 
-    id = session_get_env (session, "MIR_SERVER_NAME");
+    display_server = session_get_display_server (session);
+
+    if (IS_X_SERVER_XMIR (display_server))
+        id = x_server_xmir_get_mir_id (X_SERVER_XMIR (display_server));
+    else
+        id = session_get_env (session, "MIR_SERVER_NAME");
+
     if (id)
     {
         l_debug (seat, "Marking Mir session %s as the next session", id);
index 2005a53d81a78f04c99c7aeacc904a95963af0a4..b616eb10c905ae3729c6c5d57792e498a00e641a 100644 (file)
@@ -225,9 +225,9 @@ TESTS = \
        test-mir-session-crash \
        test-mir-session-compositor-crash \
        test-mir-container-session \
-       test-wayland-autologin \
-       test-wayland-greeter \
-       test-wayland-session \
+       test-xmir-autologin \
+       test-xmir-login \
+       test-xmir-switch \
        test-unity-compositor-command \
        test-unity-compositor-not-found \
        test-unity-compositor-fail-start \
@@ -249,6 +249,9 @@ TESTS = \
        test-unity-mir-switch \
        test-unity-mir-switch-to-user-resettable \
        test-unity-mir-script-hooks \
+       test-wayland-autologin \
+       test-wayland-greeter \
+       test-wayland-session \
        test-invalid-seat \
        test-seatdefaults-still-supported
 
@@ -634,6 +637,9 @@ EXTRA_DIST = \
        scripts/xdmcp-server-xdm-authentication-no-key.conf \
        scripts/xdmcp-server-xdm-authentication-required.conf \
        scripts/xdmcp-server-xdm-authentication-short-data.conf \
+       scripts/xmir-autologin.conf \
+       scripts/xmir-login.conf \
+       scripts/xmir-switch.conf \
        scripts/xremote-autologin.conf \
        scripts/xremote-login.conf \
        scripts/xserver-config.conf \
diff --git a/tests/scripts/xmir-autologin.conf b/tests/scripts/xmir-autologin.conf
new file mode 100644 (file)
index 0000000..72d7406
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# Check uses XMir backend when requested to autologin
+#
+
+[Seat:*]
+autologin-user=have-password1
+user-session=default
+xserver-backend=mir
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# X server starts
+#?XMIR-0 START SEAT=seat0 MIR-ID=x-0
+
+# Daemon connects when X server is ready
+#?*XMIR-0 INDICATE-READY
+#?XMIR-0 INDICATE-READY
+#?XMIR-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XMIR-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XMIR-0 TERMINATE SIGNAL=15
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/xmir-login.conf b/tests/scripts/xmir-login.conf
new file mode 100644 (file)
index 0000000..9cdbee8
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# Check uses XMir backend when requested
+#
+
+[Seat:*]
+user-session=default
+xserver-backend=mir
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# X server starts
+#?XMIR-0 START SEAT=seat0 MIR-ID=x-0
+
+# Daemon connects when X server is ready
+#?*XMIR-0 INDICATE-READY
+#?XMIR-0 INDICATE-READY
+#?XMIR-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XMIR-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0
+
+# Log into account with a password
+#?*GREETER-X-0 AUTHENTICATE USERNAME=have-password1
+#?GREETER-X-0 SHOW-PROMPT TEXT="Password:"
+#?*GREETER-X-0 RESPOND TEXT="password"
+#?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=have-password1 AUTHENTICATED=TRUE
+#?*GREETER-X-0 START-SESSION
+#?GREETER-X-0 TERMINATE SIGNAL=15
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
+#?XMIR-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XMIR-0 TERMINATE SIGNAL=15
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/xmir-switch.conf b/tests/scripts/xmir-switch.conf
new file mode 100644 (file)
index 0000000..0afe2ec
--- /dev/null
@@ -0,0 +1,106 @@
+#
+# Check system compositor correctly switches Xmir sessions
+#
+
+[Seat:*]
+autologin-user=have-password1
+user-session=default
+xserver-backend=mir
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# X server starts
+#?XMIR-0 START SEAT=seat0 MIR-ID=x-0
+
+# Daemon connects when X server is ready
+#?*XMIR-0 INDICATE-READY
+#?XMIR-0 INDICATE-READY
+#?XMIR-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XMIR-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0
+
+# Show the greeter
+#?*SWITCH-TO-GREETER
+#?RUNNER SWITCH-TO-GREETER
+
+# New X server starts
+#?XMIR-1 START SEAT=seat0 MIR-ID=x-1
+
+# Daemon connects when X server is ready
+#?*XMIR-1 INDICATE-READY
+#?XMIR-1 INDICATE-READY
+#?XMIR-1 ACCEPT-CONNECT
+
+# Lock session
+#?LOGIN1 LOCK-SESSION SESSION=c0
+
+# Greeter starts
+#?GREETER-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
+#?XMIR-1 ACCEPT-CONNECT
+#?GREETER-X-1 CONNECT-XSERVER
+#?GREETER-X-1 CONNECT-TO-DAEMON
+#?GREETER-X-1 CONNECTED-TO-DAEMON
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-1
+
+# Login
+#?*GREETER-X-1 AUTHENTICATE USERNAME=no-password1
+#?GREETER-X-1 AUTHENTICATION-COMPLETE USERNAME=no-password1 AUTHENTICATED=TRUE
+#?*GREETER-X-1 START-SESSION
+#?GREETER-X-1 TERMINATE SIGNAL=15
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-1
+
+# New session starts
+#?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c2
+#?XMIR-1 ACCEPT-CONNECT
+#?SESSION-X-1 CONNECT-XSERVER
+
+# Logout of new session
+#?*SESSION-X-1 LOGOUT
+#?XMIR-1 TERMINATE SIGNAL=15
+
+# X server starts
+#?XMIR-2 START SEAT=seat0 MIR-ID=x-2
+#?*XMIR-2 INDICATE-READY
+#?XMIR-2 INDICATE-READY
+#?XMIR-2 ACCEPT-CONNECT
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-2
+
+# Greeter starts
+#?GREETER-X-2 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c3
+#?XMIR-2 ACCEPT-CONNECT
+#?GREETER-X-2 CONNECT-XSERVER
+#?GREETER-X-2 CONNECT-TO-DAEMON
+#?GREETER-X-2 CONNECTED-TO-DAEMON
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-2
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XMIR-0 TERMINATE SIGNAL=15
+#?GREETER-X-2 TERMINATE SIGNAL=15
+#?XMIR-2 TERMINATE SIGNAL=15
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/test-xmir-autologin b/tests/test-xmir-autologin
new file mode 100755 (executable)
index 0000000..be0fbdf
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner xmir-autologin test-gobject-greeter
diff --git a/tests/test-xmir-login b/tests/test-xmir-login
new file mode 100755 (executable)
index 0000000..3c0317e
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner xmir-login test-gobject-greeter
diff --git a/tests/test-xmir-switch b/tests/test-xmir-switch
new file mode 100755 (executable)
index 0000000..d1217f7
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner xmir-switch test-gobject-greeter