diff options
author | xdavidwu <xdavidwuph@gmail.com> | 2019-10-18 18:57:17 +0800 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-04-04 11:42:04 +0200 |
commit | 5886187c6ef56307f15be475dc62785faf32ef35 (patch) | |
tree | 535283eca78c9a4ea63f26d9a13c1df48fe2b2f6 /include/sway/input/text_input.h | |
parent | swapped hiding the cursor and sending a touch event as a more logical sequence (diff) | |
download | sway-5886187c6ef56307f15be475dc62785faf32ef35.tar.gz sway-5886187c6ef56307f15be475dc62785faf32ef35.tar.zst sway-5886187c6ef56307f15be475dc62785faf32ef35.zip |
Port input method and text input from rootston
This ports swaywm/wlroots#1203, swaywm/wlroots#1303,
swaywm/wlroots#1308, swaywm/wlroots#1759 rootston part to sway.
Co-Authored-By: Leo Chen <leo881003@gmail.com>
Diffstat (limited to 'include/sway/input/text_input.h')
-rw-r--r-- | include/sway/input/text_input.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/sway/input/text_input.h b/include/sway/input/text_input.h new file mode 100644 index 00000000..4c3b2e07 --- /dev/null +++ b/include/sway/input/text_input.h | |||
@@ -0,0 +1,63 @@ | |||
1 | #ifndef _SWAY_INPUT_TEXT_INPUT_H | ||
2 | #define _SWAY_INPUT_TEXT_INPUT_H | ||
3 | |||
4 | #include <wlr/types/wlr_text_input_v3.h> | ||
5 | #include <wlr/types/wlr_input_method_v2.h> | ||
6 | #include <wlr/types/wlr_surface.h> | ||
7 | #include "sway/input/seat.h" | ||
8 | |||
9 | /** | ||
10 | * The relay structure manages the relationship between text-input and | ||
11 | * input_method interfaces on a given seat. Multiple text-input interfaces may | ||
12 | * be bound to a relay, but at most one will be focused (reveiving events) at | ||
13 | * a time. At most one input-method interface may be bound to the seat. The | ||
14 | * relay manages life cycle of both sides. When both sides are present and | ||
15 | * focused, the relay passes messages between them. | ||
16 | * | ||
17 | * Text input focus is a subset of keyboard focus - if the text-input is | ||
18 | * in the focused state, wl_keyboard sent an enter as well. However, having | ||
19 | * wl_keyboard focused doesn't mean that text-input will be focused. | ||
20 | */ | ||
21 | struct sway_input_method_relay { | ||
22 | struct sway_seat *seat; | ||
23 | |||
24 | struct wl_list text_inputs; // sway_text_input::link | ||
25 | struct wlr_input_method_v2 *input_method; // doesn't have to be present | ||
26 | |||
27 | struct wl_listener text_input_new; | ||
28 | struct wl_listener text_input_enable; | ||
29 | struct wl_listener text_input_commit; | ||
30 | struct wl_listener text_input_disable; | ||
31 | struct wl_listener text_input_destroy; | ||
32 | |||
33 | struct wl_listener input_method_new; | ||
34 | struct wl_listener input_method_commit; | ||
35 | struct wl_listener input_method_destroy; | ||
36 | }; | ||
37 | |||
38 | struct sway_text_input { | ||
39 | struct sway_input_method_relay *relay; | ||
40 | |||
41 | struct wlr_text_input_v3 *input; | ||
42 | // The surface getting seat's focus. Stored for when text-input cannot | ||
43 | // be sent an enter event immediately after getting focus, e.g. when | ||
44 | // there's no input method available. Cleared once text-input is entered. | ||
45 | struct wlr_surface *pending_focused_surface; | ||
46 | |||
47 | struct wl_list link; | ||
48 | |||
49 | struct wl_listener pending_focused_surface_destroy; | ||
50 | }; | ||
51 | |||
52 | void sway_input_method_relay_init(struct sway_seat *seat, | ||
53 | struct sway_input_method_relay *relay); | ||
54 | |||
55 | // Updates currently focused surface. Surface must belong to the same seat. | ||
56 | void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay, | ||
57 | struct wlr_surface *surface); | ||
58 | |||
59 | struct sway_text_input *sway_text_input_create( | ||
60 | struct sway_input_method_relay *relay, | ||
61 | struct wlr_text_input_v3 *text_input); | ||
62 | |||
63 | #endif | ||