aboutsummaryrefslogtreecommitdiff
path: root/backend/session/session.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-05 23:11:26 -0400
committerGitHub <noreply@github.com>2017-08-05 23:11:26 -0400
commitf95c02eebe54785a4f64332f7e574dddff7e3669 (patch)
tree0e29dfa81a30d6172c558d2b5df6d95f31a32b20 /backend/session/session.c
parent41b98f21e50a6d57ba4b7fd8ba90066bba614e6a (diff)
parent5bf61ca7edb658737f3ccbaed0a99f4779d329bb (diff)
Merge pull request #29 from ascent12/session
Moved session into backend/session and changed ownership
Diffstat (limited to 'backend/session/session.c')
-rw-r--r--backend/session/session.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/backend/session/session.c b/backend/session/session.c
new file mode 100644
index 00000000..a07d3cda
--- /dev/null
+++ b/backend/session/session.c
@@ -0,0 +1,54 @@
+#include <stddef.h>
+#include <stdarg.h>
+#include <wlr/backend/session.h>
+#include <wlr/backend/session/interface.h>
+#include <wlr/util/log.h>
+
+extern const struct session_impl session_logind;
+extern const struct session_impl session_direct;
+
+static const struct session_impl *impls[] = {
+#ifdef HAS_SYSTEMD
+ &session_logind,
+#endif
+ &session_direct,
+ NULL,
+};
+
+struct wlr_session *wlr_session_start(struct wl_display *disp) {
+ const struct session_impl **iter;
+
+ for (iter = impls; *iter; ++iter) {
+ struct wlr_session *session = (*iter)->start(disp);
+ if (session) {
+ return session;
+ }
+ }
+
+ wlr_log(L_ERROR, "Failed to load session backend");
+ return NULL;
+}
+
+void wlr_session_finish(struct wlr_session *session) {
+ if (!session) {
+ return;
+ }
+
+ session->impl->finish(session);
+};
+
+int wlr_session_open_file(struct wlr_session *session, const char *path) {
+ return session->impl->open(session, path);
+}
+
+void wlr_session_close_file(struct wlr_session *session, int fd) {
+ session->impl->close(session, fd);
+}
+
+bool wlr_session_change_vt(struct wlr_session *session, unsigned vt) {
+ if (!session) {
+ return false;
+ }
+
+ return session->impl->change_vt(session, vt);
+}