aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/input/text_input.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/input/text_input.h')
-rw-r--r--include/sway/input/text_input.h63
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 */
21struct 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
38struct 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
52void 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.
56void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
57 struct wlr_surface *surface);
58
59struct 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