aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/backend/wayland.h2
-rw-r--r--include/rootston/config.h51
-rw-r--r--include/rootston/desktop.h59
-rw-r--r--include/rootston/ini.h93
-rw-r--r--include/rootston/input.h113
-rw-r--r--include/rootston/server.h34
-rw-r--r--include/rootston/view.h57
-rw-r--r--include/wlr/interfaces/wlr_keyboard.h2
-rw-r--r--include/wlr/types/wlr_keyboard.h13
-rw-r--r--include/wlr/types/wlr_seat.h54
10 files changed, 454 insertions, 24 deletions
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index 917a798a..752dab69 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -1,6 +1,7 @@
#ifndef BACKEND_WAYLAND_H
#define BACKEND_WAYLAND_H
+#include <stdbool.h>
#include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-egl.h>
@@ -14,6 +15,7 @@ struct wlr_wl_backend {
struct wlr_backend backend;
/* local state */
+ bool started;
struct wl_display *local_display;
list_t *devices;
list_t *outputs;
diff --git a/include/rootston/config.h b/include/rootston/config.h
new file mode 100644
index 00000000..0832d88d
--- /dev/null
+++ b/include/rootston/config.h
@@ -0,0 +1,51 @@
+#ifndef _ROOTSTON_CONFIG_H
+#define _ROOTSTON_CONFIG_H
+#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_cursor.h>
+
+struct output_config {
+ char *name;
+ enum wl_output_transform transform;
+ int x, y;
+ struct wl_list link;
+};
+
+struct device_config {
+ char *name;
+ char *mapped_output;
+ struct wlr_box *mapped_box;
+ struct wl_list link;
+};
+
+struct roots_config {
+ // TODO: Multiple cursors, multiseat
+ struct {
+ char *mapped_output;
+ struct wlr_box *mapped_box;
+ } cursor;
+
+ struct wl_list outputs;
+ struct wl_list devices;
+ char *config_path;
+};
+
+struct roots_config *parse_args(int argc, char *argv[]);
+
+void roots_config_destroy(struct roots_config *config);
+
+/**
+ * Get configuration for the output. If the output is not configured, returns
+ * NULL.
+ */
+struct output_config *config_get_output(struct roots_config *config,
+ struct wlr_output *output);
+
+/**
+ * Get configuration for the device. If the device is not configured, returns
+ * NULL.
+ */
+struct device_config *config_get_device(struct roots_config *config,
+ struct wlr_input_device *device);
+
+#endif
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
new file mode 100644
index 00000000..62050972
--- /dev/null
+++ b/include/rootston/desktop.h
@@ -0,0 +1,59 @@
+#ifndef _ROOTSTON_DESKTOP_H
+#define _ROOTSTON_DESKTOP_H
+#include <time.h>
+#include <wayland-server.h>
+#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_wl_shell.h>
+#include <wlr/types/wlr_xdg_shell_v6.h>
+#include <wlr/types/wlr_gamma_control.h>
+#include "rootston/view.h"
+#include "rootston/config.h"
+
+struct roots_output {
+ struct roots_desktop *desktop;
+ struct wlr_output *wlr_output;
+ struct wl_listener frame;
+ struct wl_listener resolution;
+ struct timespec last_frame;
+ struct wl_list link;
+};
+
+struct roots_desktop {
+ struct wl_list views;
+
+ struct wl_list outputs;
+ struct timespec last_frame;
+
+ struct roots_server *server;
+ struct roots_config *config;
+
+ struct wlr_output_layout *layout;
+
+ struct wlr_compositor *compositor;
+ struct wlr_wl_shell *wl_shell;
+ struct wlr_xdg_shell_v6 *xdg_shell_v6;
+ struct wlr_gamma_control_manager *gamma_control_manager;
+
+ struct wl_listener output_add;
+ struct wl_listener output_remove;
+ struct wl_listener xdg_shell_v6_surface;
+};
+
+struct roots_server;
+
+struct roots_desktop *desktop_create(struct roots_server *server,
+ struct roots_config *config);
+void desktop_destroy(struct roots_desktop *desktop);
+
+void view_destroy(struct roots_view *view);
+struct roots_view *view_at(struct roots_desktop *desktop, int x, int y);
+void view_activate(struct roots_view *view, bool activate);
+
+void output_add_notify(struct wl_listener *listener, void *data);
+void output_remove_notify(struct wl_listener *listener, void *data);
+
+void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
+
+#endif
diff --git a/include/rootston/ini.h b/include/rootston/ini.h
new file mode 100644
index 00000000..2804255b
--- /dev/null
+++ b/include/rootston/ini.h
@@ -0,0 +1,93 @@
+/* inih -- simple .INI file parser
+
+inih is released under the New BSD license (see LICENSE.txt). Go to the project
+home page for more info:
+
+https://github.com/benhoyt/inih
+
+*/
+
+#ifndef __INI_H__
+#define __INI_H__
+
+/* Make this header file easier to include in C++ code */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+/* Typedef for prototype of handler function. */
+typedef int (*ini_handler)(void* user, const char* section,
+ const char* name, const char* value);
+
+/* Typedef for prototype of fgets-style reader function. */
+typedef char* (*ini_reader)(char* str, int num, void* stream);
+
+/* Parse given INI-style file. May have [section]s, name=value pairs
+ (whitespace stripped), and comments starting with ';' (semicolon). Section
+ is "" if name=value pair parsed before any section heading. name:value
+ pairs are also supported as a concession to Python's configparser.
+
+ For each name=value pair parsed, call handler function with given user
+ pointer as well as section, name, and value (data only valid for duration
+ of handler call). Handler should return nonzero on success, zero on error.
+
+ Returns 0 on success, line number of first error on parse error (doesn't
+ stop on first error), -1 on file open error, or -2 on memory allocation
+ error (only when INI_USE_STACK is zero).
+*/
+int ini_parse(const char* filename, ini_handler handler, void* user);
+
+/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
+ close the file when it's finished -- the caller must do that. */
+int ini_parse_file(FILE* file, ini_handler handler, void* user);
+
+/* Same as ini_parse(), but takes an ini_reader function pointer instead of
+ filename. Used for implementing custom or string-based I/O. */
+int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
+ void* user);
+
+/* Nonzero to allow multi-line value parsing, in the style of Python's
+ configparser. If allowed, ini_parse() will call the handler with the same
+ name for each subsequent line parsed. */
+#ifndef INI_ALLOW_MULTILINE
+#define INI_ALLOW_MULTILINE 1
+#endif
+
+/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
+ the file. See http://code.google.com/p/inih/issues/detail?id=21 */
+#ifndef INI_ALLOW_BOM
+#define INI_ALLOW_BOM 1
+#endif
+
+/* Nonzero to allow inline comments (with valid inline comment characters
+ specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
+ Python 3.2+ configparser behaviour. */
+#ifndef INI_ALLOW_INLINE_COMMENTS
+#define INI_ALLOW_INLINE_COMMENTS 1
+#endif
+#ifndef INI_INLINE_COMMENT_PREFIXES
+#define INI_INLINE_COMMENT_PREFIXES ";"
+#endif
+
+/* Nonzero to use stack, zero to use heap (malloc/free). */
+#ifndef INI_USE_STACK
+#define INI_USE_STACK 1
+#endif
+
+/* Stop parsing on first error (default is to keep parsing). */
+#ifndef INI_STOP_ON_FIRST_ERROR
+#define INI_STOP_ON_FIRST_ERROR 0
+#endif
+
+/* Maximum line length for any line in INI file. */
+#ifndef INI_MAX_LINE
+#define INI_MAX_LINE 2000
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INI_H__ */
diff --git a/include/rootston/input.h b/include/rootston/input.h
new file mode 100644
index 00000000..ec1cd32d
--- /dev/null
+++ b/include/rootston/input.h
@@ -0,0 +1,113 @@
+#ifndef _ROOTSTON_INPUT_H
+#define _ROOTSTON_INPUT_H
+#include <xkbcommon/xkbcommon.h>
+#include <wayland-server.h>
+#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_cursor.h>
+#include <wlr/types/wlr_seat.h>
+#include <wlr/xcursor.h>
+#include "rootston/config.h"
+#include "rootston/view.h"
+#include "rootston/server.h"
+
+struct roots_keyboard {
+ struct roots_input *input;
+ struct wlr_input_device *device;
+ struct wl_listener key;
+ struct wl_list link;
+ struct xkb_keymap *keymap;
+ struct xkb_state *xkb_state;
+ xkb_led_index_t leds[WLR_LED_LAST];
+ int keymap_fd;
+ size_t keymap_size;
+};
+
+struct roots_pointer {
+ struct roots_input *input;
+ struct wlr_input_device *device;
+ // We don't listen to any pointer events directly - they go through
+ // wlr_cursor
+ struct wl_list link;
+};
+
+struct roots_touch {
+ struct roots_input *input;
+ struct wlr_input_device *device;
+ struct wl_listener down;
+ struct wl_listener up;
+ struct wl_listener motion;
+ struct wl_listener cancel;
+ struct wl_list link;
+};
+
+// TODO: tablet pad
+struct roots_tablet_tool {
+ struct roots_input *input;
+ struct wlr_input_device *device;
+ struct wl_listener axis;
+ struct wl_listener proximity;
+ struct wl_listener tip;
+ struct wl_listener button;
+ struct wl_list link;
+};
+
+enum roots_cursor_mode {
+ ROOTS_CURSOR_PASSTHROUGH = 0,
+ ROOTS_CURSOR_MOVE = 1,
+ ROOTS_CURSOR_RESIZE = 2,
+ ROOTS_CURSOR_ROTATE = 3,
+};
+
+struct roots_input_event {
+ uint32_t serial;
+ struct wlr_cursor *cursor;
+ struct wlr_input_device *device;
+};
+
+struct roots_input {
+ struct roots_config *config;
+ struct roots_server *server;
+
+ // TODO: multiseat, multicursor
+ struct wlr_cursor *cursor;
+ struct wlr_xcursor *xcursor;
+ struct wlr_seat *wl_seat;
+
+ enum roots_cursor_mode mode;
+ struct roots_view *active_view;
+ int offs_x, offs_y;
+
+ // Ring buffer of input events that could trigger move/resize/rotate
+ int input_events_idx;
+ struct roots_input_event input_events[16];
+
+ struct wl_list keyboards;
+ struct wl_list pointers;
+ struct wl_list touch;
+ struct wl_list tablet_tools;
+
+ struct wl_listener input_add;
+ struct wl_listener input_remove;
+
+ struct wl_listener cursor_motion;
+ struct wl_listener cursor_motion_absolute;
+ struct wl_listener cursor_button;
+ struct wl_listener cursor_axis;
+ struct wl_listener cursor_tool_axis;
+ struct wl_listener cursor_tool_tip;
+};
+
+struct roots_input *input_create(struct roots_server *server,
+ struct roots_config *config);
+void input_destroy(struct roots_input *input);
+
+void pointer_add(struct wlr_input_device *device, struct roots_input *input);
+void keyboard_add(struct wlr_input_device *device, struct roots_input *input);
+
+void cursor_initialize(struct roots_input *input);
+void cursor_load_config(struct roots_config *config,
+ struct wlr_cursor *cursor,
+ struct roots_input *input,
+ struct roots_desktop *desktop);
+
+#endif
diff --git a/include/rootston/server.h b/include/rootston/server.h
new file mode 100644
index 00000000..d9fa8f9e
--- /dev/null
+++ b/include/rootston/server.h
@@ -0,0 +1,34 @@
+#ifndef _ROOTSTON_SERVER_H
+#define _ROOTSTON_SERVER_H
+#include <wayland-server.h>
+#include <wlr/backend.h>
+#include <wlr/backend/session.h>
+#include <wlr/types/wlr_data_device_manager.h>
+#include <wlr/render.h>
+#include <wlr/xwayland.h>
+#include "rootston/config.h"
+#include "rootston/desktop.h"
+#include "rootston/input.h"
+
+struct roots_server {
+ /* Rootston resources */
+ struct roots_config *config;
+ struct roots_desktop *desktop;
+ struct roots_input *input;
+
+ /* Wayland resources */
+ struct wl_display *wl_display;
+ struct wl_event_loop *wl_event_loop;
+
+ /* WLR tools */
+ struct wlr_backend *backend;
+ struct wlr_renderer *renderer;
+ struct wlr_xwayland *xwayland;
+
+ /* Global resources */
+ struct wlr_data_device_manager *data_device_manager;
+};
+
+extern struct roots_server server;
+
+#endif
diff --git a/include/rootston/view.h b/include/rootston/view.h
new file mode 100644
index 00000000..b74d1075
--- /dev/null
+++ b/include/rootston/view.h
@@ -0,0 +1,57 @@
+#ifndef _ROOTSTON_VIEW_H
+#define _ROOTSTON_VIEW_H
+#include <stdbool.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_xdg_shell_v6.h>
+
+struct roots_wl_shell_surface {
+ // TODO
+ void *_placeholder;
+};
+
+struct roots_xdg_surface_v6 {
+ struct roots_view *view;
+ // TODO: Maybe destroy listener should go in roots_view
+ struct wl_listener destroy;
+ struct wl_listener ping_timeout;
+ struct wl_listener request_minimize;
+ struct wl_listener request_move;
+ struct wl_listener request_resize;
+ struct wl_listener request_show_window_menu;
+};
+
+enum roots_view_type {
+ ROOTS_WL_SHELL_VIEW,
+ ROOTS_XDG_SHELL_V6_VIEW,
+ ROOTS_XWAYLAND_VIEW,
+};
+
+struct roots_view {
+ struct roots_desktop *desktop;
+ double x, y;
+ float rotation;
+ // TODO: Something for roots-enforced width/height
+ enum roots_view_type type;
+ union {
+ struct wlr_shell_surface *wl_shell_surface;
+ struct wlr_xdg_surface_v6 *xdg_surface_v6;
+ };
+ union {
+ struct roots_wl_shell_surface *roots_wl_shell_surface;
+ struct roots_xdg_surface_v6 *roots_xdg_surface_v6;
+ };
+ struct wlr_surface *wlr_surface;
+ struct wl_list link;
+ // TODO: This would probably be better as a field that's updated on a
+ // configure event from the xdg_shell
+ // If not then this should follow the typical type/impl pattern we use
+ // elsewhere
+ void (*get_input_bounds)(struct roots_view *view, struct wlr_box *box);
+ void (*activate)(struct roots_view *view, bool active);
+};
+
+void view_get_input_bounds(struct roots_view *view, struct wlr_box *box);
+void view_activate(struct roots_view *view, bool active);
+
+#endif
diff --git a/include/wlr/interfaces/wlr_keyboard.h b/include/wlr/interfaces/wlr_keyboard.h
index 4958e2b8..78c1f753 100644
--- a/include/wlr/interfaces/wlr_keyboard.h
+++ b/include/wlr/interfaces/wlr_keyboard.h
@@ -11,5 +11,7 @@ struct wlr_keyboard_impl {
void wlr_keyboard_init(struct wlr_keyboard *keyboard, struct wlr_keyboard_impl *impl);
void wlr_keyboard_destroy(struct wlr_keyboard *keyboard);
+void wlr_keyboard_update_state(struct wlr_keyboard *keyboard,
+ struct wlr_event_keyboard_key *event);
#endif
diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h
index 3f5d0d0c..af205c63 100644
--- a/include/wlr/types/wlr_keyboard.h
+++ b/include/wlr/types/wlr_keyboard.h
@@ -3,6 +3,8 @@
#include <wayland-server.h>
#include <stdint.h>
+#include <wayland-server.h>
+#include <xkbcommon/xkbcommon.h>
enum WLR_KEYBOARD_LED {
WLR_LED_NUM_LOCK = 1,
@@ -15,9 +17,17 @@ struct wlr_keyboard_impl;
struct wlr_keyboard {
struct wlr_keyboard_impl *impl;
+ // TODO: Should this store key repeat info too?
+
+ int keymap_fd;
+ size_t keymap_size;
+ struct xkb_keymap *keymap;
+ struct xkb_state *xkb_state;
+ xkb_led_index_t leds[WLR_LED_LAST];
struct {
struct wl_signal key;
+ struct wl_signal keymap;
} events;
void *data;
@@ -37,4 +47,7 @@ struct wlr_event_keyboard_key {
enum wlr_key_state state;
};
+void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
+ struct xkb_keymap *keymap);
+
#endif
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 0270ad4e..86fd36dd 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -3,6 +3,7 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_keyboard.h>
#include <wayland-server.h>
/**
@@ -13,6 +14,7 @@
struct wlr_seat_handle {
struct wl_resource *wl_resource;
struct wlr_seat *wlr_seat;
+ struct wlr_seat_keyboard *seat_keyboard;
struct wl_resource *pointer;
struct wl_resource *keyboard;
@@ -31,6 +33,15 @@ struct wlr_seat_pointer_state {
struct wl_listener focus_resource_destroy_listener;
};
+struct wlr_seat_keyboard {
+ struct wlr_seat *seat;
+ struct wlr_keyboard *keyboard;
+ struct wl_listener key;
+ struct wl_listener keymap;
+ struct wl_listener destroy;
+ struct wl_list link;
+};
+
struct wlr_seat_keyboard_state {
struct wlr_seat *wlr_seat;
struct wlr_seat_handle *focused_handle;
@@ -39,14 +50,15 @@ struct wlr_seat_keyboard_state {
int keymap_fd;
size_t keymap_size;
- struct wl_listener focus_surface_destroy_listener;
- struct wl_listener focus_resource_destroy_listener;
+ struct wl_listener surface_destroy;
+ struct wl_listener resource_destroy;
};
struct wlr_seat {
struct wl_global *wl_global;
struct wl_display *display;
struct wl_list handles;
+ struct wl_list keyboards;
char *name;
uint32_t capabilities;
struct wlr_data_device *data_device;
@@ -57,7 +69,6 @@ struct wlr_seat {
struct {
struct wl_signal client_bound;
struct wl_signal client_unbound;
- struct wl_signal keyboard_bound;
} events;
void *data;
@@ -127,37 +138,32 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
enum wlr_axis_orientation orientation, double value);
/**
- * Send a keyboard enter event to the given surface and consider it to be the
- * focused surface for the keyboard. This will send a leave event to the last
- * surface that was entered. Pass an array of currently pressed keys.
+ * Attaches this keyboard to the seat. Key events from this keyboard will be
+ * propegated to the focused client.
*/
-void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
- struct wlr_surface *surface, struct wl_array keys);
+void wlr_seat_attach_keyboard(struct wlr_seat *seat,
+ struct wlr_input_device *dev);
/**
- * Clear the focused surface for the keyboard and leave all entered surfaces.
+ * Detaches this keyboard from the seat. This is done automatically when the
+ * keyboard is destroyed; you only need to use this if you want to remove it for
+ * some other reason.
*/
-void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
+void wlr_seat_detach_keyboard(struct wlr_seat *seat, struct wlr_keyboard *kb);
/**
- * Send a key event to the surface with keyboard focus. Returns the event
- * serial.
+ * Send a keyboard enter event to the given surface and consider it to be the
+ * focused surface for the keyboard. This will send a leave event to the last
+ * surface that was entered. Pass an array of currently pressed keys.
*/
-uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
- uint32_t key, uint32_t state);
+void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
+ struct wlr_surface *surface);
/**
- * Send the modifiers event to the surface with keyboard focus. Also sends the
- * event to the surface with pointer focus.
+ * Clear the focused surface for the keyboard and leave all entered surfaces.
*/
-void wlr_seat_keyboard_send_modifiers(struct wlr_seat *wlr_seat,
- uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
- uint32_t group);
+void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
-/**
- * Set the keymap and send it to seat keyboard resources.
- */
-void wlr_seat_keyboard_set_keymap(struct wlr_seat *wlr_seat, int keymap_fd,
- size_t keymap_size);
+// TODO: May be useful to be able to simulate keyboard input events
#endif