2017-05-03 02:11:22 +00:00
|
|
|
#include <stddef.h>
|
2017-05-03 04:23:07 +00:00
|
|
|
#include <stdarg.h>
|
2017-07-11 07:18:34 +00:00
|
|
|
#include <wlr/backend/session.h>
|
|
|
|
#include <wlr/backend/session/interface.h>
|
2017-06-21 16:10:07 +00:00
|
|
|
#include <wlr/util/log.h>
|
2017-05-03 02:11:22 +00:00
|
|
|
|
2017-06-04 23:30:37 +00:00
|
|
|
extern const struct session_impl session_logind;
|
|
|
|
extern const struct session_impl session_direct;
|
|
|
|
|
|
|
|
static const struct session_impl *impls[] = {
|
2017-05-03 02:11:22 +00:00
|
|
|
#ifdef HAS_SYSTEMD
|
2017-06-04 23:30:37 +00:00
|
|
|
&session_logind,
|
2017-05-03 02:11:22 +00:00
|
|
|
#endif
|
2017-06-04 23:30:37 +00:00
|
|
|
&session_direct,
|
2017-05-03 02:11:22 +00:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2017-05-13 11:56:40 +00:00
|
|
|
struct wlr_session *wlr_session_start(struct wl_display *disp) {
|
2017-06-04 23:30:37 +00:00
|
|
|
const struct session_impl **iter;
|
2017-05-03 02:11:22 +00:00
|
|
|
|
2017-06-04 23:30:37 +00:00
|
|
|
for (iter = impls; *iter; ++iter) {
|
2017-05-13 11:56:40 +00:00
|
|
|
struct wlr_session *session = (*iter)->start(disp);
|
2017-05-03 02:11:22 +00:00
|
|
|
if (session) {
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-03 04:23:07 +00:00
|
|
|
wlr_log(L_ERROR, "Failed to load session backend");
|
2017-05-03 02:11:22 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_session_finish(struct wlr_session *session) {
|
2017-07-11 06:51:19 +00:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-04 23:30:37 +00:00
|
|
|
session->impl->finish(session);
|
2017-05-03 02:11:22 +00:00
|
|
|
};
|
|
|
|
|
2017-07-09 05:53:13 +00:00
|
|
|
int wlr_session_open_file(struct wlr_session *session, const char *path) {
|
2017-06-04 23:30:37 +00:00
|
|
|
return session->impl->open(session, path);
|
2017-05-03 02:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_session_close_file(struct wlr_session *session, int fd) {
|
2017-06-04 23:30:37 +00:00
|
|
|
session->impl->close(session, fd);
|
2017-05-03 02:11:22 +00:00
|
|
|
}
|
2017-05-13 11:56:40 +00:00
|
|
|
|
2017-07-09 05:53:13 +00:00
|
|
|
bool wlr_session_change_vt(struct wlr_session *session, unsigned vt) {
|
2017-07-11 06:51:19 +00:00
|
|
|
if (!session) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-04 23:30:37 +00:00
|
|
|
return session->impl->change_vt(session, vt);
|
2017-05-13 11:56:40 +00:00
|
|
|
}
|