summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar xdavidwu <xdavidwuph@gmail.com>2019-10-18 18:57:17 +0800
committerLibravatar Simon Ser <contact@emersion.fr>2020-04-04 11:42:04 +0200
commit5886187c6ef56307f15be475dc62785faf32ef35 (patch)
tree535283eca78c9a4ea63f26d9a13c1df48fe2b2f6 /include
parentswapped hiding the cursor and sending a touch event as a more logical sequence (diff)
downloadsway-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')
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--include/sway/input/text_input.h63
-rw-r--r--include/sway/server.h4
3 files changed, 70 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
diff --git a/include/sway/server.h b/include/sway/server.h
index 65bd6429..a9ffe187 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -7,12 +7,14 @@
7#include <wlr/render/wlr_renderer.h> 7#include <wlr/render/wlr_renderer.h>
8#include <wlr/types/wlr_compositor.h> 8#include <wlr/types/wlr_compositor.h>
9#include <wlr/types/wlr_data_device.h> 9#include <wlr/types/wlr_data_device.h>
10#include <wlr/types/wlr_input_method_v2.h>
10#include <wlr/types/wlr_layer_shell_v1.h> 11#include <wlr/types/wlr_layer_shell_v1.h>
11#include <wlr/types/wlr_output_management_v1.h> 12#include <wlr/types/wlr_output_management_v1.h>
12#include <wlr/types/wlr_output_power_management_v1.h> 13#include <wlr/types/wlr_output_power_management_v1.h>
13#include <wlr/types/wlr_presentation_time.h> 14#include <wlr/types/wlr_presentation_time.h>
14#include <wlr/types/wlr_relative_pointer_v1.h> 15#include <wlr/types/wlr_relative_pointer_v1.h>
15#include <wlr/types/wlr_server_decoration.h> 16#include <wlr/types/wlr_server_decoration.h>
17#include <wlr/types/wlr_text_input_v3.h>
16#include <wlr/types/wlr_xdg_shell.h> 18#include <wlr/types/wlr_xdg_shell.h>
17#include "config.h" 19#include "config.h"
18#include "list.h" 20#include "list.h"
@@ -76,6 +78,8 @@ struct sway_server {
76 78
77 struct wlr_output_power_manager_v1 *output_power_manager_v1; 79 struct wlr_output_power_manager_v1 *output_power_manager_v1;
78 struct wl_listener output_power_manager_set_mode; 80 struct wl_listener output_power_manager_set_mode;
81 struct wlr_input_method_manager_v2 *input_method;
82 struct wlr_text_input_manager_v3 *text_input;
79 83
80 size_t txn_timeout_ms; 84 size_t txn_timeout_ms;
81 list_t *transactions; 85 list_t *transactions;