2017-05-03 09:26:43 +02:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
2017-05-13 13:56:40 +02:00
|
|
|
#include <stdbool.h>
|
2017-05-03 09:26:43 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <wayland-server.h>
|
2017-06-05 01:30:37 +02:00
|
|
|
#include <wlr/session/interface.h>
|
2017-06-21 18:10:07 +02:00
|
|
|
#include <wlr/util/log.h>
|
2017-05-03 09:26:43 +02:00
|
|
|
|
2017-06-05 01:30:37 +02:00
|
|
|
const struct session_impl session_direct;
|
|
|
|
|
2017-05-03 09:26:43 +02:00
|
|
|
struct direct_session {
|
|
|
|
struct wlr_session base;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int direct_session_open(struct wlr_session *restrict base,
|
|
|
|
const char *restrict path) {
|
|
|
|
return open(path, O_RDWR | O_CLOEXEC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void direct_session_close(struct wlr_session *base, int fd) {
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:56:40 +02:00
|
|
|
static bool direct_change_vt(struct wlr_session *base, int vt) {
|
|
|
|
// TODO
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-03 09:26:43 +02:00
|
|
|
static void direct_session_finish(struct wlr_session *base) {
|
|
|
|
struct direct_session *session = wl_container_of(base, session, base);
|
|
|
|
|
|
|
|
free(session);
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:56:40 +02:00
|
|
|
static struct wlr_session *direct_session_start(struct wl_display *disp) {
|
2017-05-03 09:26:43 +02:00
|
|
|
struct direct_session *session = calloc(1, sizeof(*session));
|
|
|
|
if (!session) {
|
|
|
|
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_log(L_INFO, "Successfully loaded direct session");
|
|
|
|
|
2017-06-05 01:30:37 +02:00
|
|
|
session->base.impl = &session_direct;
|
2017-06-21 02:47:53 +02:00
|
|
|
session->base.active = true;
|
|
|
|
wl_signal_init(&session->base.session_signal);
|
2017-05-03 09:26:43 +02:00
|
|
|
return &session->base;
|
|
|
|
}
|
|
|
|
|
2017-06-05 01:30:37 +02:00
|
|
|
const struct session_impl session_direct = {
|
2017-05-03 09:26:43 +02:00
|
|
|
.start = direct_session_start,
|
|
|
|
.finish = direct_session_finish,
|
|
|
|
.open = direct_session_open,
|
|
|
|
.close = direct_session_close,
|
2017-05-13 13:56:40 +02:00
|
|
|
.change_vt = direct_change_vt,
|
2017-05-03 09:26:43 +02:00
|
|
|
};
|