Changeset View
Changeset View
Standalone View
Standalone View
src/server/inputmethodinterface.cpp
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | #include "inputmethodinterface.h" | ||||
21 | #include "resource_p.h" | ||||
22 | #include "seat_interface.h" | ||||
23 | #include "display.h" | ||||
24 | #include "surface_interface.h" | ||||
25 | | ||||
26 | #include <QHash> | ||||
27 | #include "qwayland-server-input-method-unstable-v1.h" | ||||
28 | | ||||
29 | using namespace KWayland; | ||||
30 | using namespace Server; | ||||
31 | | ||||
32 | static int s_version = 1; | ||||
33 | | ||||
34 | using namespace KWayland::Server; | ||||
35 | | ||||
36 | class InputMethodInterface::Private : public QtWaylandServer::zwp_input_method_v1 | ||||
37 | { | ||||
38 | public: | ||||
39 | | ||||
40 | }; | ||||
41 | | ||||
42 | InputMethodInterface::InputMethodInterface() | ||||
43 | : d(new InputMethodInterface::Private) | ||||
44 | { | ||||
45 | } | ||||
46 | | ||||
47 | InputMethodInterface::~InputMethodInterface() = default; | ||||
48 | | ||||
49 | class InputMethodContextInterface::Private : public QtWaylandServer::zwp_input_method_context_v1 | ||||
50 | { | ||||
51 | public: | ||||
52 | Private(InputMethodContextInterface* q) : q(q) {} | ||||
53 | | ||||
54 | void zwp_input_method_context_v1_commit_string(QtWaylandServer::zwp_input_method_context_v1::Resource * resource, uint32_t serial, const QString & text) override { | ||||
55 | Q_EMIT q->commitString(resource->handle, serial, text); | ||||
56 | } | ||||
57 | void zwp_input_method_context_v1_preedit_string(Resource *resource, uint32_t serial, const QString &text, const QString &commit) override { | ||||
58 | Q_EMIT q->preeditString(resource->handle, serial, text, commit); | ||||
59 | } | ||||
60 | | ||||
61 | void zwp_input_method_context_v1_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style) override { | ||||
62 | Q_EMIT q->preeditStyling(resource->handle, index, length, style); | ||||
63 | } | ||||
64 | void zwp_input_method_context_v1_preedit_cursor(Resource *resource, int32_t index) override { | ||||
65 | Q_EMIT q->preeditCursor(resource->handle, index); | ||||
66 | } | ||||
67 | void zwp_input_method_context_v1_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length) override { | ||||
68 | Q_EMIT q->deleteSurroundingText(resource->handle, index, length); | ||||
69 | } | ||||
70 | void zwp_input_method_context_v1_cursor_position(Resource *resource, int32_t index, int32_t anchor) override { | ||||
71 | Q_EMIT q->cursorPosition(resource->handle, index, anchor); | ||||
72 | } | ||||
73 | // void zwp_input_method_context_v1_modifiers_map(Resource *resource, wl_array *map) override { | ||||
74 | // Q_EMIT q->modifiersMap(resource->handle, map); | ||||
75 | // } | ||||
76 | void zwp_input_method_context_v1_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override { | ||||
77 | Q_EMIT q->keysym(resource->handle, serial, time, sym, state, modifiers); | ||||
78 | } | ||||
79 | void zwp_input_method_context_v1_grab_keyboard(Resource *resource, uint32_t keyboard) override { | ||||
80 | Q_EMIT q->grabKeyboard(resource->handle, keyboard); | ||||
81 | } | ||||
82 | void zwp_input_method_context_v1_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) override { | ||||
83 | Q_EMIT q->key(resource->handle, serial, time, key, state); | ||||
84 | } | ||||
85 | void zwp_input_method_context_v1_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) override { | ||||
86 | Q_EMIT q->modifiers(resource->handle, serial, mods_depressed, mods_latched, mods_locked, group); | ||||
87 | } | ||||
88 | void zwp_input_method_context_v1_language(Resource *resource, uint32_t serial, const QString &language) override { | ||||
89 | Q_EMIT q->language(resource->handle, serial, language); | ||||
90 | } | ||||
91 | void zwp_input_method_context_v1_text_direction(Resource *resource, uint32_t serial, uint32_t direction) override { | ||||
92 | Q_EMIT q->textDirection(resource->handle, serial, direction); | ||||
93 | } | ||||
94 | private: | ||||
95 | InputMethodContextInterface* const q; | ||||
96 | }; | ||||
97 | | ||||
98 | InputMethodContextInterface::InputMethodContextInterface() | ||||
99 | : d(new InputMethodContextInterface::Private(this)) | ||||
100 | { | ||||
101 | } | ||||
102 | | ||||
103 | InputMethodContextInterface::~InputMethodContextInterface() = default; | ||||
104 | | ||||
105 | class InputPanelInterface::Private : public QtWaylandServer::zwp_input_panel_v1 | ||||
106 | { | ||||
107 | public: | ||||
108 | | ||||
109 | }; | ||||
110 | | ||||
111 | InputPanelInterface::InputPanelInterface() | ||||
112 | : d(new InputPanelInterface::Private) | ||||
113 | { | ||||
114 | } | ||||
115 | | ||||
116 | InputPanelInterface::~InputPanelInterface() = default; | ||||
117 | | ||||
118 | class InputPanelSurfaceInterface::Private : public QtWaylandServer::zwp_input_method_v1 | ||||
119 | { | ||||
120 | public: | ||||
121 | | ||||
122 | }; | ||||
123 | | ||||
124 | InputPanelSurfaceInterface::InputPanelSurfaceInterface() | ||||
125 | : d(new InputPanelSurfaceInterface::Private) | ||||
126 | { | ||||
127 | } | ||||
128 | | ||||
129 | InputPanelSurfaceInterface::~InputPanelSurfaceInterface() = default; |