GCC Code Coverage Report


Directory: ./
File: server/input_method_v2.h
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 12 12 100.0%
Branches: 6 12 50.0%

Line Branch Exec Source
1 /*
2 SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
3 SPDX-FileCopyrightText: 2021 Dorota Czaplejewicz <gihuac.dcz@porcupinefactory.org>
4 SPDX-FileCopyrightText: 2021 Roman Glig <subdiff@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only
7 */
8 #pragma once
9
10 #include "keyboard_pool.h"
11 #include "text_input_v3.h"
12
13 #include <Wrapland/Server/wraplandserver_export.h>
14
15 #include <QObject>
16 #include <memory>
17 #include <vector>
18
19 namespace Wrapland::Server
20 {
21 class Client;
22 class Display;
23 class input_method_keyboard_grab_v2;
24 class input_method_popup_surface_v2;
25
26 class WRAPLANDSERVER_EXPORT input_method_manager_v2 : public QObject
27 {
28 Q_OBJECT
29 public:
30 explicit input_method_manager_v2(Display* display);
31 ~input_method_manager_v2() override;
32
33 private:
34 class Private;
35 std::unique_ptr<Private> d_ptr;
36 };
37
38 struct input_method_v2_state {
39 124 struct {
40 62 bool update{false};
41 std::string data;
42 62 uint32_t cursor_begin{0};
43 62 uint32_t cursor_end{0};
44 } preedit_string;
45
46 62 struct {
47 62 bool update{false};
48 std::string data;
49 } commit_string;
50
51 62 struct {
52 62 bool update{false};
53 62 uint32_t before_length{0};
54 62 uint32_t after_length{0};
55 } delete_surrounding_text;
56 };
57
58 class WRAPLANDSERVER_EXPORT input_method_v2 : public QObject
59 {
60 Q_OBJECT
61 public:
62 input_method_v2_state const& state() const;
63
64 std::vector<input_method_popup_surface_v2*> const& get_popups() const;
65
66 void set_active(bool active);
67 void set_surrounding_text(std::string const& text,
68 uint32_t cursor,
69 uint32_t anchor,
70 text_input_v3_change_cause change_cause);
71 void set_content_type(text_input_v3_content_hints hints, text_input_v3_content_purpose purpose);
72 void done();
73
74 Q_SIGNALS:
75 void state_committed();
76 void keyboard_grabbed(Wrapland::Server::input_method_keyboard_grab_v2*);
77 void popup_surface_created(Wrapland::Server::input_method_popup_surface_v2*);
78 void resourceDestroyed();
79
80 private:
81 explicit input_method_v2(Client* client, uint32_t version, uint32_t id);
82 friend class input_method_manager_v2;
83
84 class Private;
85 Private* d_ptr;
86 };
87
88 class WRAPLANDSERVER_EXPORT input_method_keyboard_grab_v2 : public QObject
89 {
90 Q_OBJECT
91 public:
92 void set_keymap(std::string const& content);
93
94 void key(uint32_t time, uint32_t key, key_state state);
95
96 void update_modifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
97 void set_repeat_info(int32_t rate, int32_t delay);
98
99 Q_SIGNALS:
100 void resourceDestroyed();
101
102 private:
103 explicit input_method_keyboard_grab_v2(Client* client,
104 uint32_t version,
105 uint32_t id,
106 Seat* seat);
107 friend class input_method_v2;
108
109 class Private;
110 Private* d_ptr;
111 };
112
113 class WRAPLANDSERVER_EXPORT input_method_popup_surface_v2 : public QObject
114 {
115 Q_OBJECT
116 public:
117 Surface* surface() const;
118 void set_text_input_rectangle(QRect const& rect);
119
120 Q_SIGNALS:
121 void resourceDestroyed();
122
123 private:
124 explicit input_method_popup_surface_v2(Client* client,
125 uint32_t version,
126 uint32_t id,
127 Surface* surface);
128 friend class input_method_v2;
129
130 class Private;
131 Private* d_ptr;
132 };
133
134 }
135
136 Q_DECLARE_METATYPE(Wrapland::Server::input_method_v2*)
137
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 Q_DECLARE_METATYPE(Wrapland::Server::input_method_keyboard_grab_v2*)
138
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 Q_DECLARE_METATYPE(Wrapland::Server::input_method_popup_surface_v2*)
139