aboutsummaryrefslogtreecommitdiff
path: root/backend/session/session.c
blob: a07d3cda4f8c55f32af5e536ecf66ae693b80655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
}