diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-05-03 19:26:43 +1200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-05-03 19:26:43 +1200 |
commit | 0002b8dd08fdab7da12127ad2f43238f376b1a7a (patch) | |
tree | 5c16cb9724e298ff1e831dbfcc0a818e2018b3c0 /session/direct.c | |
parent | 18387468bb9936d0e311c4a46535cfa93df277dc (diff) |
Added 'direct' session backend
Diffstat (limited to 'session/direct.c')
-rw-r--r-- | session/direct.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/session/direct.c b/session/direct.c new file mode 100644 index 00000000..08a9b617 --- /dev/null +++ b/session/direct.c @@ -0,0 +1,50 @@ +#define _POSIX_C_SOURCE 200809L + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <wayland-server.h> + +#include "session/interface.h" +#include "common/log.h" + +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); +} + +static void direct_session_finish(struct wlr_session *base) { + struct direct_session *session = wl_container_of(base, session, base); + + free(session); +} + +static struct wlr_session *direct_session_start(void) { + 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"); + + session->base.iface = session_direct_iface; + return &session->base; +} + +const struct session_interface session_direct_iface = { + .start = direct_session_start, + .finish = direct_session_finish, + .open = direct_session_open, + .close = direct_session_close, +}; |