Directory: | ./ |
---|---|
File: | src/client/virtual_keyboard_v1_p.h |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 18 | 20 | 90.0% |
Branches: | 3 | 4 | 75.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | SPDX-FileCopyrightText: 2021 Roman Gilg <subdiff@gmail.com> | ||
3 | |||
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only | ||
5 | */ | ||
6 | #pragma once | ||
7 | |||
8 | #include "virtual_keyboard_v1.h" | ||
9 | |||
10 | #include "wayland_pointer_p.h" | ||
11 | |||
12 | #include <QObject> | ||
13 | #include <filesystem> | ||
14 | |||
15 | #include <wayland-virtual-keyboard-v1-client-protocol.h> | ||
16 | |||
17 | namespace Wrapland::Client | ||
18 | { | ||
19 | |||
20 | // Copied from Server library. | ||
21 | struct file_wrap { | ||
22 | 6 | file_wrap() = default; | |
23 | 4 | explicit file_wrap(FILE* file) | |
24 | 4 | : file{file} | |
25 | { | ||
26 | 4 | } | |
27 | file_wrap(file_wrap const&) = delete; | ||
28 | file_wrap& operator=(file_wrap const&) = delete; | ||
29 | file_wrap(file_wrap&&) noexcept = delete; | ||
30 | 4 | file_wrap& operator=(file_wrap&& other) noexcept | |
31 | { | ||
32 | 4 | this->file = other.file; | |
33 | 4 | other.file = nullptr; | |
34 | 4 | return *this; | |
35 | } | ||
36 | 7 | ~file_wrap() | |
37 | { | ||
38 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
|
7 | if (file) { |
39 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | std::fclose(file); |
40 | 3 | } | |
41 | 7 | } | |
42 | 3 | FILE* file{nullptr}; | |
43 | }; | ||
44 | |||
45 | 3 | class Q_DECL_HIDDEN virtual_keyboard_manager_v1::Private | |
46 | { | ||
47 | public: | ||
48 | 3 | ~Private() = default; | |
49 | |||
50 | void release(); | ||
51 | bool isValid(); | ||
52 | virtual_keyboard_v1* create_virtual_keyboard(Seat* seat, QObject* parent = nullptr); | ||
53 | |||
54 | ✗ | operator zwp_virtual_keyboard_manager_v1*() | |
55 | { | ||
56 | ✗ | return manager_ptr; | |
57 | } | ||
58 | operator zwp_virtual_keyboard_manager_v1*() const | ||
59 | { | ||
60 | return manager_ptr; | ||
61 | } | ||
62 | |||
63 | WaylandPointer<zwp_virtual_keyboard_manager_v1, zwp_virtual_keyboard_manager_v1_destroy> | ||
64 | manager_ptr; | ||
65 | |||
66 | 3 | EventQueue* queue{nullptr}; | |
67 | }; | ||
68 | |||
69 | class Q_DECL_HIDDEN virtual_keyboard_v1::Private | ||
70 | { | ||
71 | public: | ||
72 | Private(Seat* seat, virtual_keyboard_v1* q_ptr); | ||
73 | 6 | virtual ~Private() = default; | |
74 | |||
75 | void setup(zwp_virtual_keyboard_v1* ti); | ||
76 | |||
77 | bool isValid() const; | ||
78 | |||
79 | WaylandPointer<zwp_virtual_keyboard_v1, zwp_virtual_keyboard_v1_destroy> virtual_keyboard_ptr; | ||
80 | |||
81 | EventQueue* queue{nullptr}; | ||
82 | Seat* seat; | ||
83 | |||
84 | file_wrap keymap; | ||
85 | |||
86 | private: | ||
87 | virtual_keyboard_v1* q_ptr; | ||
88 | }; | ||
89 | |||
90 | } | ||
91 |