aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/input
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/input')
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--include/sway/input/text_input.h63
2 files changed, 66 insertions, 0 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 49b9d09b..6d7495dd 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -7,6 +7,7 @@
7#include <wlr/util/edges.h> 7#include <wlr/util/edges.h>
8#include "sway/config.h" 8#include "sway/config.h"
9#include "sway/input/input-manager.h" 9#include "sway/input/input-manager.h"
10#include "sway/input/text_input.h"
10 11
11struct sway_seat; 12struct sway_seat;
12 13
@@ -86,6 +87,8 @@ struct sway_seat {
86 87
87 list_t *deferred_bindings; // struct sway_binding 88 list_t *deferred_bindings; // struct sway_binding
88 89
90 struct sway_input_method_relay im_relay;
91
89 struct wl_listener focus_destroy; 92 struct wl_listener focus_destroy;
90 struct wl_listener new_node; 93 struct wl_listener new_node;
91 struct wl_listener request_start_drag; 94 struct wl_listener request_start_drag;
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