diff options
-rw-r--r-- | src/mir-server.c | 71 | ||||
-rw-r--r-- | src/mir-server.h | 8 | ||||
-rw-r--r-- | src/seat-unity.c | 63 | ||||
-rw-r--r-- | tests/scripts/unity-mir-login.conf | 2 | ||||
-rw-r--r-- | tests/src/test-gobject-greeter.c | 21 | ||||
-rw-r--r-- | tests/src/test-session.c | 7 |
6 files changed, 134 insertions, 38 deletions
diff --git a/src/mir-server.c b/src/mir-server.c index c43e6d34..f70915a8 100644 --- a/src/mir-server.c +++ b/src/mir-server.c @@ -13,17 +13,18 @@ #include "mir-server.h" #include "configuration.h" +#include "vt.h" struct MirServerPrivate { /* VT to run on */ gint vt; - /* Mir socket for children of this display server to communicate on */ - gchar *mir_socket; - /* Mir socket for this server to talk to parent */ - gchar *mir_parent_socket; + gchar *parent_socket; + + /* ID to use for Mir connection */ + gchar *id; }; G_DEFINE_TYPE (MirServer, mir_server, DISPLAY_SERVER_TYPE); @@ -33,10 +34,43 @@ MirServer *mir_server_new (void) return g_object_new (MIR_SERVER_TYPE, NULL); } +void +mir_server_set_vt (MirServer *server, gint vt) +{ + g_return_if_fail (server != NULL); + if (server->priv->vt > 0) + vt_unref (server->priv->vt); + server->priv->vt = vt; + if (vt > 0) + vt_ref (vt); +} + +void +mir_server_set_parent_socket (MirServer *server, const gchar *parent_socket) +{ + g_return_if_fail (server != NULL); + g_free (server->priv->parent_socket); + server->priv->parent_socket = g_strdup (parent_socket); +} + +void +mir_server_set_id (MirServer *server, const gchar *id) +{ + g_return_if_fail (server != NULL); + g_free (server->priv->id); + server->priv->id = g_strdup (id); +} + +const gchar * +mir_server_get_id (MirServer *server) +{ + g_return_val_if_fail (server != NULL, NULL); + return server->priv->id; +} + static gint mir_server_local_get_vt (DisplayServer *server) { - g_return_val_if_fail (server != NULL, 0); return MIR_SERVER (server)->priv->vt; } @@ -49,16 +83,16 @@ mir_server_start (DisplayServer *display_server) static void mir_server_setup_session (DisplayServer *display_server, Session *session) { - MirServer *mir_server; - - mir_server = MIR_SERVER (display_server); - if (mir_server->priv->mir_socket) - session_set_env (session, "MIR_SOCKET", mir_server->priv->mir_socket); - if (mir_server->priv->mir_parent_socket) - session_set_env (session, "MIR_SERVER_FILE", mir_server->priv->mir_parent_socket); - if (mir_server->priv->vt > 0) + MirServer *server; + + server = MIR_SERVER (display_server); + if (server->priv->id) + session_set_env (session, "MIR_ID", server->priv->id); + if (server->priv->parent_socket) + session_set_env (session, "MIR_SERVER_FILE", server->priv->parent_socket); + if (server->priv->vt > 0) { - gchar *value = g_strdup_printf ("%d", mir_server->priv->vt); + gchar *value = g_strdup_printf ("%d", server->priv->vt); session_set_env (session, "MIR_SERVER_VT", value); g_free (value); } @@ -74,6 +108,15 @@ mir_server_init (MirServer *server) static void mir_server_finalize (GObject *object) { + MirServer *server; + + server = MIR_SERVER (object); + + if (server->priv->vt > 0) + vt_unref (server->priv->vt); + g_free (server->priv->id); + g_free (server->priv->parent_socket); + G_OBJECT_CLASS (mir_server_parent_class)->finalize (object); } diff --git a/src/mir-server.h b/src/mir-server.h index bf90d97b..d91ec560 100644 --- a/src/mir-server.h +++ b/src/mir-server.h @@ -40,6 +40,14 @@ GType mir_server_get_type (void); MirServer *mir_server_new (void); +void mir_server_set_vt (MirServer *server, gint vt); + +void mir_server_set_parent_socket (MirServer *server, const gchar *parent_socket); + +void mir_server_set_id (MirServer *server, const gchar *id); + +const gchar *mir_server_get_id (MirServer *server); + G_END_DECLS #endif /* MIR_SERVER_H_ */ diff --git a/src/seat-unity.c b/src/seat-unity.c index c253fe23..e40c14c0 100644 --- a/src/seat-unity.c +++ b/src/seat-unity.c @@ -398,21 +398,11 @@ create_x_server (Seat *seat) const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL; gboolean allow_tcp; gint port = 0; - gchar *id; g_debug ("Starting X server on Unity compositor"); x_server = x_server_local_new (); - if (!SEAT_UNITY (seat)->priv->use_vt_switching) - { - id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id); - SEAT_UNITY (seat)->priv->next_id++; - x_server_local_set_mir_id (x_server, id); - x_server_local_set_mir_socket (x_server, SEAT_UNITY (seat)->priv->mir_socket_filename); - g_free (id); - } - command = seat_get_string_property (seat, "xserver-command"); if (command) x_server_local_set_command (x_server, command); @@ -426,6 +416,16 @@ create_x_server (Seat *seat) x_server_local_set_vt (x_server, vt); g_signal_connect (x_server, "stopped", G_CALLBACK (x_server_stopped_cb), seat); } + else + { + gchar *id; + + id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id); + SEAT_UNITY (seat)->priv->next_id++; + x_server_local_set_mir_id (x_server, id); + x_server_local_set_mir_socket (x_server, SEAT_UNITY (seat)->priv->mir_socket_filename); + g_free (id); + } layout = seat_get_string_property (seat, "xserver-layout"); if (layout) @@ -486,12 +486,36 @@ create_x_server (Seat *seat) } static DisplayServer * +create_mir_server (Seat *seat) +{ + MirServer *mir_server; + + mir_server = mir_server_new (); + mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename); + + if (SEAT_UNITY (seat)->priv->use_vt_switching) + mir_server_set_vt (mir_server, vt_get_unused ()); + else + { + gchar *id; + + id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id); + SEAT_UNITY (seat)->priv->next_id++; + mir_server_set_id (mir_server, id); + mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename); + g_free (id); + } + + return DISPLAY_SERVER (mir_server); +} + +static DisplayServer * seat_unity_create_display_server (Seat *seat, const gchar *session_type) { if (strcmp (session_type, "x") == 0) return create_x_server (seat); else if (strcmp (session_type, "mir") == 0) - return DISPLAY_SERVER (mir_server_new ()); + return create_mir_server (seat); else { g_warning ("Can't create unsupported display server '%s'", session_type); @@ -544,13 +568,22 @@ seat_unity_set_active_session (Seat *seat, Session *session) display_server = session_get_display_server (session); if (SEAT_UNITY (seat)->priv->active_display_server != display_server) { - const gchar *id; + const gchar *id = NULL; SEAT_UNITY (seat)->priv->active_display_server = g_object_ref (display_server); - id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server)); - g_debug ("Switching to Mir session %s", id); - write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id)); + if (IS_X_SERVER_LOCAL (display_server)) + id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server)); + else if (IS_MIR_SERVER (display_server)) + id = mir_server_get_id (MIR_SERVER (display_server)); + + if (id) + { + g_debug ("Switching to Mir session %s", id); + write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id)); + } + else + g_warning ("Failed to work out session ID"); } SEAT_CLASS (seat_unity_parent_class)->set_active_session (seat, session); diff --git a/tests/scripts/unity-mir-login.conf b/tests/scripts/unity-mir-login.conf index d440c78b..a0aabd61 100644 --- a/tests/scripts/unity-mir-login.conf +++ b/tests/scripts/unity-mir-login.conf @@ -9,7 +9,7 @@ user-session=default #?RUNNER DAEMON-START # System compositor starts -#?UNITY-SYSTEM-COMPOSITOR START +#?UNITY-SYSTEM-COMPOSITOR START VT=7 #?*UNITY-SYSTEM-COMPOSITOR READY # Greeter starts diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c index dd06c728..a2f7bb0c 100644 --- a/tests/src/test-gobject-greeter.c +++ b/tests/src/test-gobject-greeter.c @@ -299,19 +299,28 @@ user_removed_cb (LightDMUserList *user_list, LightDMUser *user) int main (int argc, char **argv) { - gchar *display; + gchar *display, *mir_socket, *mir_id; #if !defined(GLIB_VERSION_2_36) g_type_init (); #endif display = getenv ("DISPLAY"); - if (display == NULL) - greeter_id = g_strdup ("GREETER-?"); - else if (display[0] == ':') - greeter_id = g_strdup_printf ("GREETER-X-%s", display + 1); + mir_socket = getenv ("MIR_SERVER_FILE"); + mir_id = getenv ("MIR_ID"); + if (display) + { + if (display[0] == ':') + greeter_id = g_strdup_printf ("GREETER-X-%s", display + 1); + else + greeter_id = g_strdup_printf ("GREETER-X-%s", display); + } + else if (mir_id) + greeter_id = g_strdup_printf ("GREETER-MIR-%s", mir_id); + else if (mir_socket) + greeter_id = g_strdup ("GREETER-MIR"); else - greeter_id = g_strdup_printf ("GREETER-X-%s", display); + greeter_id = g_strdup ("GREETER-?"); loop = g_main_loop_new (NULL, FALSE); diff --git a/tests/src/test-session.c b/tests/src/test-session.c index 6940cbdb..12c3a3b7 100644 --- a/tests/src/test-session.c +++ b/tests/src/test-session.c @@ -167,11 +167,12 @@ request_cb (const gchar *request) int main (int argc, char **argv) { - gchar *display, *mir_socket; + gchar *display, *mir_socket, *mir_id; int fd, open_max; display = getenv ("DISPLAY"); - mir_socket = getenv ("DISPLAY"); + mir_socket = getenv ("MIR_SERVER_FILE"); + mir_id = getenv ("MIR_ID"); if (display) { if (display[0] == ':') @@ -179,6 +180,8 @@ main (int argc, char **argv) else session_id = g_strdup_printf ("SESSION-X-%s", display); } + else if (mir_id) + session_id = g_strdup_printf ("SESSION-MIR-%s", mir_id); else if (mir_socket) session_id = g_strdup ("SESSION-MIR"); else |