From 1cd178e9ce21e581f363fb0fcf1e49919602ac1a Mon Sep 17 00:00:00 2001 From: Keith Bowes Date: Tue, 18 Feb 2020 07:37:19 -0500 Subject: [PATCH] Basic seat support --- include/waybox/seat.h | 16 ++++++++++++++++ include/waybox/server.h | 2 ++ waybox/meson.build | 1 + waybox/seat.c | 15 +++++++++++++++ waybox/server.c | 2 ++ 5 files changed, 36 insertions(+) create mode 100644 include/waybox/seat.h create mode 100644 waybox/seat.c diff --git a/include/waybox/seat.h b/include/waybox/seat.h new file mode 100644 index 0000000..caf13d1 --- /dev/null +++ b/include/waybox/seat.h @@ -0,0 +1,16 @@ +#ifndef _WB_SEAT_H +#define _WB_SEAT_H + +#include + +#include "waybox/server.h" + +struct wb_seat { + struct wlr_seat * seat; +}; + +struct wb_server; +struct wb_seat * wb_seat_create(struct wb_server * server); + +void wb_seat_destroy(struct wb_seat * seat); +#endif diff --git a/include/waybox/server.h b/include/waybox/server.h index 3a9b63a..b288196 100644 --- a/include/waybox/server.h +++ b/include/waybox/server.h @@ -24,6 +24,7 @@ #include "waybox/output.h" #include "waybox/cursor.h" +#include "waybox/seat.h" struct wb_server { struct wl_display *wl_display; @@ -34,6 +35,7 @@ struct wb_server { struct wlr_output_layout *layout; struct wb_cursor *cursor; + struct wb_seat * seat; struct wl_listener new_output; struct wl_listener new_input; diff --git a/waybox/meson.build b/waybox/meson.build index a44d004..55eabf7 100644 --- a/waybox/meson.build +++ b/waybox/meson.build @@ -2,6 +2,7 @@ wb_src = files( 'cursor.c', 'main.c', 'output.c', + 'seat.c', 'server.c', ) diff --git a/waybox/seat.c b/waybox/seat.c new file mode 100644 index 0000000..dbd0f2a --- /dev/null +++ b/waybox/seat.c @@ -0,0 +1,15 @@ +#include + +#include "waybox/seat.h" + +struct wb_seat * wb_seat_create(struct wb_server * server) { + struct wb_seat * seat = malloc(sizeof(struct wb_seat)); + seat->seat = wlr_seat_create(server->wl_display, "seat0"); + wlr_seat_set_capabilities(seat->seat, WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD); + return seat; +} + +void wb_seat_destroy(struct wb_seat * seat) { + wlr_seat_destroy(seat->seat); + free(seat); +} diff --git a/waybox/server.c b/waybox/server.c index 53772f5..8f26142 100644 --- a/waybox/server.c +++ b/waybox/server.c @@ -36,6 +36,7 @@ bool init_wb(struct wb_server* server) { server->layout = wlr_output_layout_create(); server->cursor = wb_cursor_create(); wlr_cursor_attach_output_layout(server->cursor->cursor, server->layout); + server->seat = wb_seat_create(server); return true; } @@ -81,6 +82,7 @@ bool terminate_wb(struct wb_server* server) { printf("Display destroyed.\n"); wb_cursor_destroy(server->cursor); + wb_seat_destroy(server->seat); wlr_output_layout_destroy(server->layout); return true;