-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputMethodV2.cpp
99 lines (82 loc) · 2.65 KB
/
InputMethodV2.cpp
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
92
93
94
95
96
97
98
99
#include "InputMethodV2.h"
#include "Core.h"
#include "InputMethodKeyboardGrabV2.h"
#include "TextInputManagerV3.h"
#include "TextInputV3.h"
#include "common.h"
#include "qwayland-server-input-method-unstable-v2.h"
class InputMethodV2Private : public QtWaylandServer::zwp_input_method_v2
{
public:
InputMethodV2Private(InputMethodV2 *q)
: q(q)
{
}
~InputMethodV2Private() { }
protected:
void zwp_input_method_v2_commit_string(Resource *resource, const QString &text) override
{
auto *im = getTextInputV3();
im->sendCommitString(text);
}
void zwp_input_method_v2_set_preedit_string(Resource *resource,
const QString &text,
int32_t cursor_begin,
int32_t cursor_end) override
{
auto *im = getTextInputV3();
im->sendPreeditString(text, cursor_begin, cursor_end);
}
void zwp_input_method_v2_delete_surrounding_text(Resource *resource,
uint32_t before_length,
uint32_t after_length) override
{
}
void zwp_input_method_v2_commit(Resource *resource, uint32_t serial) override
{
auto *im = getTextInputV3();
im->sendDone(serial);
}
void zwp_input_method_v2_get_input_popup_surface(Resource *resource,
uint32_t id,
struct ::wl_resource *surface) override
{
}
void zwp_input_method_v2_grab_keyboard(Resource *resource, uint32_t keyboard) override
{
q->m_grab->add(resource->client(), keyboard);
}
void zwp_input_method_v2_destroy(Resource *resource) override
{
wl_resource_destroy(resource->handle);
}
private:
InputMethodV2 *q;
TextInputV3 *getTextInputV3()
{
return q->m_core->getTextInputManagerV3()->getTextInputV4BySeat(q->m_seat);
}
};
InputMethodV2::InputMethodV2(Core *core, struct ::wl_resource *seat, QObject *parent)
: QObject(parent)
, m_core(core)
, m_seat(seat)
, m_grab(new InputMethodKeyboardGrabV2(seat, this))
{
}
InputMethodV2::~InputMethodV2() { }
INIT_FUNCS(InputMethodV2)
void InputMethodV2::sendDeactivate()
{
const auto resources = d->resourceMap();
for (auto *resource : resources) {
d->send_deactivate(resource->handle);
}
}
void InputMethodV2::sendActivate()
{
const auto resources = d->resourceMap();
for (auto *resource : resources) {
d->send_activate(resource->handle);
}
}