Directory: | ./ |
---|---|
File: | server/display.cpp |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 53 | 67 | 79.1% |
Branches: | 14 | 28 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /******************************************************************** | ||
2 | Copyright © 2020 Roman Gilg <subdiff@gmail.com> | ||
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 "display.h" | ||
21 | |||
22 | #include "client.h" | ||
23 | #include "client_p.h" | ||
24 | |||
25 | #include "wayland/client.h" | ||
26 | #include "wayland/display.h" | ||
27 | |||
28 | #include "appmenu.h" | ||
29 | #include "blur.h" | ||
30 | #include "compositor.h" | ||
31 | #include "contrast.h" | ||
32 | #include "data_control_v1.h" | ||
33 | #include "data_device_manager.h" | ||
34 | #include "dpms.h" | ||
35 | #include "drm_lease_v1.h" | ||
36 | #include "fake_input.h" | ||
37 | #include "idle_inhibit_v1.h" | ||
38 | #include "idle_notify_v1.h" | ||
39 | #include "input_method_v2.h" | ||
40 | #include "kde_idle.h" | ||
41 | #include "keyboard_shortcuts_inhibit.h" | ||
42 | #include "keystate.h" | ||
43 | #include "layer_shell_v1.h" | ||
44 | #include "linux_dmabuf_v1.h" | ||
45 | #include "plasma_activation_feedback.h" | ||
46 | #include "plasma_shell.h" | ||
47 | #include "plasma_virtual_desktop.h" | ||
48 | #include "plasma_window.h" | ||
49 | #include "pointer.h" | ||
50 | #include "pointer_constraints_v1.h" | ||
51 | #include "pointer_gestures_v1.h" | ||
52 | #include "presentation_time.h" | ||
53 | #include "primary_selection.h" | ||
54 | #include "relative_pointer_v1.h" | ||
55 | #include "seat.h" | ||
56 | #include "server_decoration_palette.h" | ||
57 | #include "shadow.h" | ||
58 | #include "slide.h" | ||
59 | #include "subcompositor.h" | ||
60 | #include "text_input_v2.h" | ||
61 | #include "text_input_v3.h" | ||
62 | #include "viewporter.h" | ||
63 | #include "virtual_keyboard_v1.h" | ||
64 | #include "wl_output_p.h" | ||
65 | #include "xdg_activation_v1.h" | ||
66 | #include "xdg_decoration.h" | ||
67 | #include "xdg_foreign.h" | ||
68 | #include "xdg_output.h" | ||
69 | #include "xdg_shell.h" | ||
70 | |||
71 | #include "logging.h" | ||
72 | |||
73 | #include <EGL/egl.h> | ||
74 | |||
75 | #include <algorithm> | ||
76 | #include <wayland-server.h> | ||
77 | |||
78 | namespace Wrapland::Server | ||
79 | { | ||
80 | |||
81 | 1326 | Display::Display() | |
82 |
2/4✓ Branch 0 taken 663 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
|
663 | : d_ptr(new Wayland::Display(this)) |
83 | 663 | { | |
84 | 663 | } | |
85 | |||
86 | 1308 | Display::~Display() = default; | |
87 | |||
88 | 659 | void Display::set_socket_name(std::string const& name) | |
89 | { | ||
90 | 659 | d_ptr->socket_name = name; | |
91 | 659 | } | |
92 | |||
93 | 4 | std::string Display::socket_name() const | |
94 | { | ||
95 | 4 | return d_ptr->socket_name; | |
96 | } | ||
97 | |||
98 | 663 | void Display::start() | |
99 | { | ||
100 | 663 | d_ptr->start(); | |
101 | 663 | Q_EMIT started(); | |
102 | 663 | } | |
103 | |||
104 | ✗ | void Display::startLoop() | |
105 | { | ||
106 | ✗ | d_ptr->startLoop(); | |
107 | } | ||
108 | |||
109 | 43 | void Display::dispatchEvents(int msecTimeout) | |
110 | { | ||
111 | 43 | d_ptr->dispatchEvents(msecTimeout); | |
112 | 43 | } | |
113 | |||
114 | ✗ | void Display::dispatch() | |
115 | { | ||
116 | ✗ | d_ptr->dispatch(); | |
117 | } | ||
118 | |||
119 | ✗ | void Display::flush() | |
120 | { | ||
121 | ✗ | d_ptr->flush(); | |
122 | } | ||
123 | |||
124 | 3 | void Display::terminate() | |
125 | { | ||
126 | 3 | d_ptr->terminate(); | |
127 | 3 | } | |
128 | |||
129 | 487 | void Display::createShm() | |
130 | { | ||
131 |
1/2✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
|
487 | Q_ASSERT(d_ptr->native()); |
132 | 487 | wl_display_init_shm(d_ptr->native()); | |
133 | 487 | } | |
134 | |||
135 | 570 | quint32 Display::nextSerial() | |
136 | { | ||
137 | 570 | return wl_display_next_serial(d_ptr->native()); | |
138 | } | ||
139 | |||
140 | 62 | quint32 Display::serial() | |
141 | { | ||
142 | 62 | return wl_display_get_serial(d_ptr->native()); | |
143 | } | ||
144 | |||
145 | 622 | bool Display::running() const | |
146 | { | ||
147 | 622 | return d_ptr->running(); | |
148 | } | ||
149 | |||
150 | 8 | wl_display* Display::native() const | |
151 | { | ||
152 | 8 | return d_ptr->native(); | |
153 | } | ||
154 | |||
155 | 597 | Client* Display::getClient(wl_client* wlClient) const | |
156 | { | ||
157 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 591 times.
|
597 | if (auto client = d_ptr->getClient(wlClient)) { |
158 | 6 | return client->handle; | |
159 | } | ||
160 | 591 | return nullptr; | |
161 | 597 | } | |
162 | |||
163 | 8 | std::vector<Client*> Display::clients() const | |
164 | { | ||
165 | 8 | std::vector<Client*> ret; | |
166 |
3/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10 times.
|
18 | for (auto* client : d_ptr->clients()) { |
167 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | ret.push_back(client->handle); |
168 | } | ||
169 | 8 | return ret; | |
170 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | } |
171 | |||
172 | 588 | Client* Display::createClient(wl_client* wlClient) | |
173 | { | ||
174 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588 | assert(!getClient(wlClient)); |
175 | 588 | return d_ptr->createClientHandle(wlClient); | |
176 | } | ||
177 | |||
178 | 5 | Client* Display::createClient(int fd) | |
179 | { | ||
180 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | assert(fd >= 0); |
181 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | assert(d_ptr->native()); |
182 | |||
183 | 5 | auto wl_client = wl_client_create(d_ptr->native(), fd); | |
184 | |||
185 | // TODO(romangg): throw instead? | ||
186 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (!wl_client) { |
187 | ✗ | return nullptr; | |
188 | } | ||
189 | |||
190 | 5 | return createClient(wl_client); | |
191 | 5 | } | |
192 | |||
193 | ✗ | void Display::setEglDisplay(void* display) | |
194 | { | ||
195 | ✗ | if (d_ptr->eglDisplay != EGL_NO_DISPLAY) { | |
196 | ✗ | qCWarning(WRAPLAND_SERVER, "EGLDisplay cannot be changed"); | |
197 | ✗ | return; | |
198 | } | ||
199 | ✗ | d_ptr->eglDisplay = static_cast<EGLDisplay>(display); | |
200 | } | ||
201 | |||
202 | ✗ | void* Display::eglDisplay() const | |
203 | { | ||
204 | ✗ | return d_ptr->eglDisplay; | |
205 | } | ||
206 | |||
207 | } | ||
208 |