File: ime.h

package info (click to toggle)
labwc 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: ansic: 34,416; perl: 5,836; xml: 875; sh: 162; python: 131; makefile: 12
file content (91 lines) | stat: -rw-r--r-- 2,771 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef LABWC_IME_H
#define LABWC_IME_H

#include <wayland-server-core.h>

struct keyboard;
struct wlr_keyboard_key_event;

/*
 * The relay structure manages the relationship between text-inputs and
 * input-method on a given seat. Multiple text-inputs may be bound to a relay,
 * but at most one will be "active" (communicating with input-method) at a time.
 * At most one input-method may be bound to the seat. When an input-method and
 * an active text-input is present, the relay passes messages between them.
 */
struct input_method_relay {
	struct seat *seat;
	struct wl_list text_inputs; /* struct text_input.link */
	struct wlr_input_method_v2 *input_method;
	struct wlr_surface *focused_surface;

	/*
	 * Text-input which is enabled by the client and communicating with
	 * input-method.
	 * This must be NULL if input-method is not present.
	 * Its client must be the same as that of focused_surface.
	 */
	struct text_input *active_text_input;

	struct wl_list popups; /* input_method_popup.link */
	struct wlr_scene_tree *popup_tree;

	struct wl_listener new_text_input;
	struct wl_listener new_input_method;

	struct wl_listener input_method_commit;
	struct wl_listener input_method_grab_keyboard;
	struct wl_listener input_method_destroy;
	struct wl_listener input_method_new_popup_surface;

	struct wl_listener keyboard_grab_destroy;
	struct wl_listener focused_surface_destroy;
};

struct input_method_popup {
	struct wlr_input_popup_surface_v2 *popup_surface;
	struct wlr_scene_tree *tree;
	struct input_method_relay *relay;
	struct wl_list link; /* input_method_relay.popups */

	struct wl_listener destroy;
	struct wl_listener commit;
};

struct text_input {
	struct input_method_relay *relay;
	struct wlr_text_input_v3 *input;
	struct wl_list link;

	struct wl_listener enable;
	struct wl_listener commit;
	struct wl_listener disable;
	struct wl_listener destroy;
};

/*
 * Forward key event to keyboard grab of the seat from the keyboard
 * if the keyboard grab exists.
 * Returns true if the key event was forwarded.
 */
bool input_method_keyboard_grab_forward_key(struct keyboard *keyboard,
	struct wlr_keyboard_key_event *event);

/*
 * Forward modifier state to keyboard grab of the seat from the keyboard
 * if the keyboard grab exists.
 * Returns true if the modifier state was forwarded.
 */
bool input_method_keyboard_grab_forward_modifiers(struct keyboard *keyboard);

struct input_method_relay *input_method_relay_create(struct seat *seat);

void input_method_relay_finish(struct input_method_relay *relay);

/* Updates currently focused surface. Surface must belong to the same seat. */
void input_method_relay_set_focus(struct input_method_relay *relay,
	struct wlr_surface *surface);

#endif