summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2015-07-28 20:38:40 +1200
committerRobert Ancell <robert.ancell@canonical.com>2015-07-28 20:38:40 +1200
commitf4f681f7b4209a634b021ba731addec1e081e5c7 (patch)
tree86241140b6c905cb0aff776d4742b908e67b4c9a /src
parent2db3a8b2e819ae50442688b2c75f77b6a14fbbdc (diff)
downloadlightdm-f4f681f7b4209a634b021ba731addec1e081e5c7.tar.gz
Support Wayland sessions / greeters
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/seat-xlocal.c18
-rw-r--r--src/seat.c6
-rw-r--r--src/session-config.c4
-rw-r--r--src/session-config.h2
-rw-r--r--src/wayland-session.c106
-rw-r--r--src/wayland-session.h45
7 files changed, 181 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index fc6f7f25..18e8240f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,8 @@ lightdm_SOURCES = \
vnc-server.h \
vt.c \
vt.h \
+ wayland-session.c \
+ wayland-session.h \
x-authority.c \
x-authority.h \
x-server-local.c \
@@ -78,7 +80,8 @@ lightdm_CFLAGS = \
-DLOG_DIR=\"$(localstatedir)/log/lightdm\" \
-DRUN_DIR=\"$(localstatedir)/run/lightdm\" \
-DCACHE_DIR=\"$(localstatedir)/cache/lightdm\" \
- -DSESSIONS_DIR=\"$(pkgdatadir)/sessions:$(datadir)/xsessions\" \
+ -DSESSIONS_DIR=\"$(pkgdatadir)/sessions:$(datadir)/xsessions:$(datadir)/wayland-sessions\" \
+ -DWAYLAND_SESSIONS_DIR=\"$(datadir)/wayland-sessions\" \
-DREMOTE_SESSIONS_DIR=\"$(pkgdatadir)/remote-sessions\" \
-DGREETERS_DIR=\"$(pkgdatadir)/greeters:$(datadir)/xgreeters\"
diff --git a/src/seat-xlocal.c b/src/seat-xlocal.c
index 7b5ec7ed..74cf183e 100644
--- a/src/seat-xlocal.c
+++ b/src/seat-xlocal.c
@@ -15,6 +15,7 @@
#include "configuration.h"
#include "x-server-local.h"
#include "unity-system-compositor.h"
+#include "wayland-session.h"
#include "plymouth.h"
#include "vt.h"
@@ -248,6 +249,21 @@ create_unity_system_compositor (Seat *seat)
}
static DisplayServer *
+create_wayland_session (Seat *seat)
+{
+ WaylandSession *session;
+ gint vt;
+
+ session = wayland_session_new ();
+
+ vt = get_vt (seat, DISPLAY_SERVER (session));
+ if (vt >= 0)
+ wayland_session_set_vt (session, vt);
+
+ return DISPLAY_SERVER (session);
+}
+
+static DisplayServer *
seat_xlocal_create_display_server (Seat *seat, Session *session)
{
const gchar *session_type;
@@ -257,6 +273,8 @@ seat_xlocal_create_display_server (Seat *seat, Session *session)
return DISPLAY_SERVER (create_x_server (seat));
else if (strcmp (session_type, "mir") == 0)
return create_unity_system_compositor (seat);
+ else if (strcmp (session_type, "wayland") == 0)
+ return create_wayland_session (seat);
else if (strcmp (session_type, "mir-container") == 0)
{
DisplayServer *compositor;
diff --git a/src/seat.c b/src/seat.c
index f9b149dd..ca1621b3 100644
--- a/src/seat.c
+++ b/src/seat.c
@@ -962,11 +962,15 @@ find_session_config (Seat *seat, const gchar *sessions_dir, const gchar *session
for (i = 0; dirs[i]; i++)
{
gchar *filename, *path;
+ const gchar *default_session_type = "x";
+
+ if (strcmp (dirs[i], WAYLAND_SESSIONS_DIR) == 0)
+ default_session_type = "wayland";
filename = g_strdup_printf ("%s.desktop", session_name);
path = g_build_filename (dirs[i], filename, NULL);
g_free (filename);
- session_config = session_config_new_from_file (path, &error);
+ session_config = session_config_new_from_file (path, default_session_type, &error);
g_free (path);
if (session_config)
break;
diff --git a/src/session-config.c b/src/session-config.c
index b5ea7228..34f3a970 100644
--- a/src/session-config.c
+++ b/src/session-config.c
@@ -29,7 +29,7 @@ struct SessionConfigPrivate
G_DEFINE_TYPE (SessionConfig, session_config, G_TYPE_OBJECT);
SessionConfig *
-session_config_new_from_file (const gchar *filename, GError **error)
+session_config_new_from_file (const gchar *filename, const gchar *default_session_type, GError **error)
{
GKeyFile *desktop_file;
SessionConfig *config;
@@ -52,7 +52,7 @@ session_config_new_from_file (const gchar *filename, GError **error)
config->priv->command = command;
config->priv->session_type = g_key_file_get_string (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "X-LightDM-Session-Type", NULL);
if (!config->priv->session_type)
- config->priv->session_type = g_strdup ("x");
+ config->priv->session_type = g_strdup (default_session_type);
config->priv->desktop_names = g_key_file_get_string_list (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "DesktopNames", NULL, NULL);
if (!config->priv->desktop_names)
diff --git a/src/session-config.h b/src/session-config.h
index 2d3d5288..aea59599 100644
--- a/src/session-config.h
+++ b/src/session-config.h
@@ -36,7 +36,7 @@ typedef struct
GType session_config_get_type (void);
-SessionConfig *session_config_new_from_file (const gchar *filename, GError **error);
+SessionConfig *session_config_new_from_file (const gchar *filename, const gchar *default_session_type, GError **error);
const gchar *session_config_get_command (SessionConfig *config);
diff --git a/src/wayland-session.c b/src/wayland-session.c
new file mode 100644
index 00000000..19a50aa5
--- /dev/null
+++ b/src/wayland-session.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd.
+ * Author: Robert Ancell <robert.ancell@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include "wayland-session.h"
+#include "vt.h"
+
+struct WaylandSessionPrivate
+{
+ /* VT to run on */
+ gint vt;
+ gboolean have_vt_ref;
+};
+
+G_DEFINE_TYPE (WaylandSession, wayland_session, DISPLAY_SERVER_TYPE);
+
+WaylandSession *
+wayland_session_new (void)
+{
+ return g_object_new (WAYLAND_SESSION_TYPE, NULL);
+}
+
+void
+wayland_session_set_vt (WaylandSession *session, gint vt)
+{
+ g_return_if_fail (session != NULL);
+
+ if (session->priv->have_vt_ref)
+ vt_unref (session->priv->vt);
+ session->priv->have_vt_ref = FALSE;
+ session->priv->vt = vt;
+ if (vt > 0)
+ {
+ vt_ref (vt);
+ session->priv->have_vt_ref = TRUE;
+ }
+}
+
+static gint
+wayland_session_get_vt (DisplayServer *server)
+{
+ g_return_val_if_fail (server != NULL, 0);
+ return WAYLAND_SESSION (server)->priv->vt;
+}
+
+static void
+wayland_session_connect_session (DisplayServer *display_server, Session *session)
+{
+ WaylandSession *wayland_session = WAYLAND_SESSION (display_server);
+
+ session_set_env (session, "XDG_SESSION_TYPE", "wayland");
+
+ if (wayland_session->priv->vt >= 0)
+ {
+ gchar *value = g_strdup_printf ("%d", wayland_session->priv->vt);
+ session_set_env (session, "XDG_VTNR", value);
+ g_free (value);
+ }
+}
+
+static void
+wayland_session_disconnect_session (DisplayServer *display_server, Session *session)
+{
+ session_unset_env (session, "XDG_SESSION_TYPE");
+ session_unset_env (session, "XDG_VTNR");
+}
+
+static void
+wayland_session_init (WaylandSession *session)
+{
+ session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, WAYLAND_SESSION_TYPE, WaylandSessionPrivate);
+}
+
+static void
+wayland_session_finalize (GObject *object)
+{
+ WaylandSession *self;
+
+ self = WAYLAND_SESSION (object);
+
+ if (self->priv->have_vt_ref)
+ vt_unref (self->priv->vt);
+
+ G_OBJECT_CLASS (wayland_session_parent_class)->finalize (object);
+}
+
+static void
+wayland_session_class_init (WaylandSessionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ DisplayServerClass *display_server_class = DISPLAY_SERVER_CLASS (klass);
+
+ display_server_class->get_vt = wayland_session_get_vt;
+ display_server_class->connect_session = wayland_session_connect_session;
+ display_server_class->disconnect_session = wayland_session_disconnect_session;
+ object_class->finalize = wayland_session_finalize;
+
+ g_type_class_add_private (klass, sizeof (WaylandSessionPrivate));
+}
diff --git a/src/wayland-session.h b/src/wayland-session.h
new file mode 100644
index 00000000..79282ca6
--- /dev/null
+++ b/src/wayland-session.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd.
+ * Author: Robert Ancell <robert.ancell@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef WAYLAND_SESSION_H_
+#define WAYLAND_SESSION_H_
+
+#include <glib-object.h>
+#include "display-server.h"
+
+G_BEGIN_DECLS
+
+#define WAYLAND_SESSION_TYPE (wayland_session_get_type())
+#define WAYLAND_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WAYLAND_SESSION_TYPE, WaylandSession))
+#define IS_WAYLAND_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WAYLAND_SESSION_TYPE))
+
+typedef struct WaylandSessionPrivate WaylandSessionPrivate;
+
+typedef struct
+{
+ DisplayServer parent_instance;
+ WaylandSessionPrivate *priv;
+} WaylandSession;
+
+typedef struct
+{
+ DisplayServerClass parent_class;
+} WaylandSessionClass;
+
+GType wayland_session_get_type (void);
+
+WaylandSession *wayland_session_new (void);
+
+void wayland_session_set_vt (WaylandSession *session, gint vt);
+
+G_END_DECLS
+
+#endif /* WAYLAND_SESSION_H_ */