diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/rootston/config.h | 51 | ||||
-rw-r--r-- | include/rootston/desktop.h | 33 | ||||
-rw-r--r-- | include/rootston/ini.h | 93 | ||||
-rw-r--r-- | include/rootston/input.h | 91 | ||||
-rw-r--r-- | include/rootston/server.h | 31 | ||||
-rw-r--r-- | include/rootston/view.h | 41 |
6 files changed, 340 insertions, 0 deletions
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..7881e599 --- /dev/null +++ b/include/rootston/desktop.h @@ -0,0 +1,33 @@ +#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_data_device_manager.h> +#include <wlr/types/wlr_gamma_control.h> +#include "rootston/view.h" + +struct roots_output { + struct roots_desktop *desktop; + struct wlr_output *output; + struct wl_listener frame; + struct wl_listener resolution; + struct timespec last_frame; + struct wl_list link; +}; + +struct roots_desktop { + struct wl_list outputs; + struct wlr_output_layout *layout; + struct wlr_compositor *wlr_compositor; + struct wlr_wl_shell *wl_shell; + struct wlr_xdg_shell_v6 *xdg_shell; + struct wlr_data_device_manager *data_device_manager; + struct wlr_gamma_control_manager *gamma_control_manager; +}; + +#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..88505201 --- /dev/null +++ b/include/rootston/input.h @@ -0,0 +1,91 @@ +#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/view.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; + struct wl_listener motion; + struct wl_listener motion_absolute; + struct wl_listener button; + struct wl_listener axis; + 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, + ROOTS_CURSOR_MOVE, + ROOTS_CURSOR_RESIZE, + ROOTS_CURSOR_ROTATE, +}; + +struct roots_input_event { + uint32_t serial; + struct wlr_cursor *cursor; + struct wlr_input_device *device; +}; + +struct roots_input { + // TODO: multiseat, multicursor + struct wlr_cursor *cursor; + struct wlr_xcursor *xcursor; + struct wlr_seat *wl_seat; + + enum roots_cursor_mode mode; + struct roots_view *focused_view; + struct roots_view *moving_view; + struct roots_view *resizing_view; + struct roots_view *rotating_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_list tablet_pads; +}; + +#endif diff --git a/include/rootston/server.h b/include/rootston/server.h new file mode 100644 index 00000000..f4d1de95 --- /dev/null +++ b/include/rootston/server.h @@ -0,0 +1,31 @@ +#ifndef _ROOTSTON_SERVER_H +#define _ROOTSTON_SERVER_H +#include <wayland-server.h> +#include <wlr/backend.h> +#include <wlr/backend/session.h> +#include <wlr/render.h> +#include <wlr/xwayland.h> +#include "rootston/config.h" +#include "rootston/desktop.h" +#include "rootston/input.h" + +struct rootston { + /* 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_session *session; + struct wlr_renderer *renderer; + struct wlr_xwayland *xwayland; +}; + +extern struct rootston root; + +#endif diff --git a/include/rootston/view.h b/include/rootston/view.h new file mode 100644 index 00000000..d33e6bfb --- /dev/null +++ b/include/rootston/view.h @@ -0,0 +1,41 @@ +#ifndef _ROOTSTON_VIEW_H +#define _ROOTSTON_VIEW_H + +struct roots_wl_shell_surface { + // TODO + void *_placeholder; +}; + +struct roots_xdg_surface_v6 { + // TODO: Maybe destroy listener should go in roots_view + struct wl_listener destroy_listener; + struct wl_listener ping_timeout_listener; + struct wl_listener request_minimize_listener; + struct wl_listener request_move_listener; + struct wl_listener request_resize_listener; + struct wl_listener request_show_window_menu_listener; +}; + +enum roots_view_type { + ROOTS_WL_SHELL_VIEW, + ROOTS_XDG_SHELL_V6_VIEW, + ROOTS_XWAYLAND_VIEW, +}; + +struct roots_view { + 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 xdg_shell_v6_surface *xdg_shell_v6_surface; + }; + union { + struct roots_wl_shell_surface *roots_wl_shell_surface; + struct xdg_shell_v6_surface *roots_xdg_surface_v6; + }; + struct wl_list link; +}; + +#endif |