diff options
Diffstat (limited to 'include/sway/input')
-rw-r--r-- | include/sway/input/cursor.h | 36 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 64 | ||||
-rw-r--r-- | include/sway/input/keyboard.h | 30 | ||||
-rw-r--r-- | include/sway/input/seat.h | 111 |
4 files changed, 241 insertions, 0 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h new file mode 100644 index 00000000..fcd94437 --- /dev/null +++ b/include/sway/input/cursor.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _SWAY_INPUT_CURSOR_H | ||
2 | #define _SWAY_INPUT_CURSOR_H | ||
3 | #include <stdint.h> | ||
4 | #include "sway/input/seat.h" | ||
5 | |||
6 | struct sway_cursor { | ||
7 | struct sway_seat *seat; | ||
8 | struct wlr_cursor *cursor; | ||
9 | struct wlr_xcursor_manager *xcursor_manager; | ||
10 | |||
11 | struct wl_client *image_client; | ||
12 | |||
13 | struct wl_listener motion; | ||
14 | struct wl_listener motion_absolute; | ||
15 | struct wl_listener button; | ||
16 | struct wl_listener axis; | ||
17 | |||
18 | struct wl_listener touch_down; | ||
19 | struct wl_listener touch_up; | ||
20 | struct wl_listener touch_motion; | ||
21 | |||
22 | struct wl_listener tool_axis; | ||
23 | struct wl_listener tool_tip; | ||
24 | struct wl_listener tool_button; | ||
25 | uint32_t tool_buttons; | ||
26 | |||
27 | struct wl_listener request_set_cursor; | ||
28 | }; | ||
29 | |||
30 | void sway_cursor_destroy(struct sway_cursor *cursor); | ||
31 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | ||
32 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time); | ||
33 | void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, | ||
34 | uint32_t button, enum wlr_button_state state); | ||
35 | |||
36 | #endif | ||
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h new file mode 100644 index 00000000..89a3ac71 --- /dev/null +++ b/include/sway/input/input-manager.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _SWAY_INPUT_INPUT_MANAGER_H | ||
2 | #define _SWAY_INPUT_INPUT_MANAGER_H | ||
3 | #include <libinput.h> | ||
4 | #include <wlr/types/wlr_input_inhibitor.h> | ||
5 | #include "sway/server.h" | ||
6 | #include "sway/config.h" | ||
7 | #include "list.h" | ||
8 | |||
9 | /** | ||
10 | * The global singleton input manager | ||
11 | * TODO: make me not a global | ||
12 | */ | ||
13 | extern struct sway_input_manager *input_manager; | ||
14 | |||
15 | struct sway_input_device { | ||
16 | char *identifier; | ||
17 | struct wlr_input_device *wlr_device; | ||
18 | struct wl_list link; | ||
19 | struct wl_listener device_destroy; | ||
20 | }; | ||
21 | |||
22 | struct sway_input_manager { | ||
23 | struct sway_server *server; | ||
24 | struct wl_list devices; | ||
25 | struct wl_list seats; | ||
26 | |||
27 | struct wlr_input_inhibit_manager *inhibit; | ||
28 | |||
29 | struct wl_listener new_input; | ||
30 | struct wl_listener inhibit_activate; | ||
31 | struct wl_listener inhibit_deactivate; | ||
32 | }; | ||
33 | |||
34 | struct sway_input_manager *input_manager_create(struct sway_server *server); | ||
35 | |||
36 | bool input_manager_has_focus(struct sway_input_manager *input, | ||
37 | struct sway_container *container); | ||
38 | |||
39 | void input_manager_set_focus(struct sway_input_manager *input, | ||
40 | struct sway_container *container); | ||
41 | |||
42 | void input_manager_configure_xcursor(struct sway_input_manager *input); | ||
43 | |||
44 | void input_manager_apply_input_config(struct sway_input_manager *input, | ||
45 | struct input_config *input_config); | ||
46 | |||
47 | void input_manager_apply_seat_config(struct sway_input_manager *input, | ||
48 | struct seat_config *seat_config); | ||
49 | |||
50 | struct sway_seat *input_manager_get_default_seat( | ||
51 | struct sway_input_manager *input); | ||
52 | |||
53 | struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, | ||
54 | const char *seat_name); | ||
55 | |||
56 | /** | ||
57 | * Gets the last seat the user interacted with | ||
58 | */ | ||
59 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); | ||
60 | |||
61 | struct input_config *input_device_get_config(struct sway_input_device *device); | ||
62 | |||
63 | |||
64 | #endif | ||
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h new file mode 100644 index 00000000..8ec3eb35 --- /dev/null +++ b/include/sway/input/keyboard.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef _SWAY_INPUT_KEYBOARD_H | ||
2 | #define _SWAY_INPUT_KEYBOARD_H | ||
3 | |||
4 | #include "sway/input/seat.h" | ||
5 | |||
6 | #define SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP 32 | ||
7 | |||
8 | struct sway_keyboard { | ||
9 | struct sway_seat_device *seat_device; | ||
10 | |||
11 | struct xkb_keymap *keymap; | ||
12 | |||
13 | struct wl_listener keyboard_key; | ||
14 | struct wl_listener keyboard_modifiers; | ||
15 | |||
16 | xkb_keysym_t pressed_keysyms_translated[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP]; | ||
17 | uint32_t modifiers_translated; | ||
18 | |||
19 | xkb_keysym_t pressed_keysyms_raw[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP]; | ||
20 | uint32_t modifiers_raw; | ||
21 | }; | ||
22 | |||
23 | struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, | ||
24 | struct sway_seat_device *device); | ||
25 | |||
26 | void sway_keyboard_configure(struct sway_keyboard *keyboard); | ||
27 | |||
28 | void sway_keyboard_destroy(struct sway_keyboard *keyboard); | ||
29 | |||
30 | #endif | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h new file mode 100644 index 00000000..ff76841e --- /dev/null +++ b/include/sway/input/seat.h | |||
@@ -0,0 +1,111 @@ | |||
1 | #ifndef _SWAY_INPUT_SEAT_H | ||
2 | #define _SWAY_INPUT_SEAT_H | ||
3 | |||
4 | #include <wlr/types/wlr_layer_shell.h> | ||
5 | #include <wlr/types/wlr_seat.h> | ||
6 | #include "sway/input/input-manager.h" | ||
7 | |||
8 | struct sway_seat_device { | ||
9 | struct sway_seat *sway_seat; | ||
10 | struct sway_input_device *input_device; | ||
11 | struct sway_keyboard *keyboard; | ||
12 | struct wl_list link; // sway_seat::devices | ||
13 | }; | ||
14 | |||
15 | struct sway_seat_container { | ||
16 | struct sway_seat *seat; | ||
17 | struct sway_container *container; | ||
18 | |||
19 | struct wl_list link; // sway_seat::focus_stack | ||
20 | |||
21 | struct wl_listener destroy; | ||
22 | }; | ||
23 | |||
24 | struct sway_seat { | ||
25 | struct wlr_seat *wlr_seat; | ||
26 | struct sway_cursor *cursor; | ||
27 | struct sway_input_manager *input; | ||
28 | |||
29 | bool has_focus; | ||
30 | struct wl_list focus_stack; // list of containers in focus order | ||
31 | |||
32 | // If the focused layer is set, views cannot receive keyboard focus | ||
33 | struct wlr_layer_surface *focused_layer; | ||
34 | |||
35 | // If exclusive_client is set, no other clients will receive input events | ||
36 | struct wl_client *exclusive_client; | ||
37 | |||
38 | struct wl_listener focus_destroy; | ||
39 | struct wl_listener new_container; | ||
40 | |||
41 | struct wl_list devices; // sway_seat_device::link | ||
42 | |||
43 | struct wl_list link; // input_manager::seats | ||
44 | }; | ||
45 | |||
46 | struct sway_seat *seat_create(struct sway_input_manager *input, | ||
47 | const char *seat_name); | ||
48 | |||
49 | void seat_destroy(struct sway_seat *seat); | ||
50 | |||
51 | void seat_add_device(struct sway_seat *seat, | ||
52 | struct sway_input_device *device); | ||
53 | |||
54 | void seat_configure_device(struct sway_seat *seat, | ||
55 | struct sway_input_device *device); | ||
56 | |||
57 | void seat_remove_device(struct sway_seat *seat, | ||
58 | struct sway_input_device *device); | ||
59 | |||
60 | void seat_configure_xcursor(struct sway_seat *seat); | ||
61 | |||
62 | void seat_set_focus(struct sway_seat *seat, struct sway_container *container); | ||
63 | |||
64 | void seat_set_focus_warp(struct sway_seat *seat, | ||
65 | struct sway_container *container, bool warp); | ||
66 | |||
67 | void seat_set_focus_surface(struct sway_seat *seat, | ||
68 | struct wlr_surface *surface); | ||
69 | |||
70 | void seat_set_focus_layer(struct sway_seat *seat, | ||
71 | struct wlr_layer_surface *layer); | ||
72 | |||
73 | void seat_set_exclusive_client(struct sway_seat *seat, | ||
74 | struct wl_client *client); | ||
75 | |||
76 | struct sway_container *seat_get_focus(struct sway_seat *seat); | ||
77 | |||
78 | /** | ||
79 | * Return the last container to be focused for the seat (or the most recently | ||
80 | * opened if no container has received focused) that is a child of the given | ||
81 | * container. The focus-inactive container of the root window is the focused | ||
82 | * container for the seat (if the seat does have focus). This function can be | ||
83 | * used to determine what container gets focused next if the focused container | ||
84 | * is destroyed, or focus moves to a container with children and we need to | ||
85 | * descend into the next leaf in focus order. | ||
86 | */ | ||
87 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, | ||
88 | struct sway_container *container); | ||
89 | |||
90 | /** | ||
91 | * Descend into the focus stack to find the focus-inactive view. Useful for | ||
92 | * container placement when they change position in the tree. | ||
93 | */ | ||
94 | struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, | ||
95 | struct sway_container *container); | ||
96 | |||
97 | /** | ||
98 | * Iterate over the focus-inactive children of the container calling the | ||
99 | * function on each. | ||
100 | */ | ||
101 | void seat_focus_inactive_children_for_each(struct sway_seat *seat, | ||
102 | struct sway_container *container, | ||
103 | void (*f)(struct sway_container *container, void *data), void *data); | ||
104 | |||
105 | void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); | ||
106 | |||
107 | struct seat_config *seat_get_config(struct sway_seat *seat); | ||
108 | |||
109 | bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | ||
110 | |||
111 | #endif | ||