aboutsummaryrefslogtreecommitdiff
path: root/include/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'include/rootston')
-rw-r--r--include/rootston/config.h1
-rw-r--r--include/rootston/cursor.h103
-rw-r--r--include/rootston/input.h150
-rw-r--r--include/rootston/keyboard.h33
-rw-r--r--include/rootston/seat.h90
-rw-r--r--include/rootston/xcursor.h15
6 files changed, 246 insertions, 146 deletions
diff --git a/include/rootston/config.h b/include/rootston/config.h
index 75c04619..58fb1a1c 100644
--- a/include/rootston/config.h
+++ b/include/rootston/config.h
@@ -19,6 +19,7 @@ struct device_config {
char *name;
char *mapped_output;
struct wlr_box *mapped_box;
+ char *seat;
struct wl_list link;
};
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
new file mode 100644
index 00000000..c0dbc010
--- /dev/null
+++ b/include/rootston/cursor.h
@@ -0,0 +1,103 @@
+#ifndef _ROOTSTON_CURSOR_H
+#define _ROOTSTON_CURSOR_H
+
+#include "rootston/seat.h"
+
+enum roots_cursor_mode {
+ ROOTS_CURSOR_PASSTHROUGH = 0,
+ ROOTS_CURSOR_MOVE = 1,
+ ROOTS_CURSOR_RESIZE = 2,
+ ROOTS_CURSOR_ROTATE = 3,
+};
+
+enum roots_cursor_resize_edge {
+ ROOTS_CURSOR_RESIZE_EDGE_TOP = 1,
+ ROOTS_CURSOR_RESIZE_EDGE_BOTTOM = 2,
+ ROOTS_CURSOR_RESIZE_EDGE_LEFT = 4,
+ ROOTS_CURSOR_RESIZE_EDGE_RIGHT = 8,
+};
+
+struct roots_input_event {
+ uint32_t serial;
+ struct wlr_cursor *cursor;
+ struct wlr_input_device *device;
+};
+
+struct roots_cursor {
+ struct roots_seat *seat;
+ struct wlr_cursor *cursor;
+
+ enum roots_cursor_mode mode;
+
+ // state from input (review if this is necessary)
+ struct wlr_xcursor_theme *xcursor_theme;
+ struct wlr_seat *wl_seat;
+ struct wl_client *cursor_client;
+ int offs_x, offs_y;
+ int view_x, view_y, view_width, view_height;
+ float view_rotation;
+ uint32_t resize_edges;
+ // Ring buffer of input events that could trigger move/resize/rotate
+ int input_events_idx;
+ struct wl_list touch_points;
+ struct roots_input_event input_events[16];
+
+ struct wl_listener motion;
+ struct wl_listener motion_absolute;
+ struct wl_listener button;
+ struct wl_listener axis;
+
+ struct wl_listener touch_down;
+ struct wl_listener touch_up;
+ struct wl_listener touch_motion;
+
+ struct wl_listener tool_axis;
+ struct wl_listener tool_tip;
+
+ struct wl_listener pointer_grab_begin;
+ struct wl_listener pointer_grab_end;
+
+ struct wl_listener request_set_cursor;
+};
+
+struct roots_cursor *roots_cursor_create(struct roots_seat *seat);
+
+void roots_cursor_destroy(struct roots_cursor *cursor);
+
+void roots_cursor_handle_motion(struct roots_cursor *cursor,
+ struct wlr_event_pointer_motion *event);
+
+void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
+ struct wlr_event_pointer_motion_absolute *event);
+
+void roots_cursor_handle_button(struct roots_cursor *cursor,
+ struct wlr_event_pointer_button *event);
+
+void roots_cursor_handle_axis(struct roots_cursor *cursor,
+ struct wlr_event_pointer_axis *event);
+
+void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
+ struct wlr_event_touch_down *event);
+
+void roots_cursor_handle_touch_up(struct roots_cursor *cursor,
+ struct wlr_event_touch_up *event);
+
+void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
+ struct wlr_event_touch_motion *event);
+
+void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
+ struct wlr_event_tablet_tool_axis *event);
+
+void roots_cursor_handle_tool_tip(struct roots_cursor *cursor,
+ struct wlr_event_tablet_tool_tip *event);
+
+void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
+ struct wlr_seat_pointer_request_set_cursor_event *event);
+
+void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
+ struct wlr_seat_pointer_grab *grab);
+
+void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
+ struct wlr_seat_pointer_grab *grab);
+
+#endif
diff --git a/include/rootston/input.h b/include/rootston/input.h
index 20b73c8a..ea0bbeb6 100644
--- a/include/rootston/input.h
+++ b/include/rootston/input.h
@@ -1,171 +1,29 @@
#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/cursor.h"
#include "rootston/config.h"
#include "rootston/view.h"
#include "rootston/server.h"
-#define ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP 32
-
-struct roots_keyboard {
- struct roots_input *input;
- struct wlr_input_device *device;
- struct wl_listener key;
- struct wl_listener modifiers;
- struct wl_list link;
-
- xkb_keysym_t pressed_keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP];
-};
-
-struct roots_pointer {
- struct roots_input *input;
- struct wlr_input_device *device;
- struct wl_list link;
-};
-
-struct roots_touch {
- struct roots_input *input;
- struct wlr_input_device *device;
- 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,
-};
-
-enum roots_cursor_resize_edge {
- ROOTS_CURSOR_RESIZE_EDGE_TOP = 1,
- ROOTS_CURSOR_RESIZE_EDGE_BOTTOM = 2,
- ROOTS_CURSOR_RESIZE_EDGE_LEFT = 4,
- ROOTS_CURSOR_RESIZE_EDGE_RIGHT = 8,
-};
-
-struct roots_input_event {
- uint32_t serial;
- struct wlr_cursor *cursor;
- struct wlr_input_device *device;
-};
-
-struct roots_drag_icon {
- struct wlr_surface *surface;
- struct wl_list link; // roots_input::drag_icons
- bool mapped;
-
- int32_t sx;
- int32_t sy;
-
- struct wl_listener surface_destroy;
- struct wl_listener surface_commit;
-};
-
-struct roots_touch_point {
- struct roots_touch *device;
- int32_t slot;
- double x, y;
- struct wl_list link;
-};
-
struct roots_input {
struct roots_config *config;
struct roots_server *server;
- // TODO: multiseat, multicursor
- struct wlr_cursor *cursor;
- struct wlr_xcursor_theme *xcursor_theme;
- struct wlr_seat *wl_seat;
- struct wl_list drag_icons;
- struct wl_client *cursor_client;
-
- enum roots_cursor_mode mode;
- struct roots_view *active_view;
- int offs_x, offs_y;
- int view_x, view_y, view_width, view_height;
- float view_rotation;
- uint32_t resize_edges;
-
- // 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_touch_down;
- struct wl_listener cursor_touch_up;
- struct wl_listener cursor_touch_motion;
-
- struct wl_listener cursor_tool_axis;
- struct wl_listener cursor_tool_tip;
-
- struct wl_listener pointer_grab_begin;
- struct wl_list touch_points;
-
- struct wl_listener pointer_grab_end;
-
- struct wl_listener request_set_cursor;
+ struct wl_list seats;
};
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 pointer_remove(struct wlr_input_device *device, struct roots_input *input);
-void keyboard_add(struct wlr_input_device *device, struct roots_input *input);
-void keyboard_remove(struct wlr_input_device *device, struct roots_input *input);
-void touch_add(struct wlr_input_device *device, struct roots_input *input);
-void touch_remove(struct wlr_input_device *device, struct roots_input *input);
-void tablet_tool_add(struct wlr_input_device *device, struct roots_input *input);
-void tablet_tool_remove(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);
-const struct roots_input_event *get_input_event(struct roots_input *input,
- uint32_t serial);
-void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
- struct roots_view *view);
-void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
- struct roots_view *view, uint32_t edges);
-
-struct wlr_xcursor *get_default_xcursor(struct wlr_xcursor_theme *theme);
-struct wlr_xcursor *get_move_xcursor(struct wlr_xcursor_theme *theme);
-struct wlr_xcursor *get_resize_xcursor(struct wlr_xcursor_theme *theme,
- uint32_t edges);
-struct wlr_xcursor *get_rotate_xcursor(struct wlr_xcursor_theme *theme);
-
-void set_view_focus(struct roots_input *input, struct roots_desktop *desktop,
- struct roots_view *view);
+struct roots_seat *input_seat_from_wlr_seat(struct roots_input *input,
+ struct wlr_seat *seat);
#endif
diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h
new file mode 100644
index 00000000..4dd70a65
--- /dev/null
+++ b/include/rootston/keyboard.h
@@ -0,0 +1,33 @@
+#ifndef _ROOTSTON_KEYBOARD_H
+#define _ROOTSTON_KEYBOARD_H
+
+#include <xkbcommon/xkbcommon.h>
+#include "rootston/input.h"
+
+#define ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP 32
+
+struct roots_keyboard {
+ struct roots_input *input;
+ struct roots_seat *seat;
+ struct wlr_input_device *device;
+ struct keyboard_config *config;
+ struct wl_list link;
+
+ struct wl_listener keyboard_key;
+ struct wl_listener keyboard_modifiers;
+
+ xkb_keysym_t pressed_keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP];
+};
+
+struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device,
+ struct roots_input *input);
+
+void roots_keyboard_destroy(struct roots_keyboard *keyboard);
+
+void roots_keyboard_handle_key(struct roots_keyboard *keyboard,
+ struct wlr_event_keyboard_key *event);
+
+void roots_keyboard_handle_modifiers(struct roots_keyboard *r_keyboard,
+ struct wlr_event_keyboard_modifiers *event);
+
+#endif
diff --git a/include/rootston/seat.h b/include/rootston/seat.h
new file mode 100644
index 00000000..b5593651
--- /dev/null
+++ b/include/rootston/seat.h
@@ -0,0 +1,90 @@
+#ifndef _ROOTSTON_SEAT_H
+#define _ROOTSTON_SEAT_H
+
+#include <wayland-server.h>
+
+#include "rootston/input.h"
+#include "rootston/keyboard.h"
+
+struct roots_drag_icon {
+ struct wlr_surface *surface;
+ struct wl_list link; // roots_seat::drag_icons
+ bool mapped;
+
+ int32_t sx;
+ int32_t sy;
+
+ struct wl_listener surface_destroy;
+ struct wl_listener surface_commit;
+};
+
+struct roots_seat {
+ struct roots_input *input;
+ struct wlr_seat *seat;
+ struct roots_cursor *cursor;
+ struct wl_list link;
+ struct wl_list drag_icons;
+
+ struct roots_view *focus;
+
+ struct wl_list keyboards;
+ struct wl_list pointers;
+ struct wl_list touch;
+ struct wl_list tablet_tools;
+};
+
+struct roots_pointer {
+ struct roots_seat *seat;
+ struct wlr_input_device *device;
+ struct wl_list link;
+};
+
+struct roots_touch {
+ struct roots_seat *seat;
+ struct wlr_input_device *device;
+ struct wl_list link;
+};
+
+struct roots_touch_point {
+ struct roots_touch *device;
+ int32_t slot;
+ double x, y;
+ struct wl_list link;
+};
+
+struct roots_tablet_tool {
+ struct roots_seat *seat;
+ 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;
+};
+
+struct roots_seat *roots_seat_create(struct roots_input *input, char *name);
+
+void roots_seat_destroy(struct roots_seat *seat);
+
+void roots_seat_add_device(struct roots_seat *seat,
+ struct wlr_input_device *device);
+
+void roots_seat_remove_device(struct roots_seat *seat,
+ struct wlr_input_device *device);
+
+void roots_seat_configure_cursor(struct roots_seat *seat);
+
+void roots_seat_configure_xcursor(struct roots_seat *seat);
+
+bool roots_seat_has_meta_pressed(struct roots_seat *seat);
+
+void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view);
+
+void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view);
+
+void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
+ uint32_t edges);
+
+void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view);
+
+#endif
diff --git a/include/rootston/xcursor.h b/include/rootston/xcursor.h
new file mode 100644
index 00000000..c96e50ef
--- /dev/null
+++ b/include/rootston/xcursor.h
@@ -0,0 +1,15 @@
+#ifndef _ROOTSTON_XCURSOR_H
+#define _ROOTSTON_XCURSOR_H
+
+#include <wlr/xcursor.h>
+
+struct wlr_xcursor *get_default_xcursor(struct wlr_xcursor_theme *theme);
+
+struct wlr_xcursor *get_move_xcursor(struct wlr_xcursor_theme *theme);
+
+struct wlr_xcursor *get_resize_xcursor(struct wlr_xcursor_theme *theme,
+ uint32_t edges);
+
+struct wlr_xcursor *get_rotate_xcursor(struct wlr_xcursor_theme *theme);
+
+#endif