Debian Codegraph @

uwac/libuwac/uwac-display.c

raw symbols SCIP
1 /*
2 * Copyright © 2014 David FORT <[email protected]>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22 #include "uwac-priv.h"cxx . . $ `<file>/uwac/libuwac/uwac-priv.h`/
23 #include "uwac-utils.h"cxx . . $ `<file>/uwac/libuwac/uwac-utils.h`/
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <assert.h>
30 #include <errno.h>
31 #include <time.h>
32 #include <unistd.h>
33 #include <sys/epoll.h>
34
35 #include "uwac-os.h"cxx . . $ `<file>/uwac/libuwac/uwac-os.h`/
36 #include "wayland-cursor.h"
37
38 #define TARGET_COMPOSITOR_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:38:9`! 3U
39 #define TARGET_SHM_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:39:9`! 1U
40 #define TARGET_SHELL_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:40:9`! 1U
41 #define TARGET_DDM_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:41:9`! 1U
42 #define TARGET_SEAT_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:42:9`! 5U
43 #define TARGET_XDG_VERSIONcxx . . $ `uwac/libuwac/uwac-display.c:43:9`! 5U /* The version of xdg-shell that we implement */
44
45 #if !defined(NDEBUGcxx . . $ `<built-in>:423:9`!)
46 static const char* event_names[] = {
47 "new seat", "removed seat", "new output", "configure", "pointer enter",
48 "pointer leave", "pointer motion", "pointer buttons", "pointer axis", "keyboard enter",
49 "key", "touch frame begin", "touch up", "touch down", "touch motion",
50 "touch cancel", "touch frame end", "frame done", "close", nullptr
51 };
52 #endif
53
54 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! uwac_default_error_handlercxx . . $ uwac_default_error_handler(57da8071b97367d6).(UwacDisplaycxx . . $ UwacDisplay#* display, UwacReturnCodecxx . . $ UwacReturnCode# code, const char* msg,
55 ...)
56 {
57 va_listcxx . . $ va_list# args = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!;
58 va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(args, msg);
59 (void)vfprintfcxx . . $ vfprintf(bded311e54d67f9c).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s", args);
60 va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(args);
61 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
62 }
63
64 UwacErrorHandlercxx . . $ UwacErrorHandler# uwacErrorHandlercxx . . $ uwacErrorHandler. = uwac_default_error_handlercxx . . $ uwac_default_error_handler(57da8071b97367d6).;
65
66 void UwacInstallErrorHandlercxx . . $ UwacInstallErrorHandler(566057c9541b46cd).(UwacErrorHandlercxx . . $ UwacErrorHandler# handler)
67 {
68 if (handler)
69 uwacErrorHandlercxx . . $ uwacErrorHandler. = handler;
70 else
71 uwacErrorHandlercxx . . $ uwacErrorHandler. = uwac_default_error_handlercxx . . $ uwac_default_error_handler(57da8071b97367d6).;
72 }
73
74 static void cb_shm_formatcxx . . $ cb_shm_format(d7decac8f607c04e).(void* data, struct wl_shmcxx . . $ wl_shm#* wl_shm, uint32_tcxx . . $ uint32_t# format)
75 {
76 UwacDisplaycxx . . $ UwacDisplay#* d = data;
77
78 if (format == WL_SHM_FORMAT_RGB565cxx . . $ WL_SHM_FORMAT_RGB565.)
79 d->has_rgb565cxx . . $ uwac_display#has_rgb565. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
80
81 d->shm_formats_nbcxx . . $ uwac_display#shm_formats_nb.++;
82 d->shm_formatscxx . . $ uwac_display#shm_formats. =
83 xrealloccxx . . $ xrealloc(417ab160f6baadc6).((void*)d->shm_formatscxx . . $ uwac_display#shm_formats., sizeof(enum wl_shm_formatcxx . . $ wl_shm_format#) * d->shm_formats_nbcxx . . $ uwac_display#shm_formats_nb.);
84 d->shm_formatscxx . . $ uwac_display#shm_formats.[d->shm_formats_nbcxx . . $ uwac_display#shm_formats_nb. - 1] = format;
85 }
86
87 static struct wl_shm_listenercxx . . $ wl_shm_listener# shm_listenercxx . . $ shm_listener. = { cb_shm_formatcxx . . $ cb_shm_format(d7decac8f607c04e). };
88
89 static void xdg_shell_pingcxx . . $ xdg_shell_ping(b1049735f8824d3c).(void* data, struct xdg_wm_basecxx . . $ xdg_wm_base#* xdg_wm_base, uint32_tcxx . . $ uint32_t# serial)
90 {
91 xdg_wm_base_pongcxx . . $ xdg_wm_base_pong(13ec07cd0606ce95).(xdg_wm_base, serial);
92 }
93
94 static const struct xdg_wm_base_listenercxx . . $ xdg_wm_base_listener# xdg_wm_base_listenercxx . . $ xdg_wm_base_listener. = {
95 xdg_shell_pingcxx . . $ xdg_shell_ping(b1049735f8824d3c).,
96 };
97
98 #ifdef BUILD_FULLSCREEN_SHELLcxx . . $ `<built-in>:410:9`!
99 static void fullscreen_capabilitycxx . . $ fullscreen_capability(6686c69693d1285c).(void* data,
100 struct zwp_fullscreen_shell_v1cxx . . $ zwp_fullscreen_shell_v1#* zwp_fullscreen_shell_v1,
101 uint32_tcxx . . $ uint32_t# capability)
102 {
103 }
104
105 static const struct zwp_fullscreen_shell_v1_listenercxx . . $ zwp_fullscreen_shell_v1_listener# fullscreen_shell_listenercxx . . $ fullscreen_shell_listener. = {
106 fullscreen_capabilitycxx . . $ fullscreen_capability(6686c69693d1285c).,
107 };
108 #endif
109
110 static void display_destroy_seatcxx . . $ display_destroy_seat(ea693d6981cac7a).(UwacDisplaycxx . . $ UwacDisplay#* d, uint32_tcxx . . $ uint32_t# name)
111 {
112 UwacSeatcxx . . $ UwacSeat#* seat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
113 UwacSeatcxx . . $ UwacSeat#* tmp = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
114 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(seat, tmp, &d->seats, link)
115 {
116 if (seat->seat_idcxx . . $ uwac_seat#seat_id. == name)
117 {
118 UwacSeatDestroycxx . . $ UwacSeatDestroy(9917d0f05d90b4b8).(seat);
119 }
120 }
121 }
122
123 static void UwacSeatRegisterDDMcxx . . $ UwacSeatRegisterDDM(9917d0f05d90b4b8).(UwacSeatcxx . . $ UwacSeat#* seat)
124 {
125 UwacDisplaycxx . . $ UwacDisplay#* d = seat->displaycxx . . $ uwac_seat#display.;
126 if (!d->data_device_managercxx . . $ uwac_display#data_device_manager.)
127 return;
128
129 if (!seat->data_devicecxx . . $ uwac_seat#data_device.)
130 seat->data_devicecxx . . $ uwac_seat#data_device. =
131 wl_data_device_manager_get_data_devicecxx . . $ wl_data_device_manager_get_data_device(ee8392505f93c43f).(d->data_device_managercxx . . $ uwac_display#data_device_manager., seat->seatcxx . . $ uwac_seat#seat.);
132 }
133
134 static void UwacRegisterCursorcxx . . $ UwacRegisterCursor(9917d0f05d90b4b8).(UwacSeatcxx . . $ UwacSeat#* seat)
135 {
136 if (!seat || !seat->displaycxx . . $ uwac_seat#display. || !seat->displaycxx . . $ uwac_seat#display.->compositorcxx . . $ uwac_display#compositor.)
137 return;
138
139 seat->pointer_surfacecxx . . $ uwac_seat#pointer_surface. = wl_compositor_create_surfacecxx . . $ wl_compositor_create_surface(e4f298ac62eed481).(seat->displaycxx . . $ uwac_seat#display.->compositorcxx . . $ uwac_display#compositor.);
140 }
141
142 static void registry_handle_globalcxx . . $ registry_handle_global(726e51158386df5).(void* data, struct wl_registrycxx . . $ wl_registry#* registry, uint32_tcxx . . $ uint32_t# id,
143 const char* interface, uint32_tcxx . . $ uint32_t# version)
144 {
145 UwacDisplaycxx . . $ UwacDisplay#* d = data;
146 UwacGlobalcxx . . $ UwacGlobal#* global = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
147 global = xzalloccxx . . $ xzalloc(bfcfa4d6b7f7ef64).(sizeof *global);
148 global->namecxx . . $ uwac_global#name. = id;
149 global->interfacecxx . . $ uwac_global#interface. = xstrdupcxx . . $ xstrdup(a8b8e32347182212).(interface);
150 global->versioncxx . . $ uwac_global#version. = version;
151 wl_list_insertcxx . . $ wl_list_insert(5be1c752181daf42).(d->globalscxx . . $ uwac_display#globals..prevcxx . . $ wl_list#prev., &global->linkcxx . . $ uwac_global#link.);
152
153 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_compositor") == 0)
154 {
155 d->compositorcxx . . $ uwac_display#compositor. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &wl_compositor_interfacecxx . . $ wl_compositor_interface.,
156 mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!(TARGET_COMPOSITOR_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:38:9`!, version));
157 }
158 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_shm") == 0)
159 {
160 d->shmcxx . . $ uwac_display#shm. =
161 wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &wl_shm_interfacecxx . . $ wl_shm_interface., mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!(TARGET_SHM_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:39:9`!, version));
162 wl_shm_add_listenercxx . . $ wl_shm_add_listener(a4adb9cbfcf2d3d3).(d->shmcxx . . $ uwac_display#shm., &shm_listenercxx . . $ shm_listener., d);
163 }
164 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_output") == 0)
165 {
166 UwacOutputcxx . . $ UwacOutput#* output = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
167 UwacOutputNewEventcxx . . $ UwacOutputNewEvent#* ev = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
168 output = UwacCreateOutputcxx . . $ UwacCreateOutput(2519888fa5e8806a).(d, id, version);
169
170 if (!output)
171 {
172 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(uwacErrorHandler(d, UWAC_ERROR_NOMEMORY, "unable to create output\n"));
173 return;
174 }
175
176 ev = (UwacOutputNewEventcxx . . $ UwacOutputNewEvent#*)UwacDisplayNewEventcxx . . $ UwacDisplayNewEvent(f698cd9f7a1e75c).(d, UWAC_EVENT_NEW_OUTPUTcxx . . $ UWAC_EVENT_NEW_OUTPUT.);
177
178 if (ev)
179 ev->outputcxx . . $ uwac_new_output_event#output. = output;
180 }
181 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_seat") == 0)
182 {
183 UwacSeatNewEventcxx . . $ UwacSeatNewEvent#* ev = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
184 UwacSeatcxx . . $ UwacSeat#* seat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
185 seat = UwacSeatNewcxx . . $ UwacSeatNew(130fa335c3415d7a).(d, id, mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!(version, TARGET_SEAT_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:42:9`!));
186
187 if (!seat)
188 {
189 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(uwacErrorHandler(d, UWAC_ERROR_NOMEMORY, "unable to create new seat\n"));
190 return;
191 }
192
193 UwacSeatRegisterDDMcxx . . $ UwacSeatRegisterDDM(9917d0f05d90b4b8).(seat);
194 UwacSeatRegisterClipboardcxx . . $ UwacSeatRegisterClipboard(106257c854967434).(seat);
195 UwacRegisterCursorcxx . . $ UwacRegisterCursor(9917d0f05d90b4b8).(seat);
196 ev = (UwacSeatNewEventcxx . . $ UwacSeatNewEvent#*)UwacDisplayNewEventcxx . . $ UwacDisplayNewEvent(f698cd9f7a1e75c).(d, UWAC_EVENT_NEW_SEATcxx . . $ UWAC_EVENT_NEW_SEAT.);
197
198 if (!ev)
199 {
200 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(uwacErrorHandler(d, UWAC_ERROR_NOMEMORY, "unable to create new seat event\n"));
201 return;
202 }
203
204 ev->seatcxx . . $ uwac_new_seat_event#seat. = seat;
205 }
206 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_data_device_manager") == 0)
207 {
208 UwacSeatcxx . . $ UwacSeat#* seat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
209 UwacSeatcxx . . $ UwacSeat#* tmp = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
210
211 d->data_device_managercxx . . $ uwac_display#data_device_manager. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &wl_data_device_manager_interfacecxx . . $ wl_data_device_manager_interface.,
212 mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!(TARGET_DDM_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:41:9`!, version));
213
214 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(seat, tmp, &d->seats, link)
215 {
216 UwacSeatRegisterDDMcxx . . $ UwacSeatRegisterDDM(9917d0f05d90b4b8).(seat);
217 UwacSeatRegisterClipboardcxx . . $ UwacSeatRegisterClipboard(106257c854967434).(seat);
218 UwacRegisterCursorcxx . . $ UwacRegisterCursor(9917d0f05d90b4b8).(seat);
219 }
220 }
221 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wl_shell") == 0)
222 {
223 d->shellcxx . . $ uwac_display#shell. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &wl_shell_interfacecxx . . $ wl_shell_interface.,
224 mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!(TARGET_SHELL_INTERFACEcxx . . $ `uwac/libuwac/uwac-display.c:40:9`!, version));
225 }
226 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "xdg_wm_base") == 0)
227 {
228 d->xdg_basecxx . . $ uwac_display#xdg_base. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &xdg_wm_base_interfacecxx . . $ xdg_wm_base_interface., 1);
229 xdg_wm_base_add_listenercxx . . $ xdg_wm_base_add_listener(9e2f6dfcc21444f3).(d->xdg_basecxx . . $ uwac_display#xdg_base., &xdg_wm_base_listenercxx . . $ xdg_wm_base_listener., d);
230 }
231 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "wp_viewporter") == 0)
232 {
233 d->viewportercxx . . $ uwac_display#viewporter. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &wp_viewporter_interfacecxx . . $ wp_viewporter_interface., 1);
234 }
235 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "zwp_keyboard_shortcuts_inhibit_manager_v1") == 0)
236 {
237 d->keyboard_inhibit_managercxx . . $ uwac_display#keyboard_inhibit_manager. =
238 wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interfacecxx . . $ zwp_keyboard_shortcuts_inhibit_manager_v1_interface., 1);
239 }
240 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "zxdg_decoration_manager_v1") == 0)
241 {
242 d->deco_managercxx . . $ uwac_display#deco_manager. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &zxdg_decoration_manager_v1_interfacecxx . . $ zxdg_decoration_manager_v1_interface., 1);
243 }
244 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "org_kde_kwin_server_decoration_manager") == 0)
245 {
246 d->kde_deco_managercxx . . $ uwac_display#kde_deco_manager. =
247 wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &org_kde_kwin_server_decoration_manager_interfacecxx . . $ org_kde_kwin_server_decoration_manager_interface., 1);
248 }
249 #if BUILD_IVIcxx . . $ `<built-in>:411:9`!
250 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "ivi_application") == 0)
251 {
252 d->ivi_applicationcxx . . $ uwac_display#ivi_application. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &ivi_application_interfacecxx . . $ ivi_application_interface., 1);
253 }
254 #endif
255 #if BUILD_FULLSCREEN_SHELLcxx . . $ `<built-in>:410:9`!
256 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(interface, "zwp_fullscreen_shell_v1") == 0)
257 {
258 d->fullscreen_shellcxx . . $ uwac_display#fullscreen_shell. = wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(registry, id, &zwp_fullscreen_shell_v1_interfacecxx . . $ zwp_fullscreen_shell_v1_interface., 1);
259 zwp_fullscreen_shell_v1_add_listenercxx . . $ zwp_fullscreen_shell_v1_add_listener(312c39f810a571a).(d->fullscreen_shellcxx . . $ uwac_display#fullscreen_shell., &fullscreen_shell_listenercxx . . $ fullscreen_shell_listener., d);
260 }
261 #endif
262 #if 0
263 else if (strcmp(interface, "text_cursor_position") == 0)
264 {
265 d->text_cursor_position = wl_registry_bind(registry, id, &text_cursor_position_interface, 1);
266 }
267 else if (strcmp(interface, "workspace_manager") == 0)
268 {
269 //init_workspace_manager(d, id);
270 }
271 else if (strcmp(interface, "wl_subcompositor") == 0)
272 {
273 d->subcompositor = wl_registry_bind(registry, id, &wl_subcompositor_interface, 1);
274 #endif
275 }
276
277 static void registry_handle_global_removecxx . . $ registry_handle_global_remove(f67cefd61ad6777a).(void* data, struct wl_registrycxx . . $ wl_registry#* registry, uint32_tcxx . . $ uint32_t# name)
278 {
279 UwacDisplaycxx . . $ UwacDisplay#* d = data;
280 UwacGlobalcxx . . $ UwacGlobal#* global = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
281 UwacGlobalcxx . . $ UwacGlobal#* tmp = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
282 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(global, tmp, &d->globals, link)
283 {
284 if (global->namecxx . . $ uwac_global#name. != name)
285 continue;
286
287 #if 0
288
289 if (strcmp(global->interface, "wl_output") == 0)
290 display_destroy_output(d, name);
291
292 #endif
293
294 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(global->interfacecxx . . $ uwac_global#interface., "wl_seat") == 0)
295 {
296 UwacSeatRemovedEventcxx . . $ UwacSeatRemovedEvent#* ev = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
297 display_destroy_seatcxx . . $ display_destroy_seat(ea693d6981cac7a).(d, name);
298 ev = (UwacSeatRemovedEventcxx . . $ UwacSeatRemovedEvent#*)UwacDisplayNewEventcxx . . $ UwacDisplayNewEvent(f698cd9f7a1e75c).(d, UWAC_EVENT_REMOVED_SEATcxx . . $ UWAC_EVENT_REMOVED_SEAT.);
299
300 if (ev)
301 ev->idcxx . . $ uwac_removed_seat_event#id. = name;
302 }
303
304 wl_list_removecxx . . $ wl_list_remove(cb3edbba2415fa5b).(&global->linkcxx . . $ uwac_global#link.);
305 freecxx . . $ free(5d22bdacc48458e8).(global->interfacecxx . . $ uwac_global#interface.);
306 freecxx . . $ free(5d22bdacc48458e8).(global);
307 }
308 }
309
310 static void UwacDestroyGlobalcxx . . $ UwacDestroyGlobal(8980c366bb37471a).(UwacGlobalcxx . . $ UwacGlobal#* global)
311 {
312 freecxx . . $ free(5d22bdacc48458e8).(global->interfacecxx . . $ uwac_global#interface.);
313 wl_list_removecxx . . $ wl_list_remove(cb3edbba2415fa5b).(&global->linkcxx . . $ uwac_global#link.);
314 freecxx . . $ free(5d22bdacc48458e8).(global);
315 }
316
317 static void* display_bindcxx . . $ display_bind(ddab5eff0955c419).(UwacDisplaycxx . . $ UwacDisplay#* display, uint32_tcxx . . $ uint32_t# name, const struct wl_interfacecxx . . $ wl_interface#* interface,
318 uint32_tcxx . . $ uint32_t# version)
319 {
320 return wl_registry_bindcxx . . $ wl_registry_bind(60af4078e5fa74fe).(display->registrycxx . . $ uwac_display#registry., name, interface, version);
321 }
322
323 static const struct wl_registry_listenercxx . . $ wl_registry_listener# registry_listenercxx . . $ registry_listener. = { registry_handle_globalcxx . . $ registry_handle_global(726e51158386df5).,
324 registry_handle_global_removecxx . . $ registry_handle_global_remove(f67cefd61ad6777a). };
325
326 int UwacDisplayWatchFdcxx . . $ UwacDisplayWatchFd(9aaa87a6640cbadd).(UwacDisplaycxx . . $ UwacDisplay#* display, int fd, uint32_tcxx . . $ uint32_t# events, UwacTaskcxx . . $ UwacTask#* task)
327 {
328 struct epoll_eventcxx . . $ epoll_event# ep;
329 ep.eventscxx . . $ epoll_event#events. = events;
330 ep.datacxx . . $ epoll_event#data..ptrcxx . . $ epoll_data#ptr. = task;
331 return epoll_ctlcxx . . $ epoll_ctl(9943be275b30aff9).(display->epoll_fdcxx . . $ uwac_display#epoll_fd., EPOLL_CTL_ADDcxx . . $ `<external>/7997773257684133104/epoll.h:72:9`!, fd, &ep);
332 }
333
334 static void UwacDisplayUnwatchFdcxx . . $ UwacDisplayUnwatchFd(e513af29abbeb6b6).(UwacDisplaycxx . . $ UwacDisplay#* display, int fd)
335 {
336 epoll_ctlcxx . . $ epoll_ctl(9943be275b30aff9).(display->epoll_fdcxx . . $ uwac_display#epoll_fd., EPOLL_CTL_DELcxx . . $ `<external>/7997773257684133104/epoll.h:73:9`!, fd, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!);
337 }
338
339 static void display_exitcxx . . $ display_exit(f4efb4f39cd529f3).(UwacDisplaycxx . . $ UwacDisplay#* display)
340 {
341 display->runningcxx . . $ uwac_display#running. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
342 }
343
344 static void display_dispatch_eventscxx . . $ display_dispatch_events(3cc76526b8a331fb).(UwacTaskcxx . . $ UwacTask#* task, uint32_tcxx . . $ uint32_t# events)
345 {
346 UwacDisplaycxx . . $ UwacDisplay#* display = container_ofcxx . . $ `uwac/libuwac/uwac-utils.h:33:9`!(task, UwacDisplay, dispatch_fd_task);
347 struct epoll_eventcxx . . $ epoll_event# ep;
348 int ret = 0;
349 display->display_fd_eventscxx . . $ uwac_display#display_fd_events. = events;
350
351 if ((events & EPOLLERRcxx . . $ `<external>/7997773257684133104/epoll.h:55:9`!) || (events & EPOLLHUPcxx . . $ `<external>/7997773257684133104/epoll.h:57:9`!))
352 {
353 display_exitcxx . . $ display_exit(f4efb4f39cd529f3).(display);
354 return;
355 }
356
357 if (events & EPOLLINcxx . . $ `<external>/7997773257684133104/epoll.h:39:9`!)
358 {
359 ret = wl_display_dispatchcxx . . $ wl_display_dispatch(ab6e353c475300d8).(display->displaycxx . . $ uwac_display#display.);
360
361 if (ret == -1)
362 {
363 display_exitcxx . . $ display_exit(f4efb4f39cd529f3).(display);
364 return;
365 }
366 }
367
368 if (events & EPOLLOUTcxx . . $ `<external>/7997773257684133104/epoll.h:43:9`!)
369 {
370 ret = wl_display_flushcxx . . $ wl_display_flush(ab6e353c475300d8).(display->displaycxx . . $ uwac_display#display.);
371
372 if (ret == 0)
373 {
374 ep.eventscxx . . $ epoll_event#events. = EPOLLINcxx . . $ `<external>/7997773257684133104/epoll.h:39:9`! | EPOLLERRcxx . . $ `<external>/7997773257684133104/epoll.h:55:9`! | EPOLLHUPcxx . . $ `<external>/7997773257684133104/epoll.h:57:9`!;
375 ep.datacxx . . $ epoll_event#data..ptrcxx . . $ epoll_data#ptr. = &display->dispatch_fd_taskcxx . . $ uwac_display#dispatch_fd_task.;
376 epoll_ctlcxx . . $ epoll_ctl(9943be275b30aff9).(display->epoll_fdcxx . . $ uwac_display#epoll_fd., EPOLL_CTL_MODcxx . . $ `<external>/7997773257684133104/epoll.h:74:9`!, display->display_fdcxx . . $ uwac_display#display_fd., &ep);
377 }
378 else if (ret == -1 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!)
379 {
380 display_exitcxx . . $ display_exit(f4efb4f39cd529f3).(display);
381 return;
382 }
383 }
384 }
385
386 UwacDisplaycxx . . $ UwacDisplay#* UwacOpenDisplaycxx . . $ UwacOpenDisplay(e140dd84d065645f).(const char* name, UwacReturnCodecxx . . $ UwacReturnCode#* err)
387 {
388 UwacDisplaycxx . . $ UwacDisplay#* ret = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
389 ret = (UwacDisplaycxx . . $ UwacDisplay#*)xzalloccxx . . $ xzalloc(bfcfa4d6b7f7ef64).(sizeof(*ret));
390
391 if (!ret)
392 {
393 *err = UWAC_ERROR_NOMEMORYcxx . . $ UWAC_ERROR_NOMEMORY.;
394 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
395 }
396
397 wl_list_initcxx . . $ wl_list_init(cb3edbba2415fa5b).(&ret->globalscxx . . $ uwac_display#globals.);
398 wl_list_initcxx . . $ wl_list_init(cb3edbba2415fa5b).(&ret->seatscxx . . $ uwac_display#seats.);
399 wl_list_initcxx . . $ wl_list_init(cb3edbba2415fa5b).(&ret->outputscxx . . $ uwac_display#outputs.);
400 wl_list_initcxx . . $ wl_list_init(cb3edbba2415fa5b).(&ret->windowscxx . . $ uwac_display#windows.);
401 ret->displaycxx . . $ uwac_display#display. = wl_display_connectcxx . . $ wl_display_connect(d532ccae3ff0d140).(name);
402
403 if (ret->displaycxx . . $ uwac_display#display. == nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!)
404 {
405 char buffer[256] = WINPR_C_ARRAY_INITcxx . . $ `winpr/include/winpr/platform.h:87:9`!;
406 (void)fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to connect to Wayland display %s: %s\n", name,
407 uwac_strerrorcxx . . $ uwac_strerror(c3cf521967a2a310).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, buffer, sizeof(buffer)));
408 *err = UWAC_ERROR_UNABLE_TO_CONNECTcxx . . $ UWAC_ERROR_UNABLE_TO_CONNECT.;
409 goto out_free;
410 }
411
412 ret->epoll_fdcxx . . $ uwac_display#epoll_fd. = uwac_os_epoll_create_cloexeccxx . . $ uwac_os_epoll_create_cloexec(b126dc7c1de90089).();
413
414 if (ret->epoll_fdcxx . . $ uwac_display#epoll_fd. < 0)
415 {
416 *err = UWAC_NOT_ENOUGH_RESOURCEScxx . . $ UWAC_NOT_ENOUGH_RESOURCES.;
417 goto out_disconnect;
418 }
419
420 ret->display_fdcxx . . $ uwac_display#display_fd. = wl_display_get_fdcxx . . $ wl_display_get_fd(ab6e353c475300d8).(ret->displaycxx . . $ uwac_display#display.);
421 ret->registrycxx . . $ uwac_display#registry. = wl_display_get_registrycxx . . $ wl_display_get_registry(ce14889db92c85a1).(ret->displaycxx . . $ uwac_display#display.);
422
423 if (!ret->registrycxx . . $ uwac_display#registry.)
424 {
425 *err = UWAC_ERROR_NOMEMORYcxx . . $ UWAC_ERROR_NOMEMORY.;
426 goto out_close_epoll;
427 }
428
429 wl_registry_add_listenercxx . . $ wl_registry_add_listener(6cc57d5e66fe0e3c).(ret->registrycxx . . $ uwac_display#registry., &registry_listenercxx . . $ registry_listener., ret);
430
431 if ((wl_display_roundtripcxx . . $ wl_display_roundtrip(ab6e353c475300d8).(ret->displaycxx . . $ uwac_display#display.) < 0) || (wl_display_roundtripcxx . . $ wl_display_roundtrip(ab6e353c475300d8).(ret->displaycxx . . $ uwac_display#display.) < 0))
432 {
433 uwacErrorHandlercxx . . $ uwacErrorHandler.(ret, UWAC_ERROR_UNABLE_TO_CONNECTcxx . . $ UWAC_ERROR_UNABLE_TO_CONNECT.,
434 "Failed to process Wayland connection: %m\n");
435 *err = UWAC_ERROR_UNABLE_TO_CONNECTcxx . . $ UWAC_ERROR_UNABLE_TO_CONNECT.;
436 goto out_free_registry;
437 }
438
439 ret->dispatch_fd_taskcxx . . $ uwac_display#dispatch_fd_task..runcxx . . $ uwac_task#run. = display_dispatch_eventscxx . . $ display_dispatch_events(3cc76526b8a331fb).;
440
441 if (UwacDisplayWatchFdcxx . . $ UwacDisplayWatchFd(9aaa87a6640cbadd).(ret, ret->display_fdcxx . . $ uwac_display#display_fd., EPOLLINcxx . . $ `<external>/7997773257684133104/epoll.h:39:9`! | EPOLLERRcxx . . $ `<external>/7997773257684133104/epoll.h:55:9`! | EPOLLHUPcxx . . $ `<external>/7997773257684133104/epoll.h:57:9`!,
442 &ret->dispatch_fd_taskcxx . . $ uwac_display#dispatch_fd_task.) < 0)
443 {
444 uwacErrorHandlercxx . . $ uwacErrorHandler.(ret, UWAC_ERROR_INTERNALcxx . . $ UWAC_ERROR_INTERNAL., "unable to watch display fd: %m\n");
445 *err = UWAC_ERROR_INTERNALcxx . . $ UWAC_ERROR_INTERNAL.;
446 goto out_free_registry;
447 }
448
449 ret->runningcxx . . $ uwac_display#running. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
450 ret->last_errorcxx . . $ uwac_display#last_error. = *err = UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
451 return ret;
452 out_free_registry:
453 wl_registry_destroycxx . . $ wl_registry_destroy(8f8fd4354233e784).(ret->registrycxx . . $ uwac_display#registry.);
454 out_close_epoll:
455 closecxx . . $ close(7864480464b09eea).(ret->epoll_fdcxx . . $ uwac_display#epoll_fd.);
456 out_disconnect:
457 wl_display_disconnectcxx . . $ wl_display_disconnect(dfc29eeec957a140).(ret->displaycxx . . $ uwac_display#display.);
458 out_free:
459 freecxx . . $ free(5d22bdacc48458e8).(ret);
460 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
461 }
462
463 int UwacDisplayDispatchcxx . . $ UwacDisplayDispatch(447a1ee01e23a2a1).(UwacDisplaycxx . . $ UwacDisplay#* display, int timeout)
464 {
465 int ret = 0;
466 int count = 0;
467 UwacTaskcxx . . $ UwacTask#* task = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
468 struct epoll_eventcxx . . $ epoll_event# ep[16];
469 wl_display_dispatch_pendingcxx . . $ wl_display_dispatch_pending(ab6e353c475300d8).(display->displaycxx . . $ uwac_display#display.);
470
471 if (!display->runningcxx . . $ uwac_display#running.)
472 return 0;
473
474 ret = wl_display_flushcxx . . $ wl_display_flush(ab6e353c475300d8).(display->displaycxx . . $ uwac_display#display.);
475
476 if (ret < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!)
477 {
478 ep[0].eventscxx . . $ epoll_event#events. = (EPOLLINcxx . . $ `<external>/7997773257684133104/epoll.h:39:9`! | EPOLLOUTcxx . . $ `<external>/7997773257684133104/epoll.h:43:9`! | EPOLLERRcxx . . $ `<external>/7997773257684133104/epoll.h:55:9`! | EPOLLHUPcxx . . $ `<external>/7997773257684133104/epoll.h:57:9`!);
479 ep[0].datacxx . . $ epoll_event#data..ptrcxx . . $ epoll_data#ptr. = &display->dispatch_fd_taskcxx . . $ uwac_display#dispatch_fd_task.;
480 epoll_ctlcxx . . $ epoll_ctl(9943be275b30aff9).(display->epoll_fdcxx . . $ uwac_display#epoll_fd., EPOLL_CTL_MODcxx . . $ `<external>/7997773257684133104/epoll.h:74:9`!, display->display_fdcxx . . $ uwac_display#display_fd., &ep[0]);
481 }
482 else if (ret < 0)
483 {
484 return -1;
485 }
486
487 count = epoll_waitcxx . . $ epoll_wait(50c76d20e903e766).(display->epoll_fdcxx . . $ uwac_display#epoll_fd., ep, ARRAY_LENGTHcxx . . $ `uwac/libuwac/uwac-utils.h:35:9`!(ep), timeout);
488
489 for (int i = 0; i < count; i++)
490 {
491 task = ep[i].datacxx . . $ epoll_event#data..ptrcxx . . $ epoll_data#ptr.;
492 task->runcxx . . $ uwac_task#run.(task, ep[i].eventscxx . . $ epoll_event#events.);
493 }
494
495 return 1;
496 }
497
498 UwacReturnCodecxx . . $ UwacReturnCode# UwacDisplayGetLastErrorcxx . . $ UwacDisplayGetLastError(7ebbe4c01e54ed2d).(const UwacDisplaycxx . . $ UwacDisplay#* display)
499 {
500 return display->last_errorcxx . . $ uwac_display#last_error.;
501 }
502
503 UwacReturnCodecxx . . $ UwacReturnCode# UwacCloseDisplaycxx . . $ UwacCloseDisplay(cb95706cd775f731).(UwacDisplaycxx . . $ UwacDisplay#** pdisplay)
504 {
505 UwacDisplaycxx . . $ UwacDisplay#* display = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
506 UwacSeatcxx . . $ UwacSeat#* seat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
507 UwacSeatcxx . . $ UwacSeat#* tmpSeat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
508 UwacWindowcxx . . $ UwacWindow#* window = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
509 UwacWindowcxx . . $ UwacWindow#* tmpWindow = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
510 UwacOutputcxx . . $ UwacOutput#* output = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
511 UwacOutputcxx . . $ UwacOutput#* tmpOutput = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
512 UwacGlobalcxx . . $ UwacGlobal#* global = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
513 UwacGlobalcxx . . $ UwacGlobal#* tmpGlobal = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
514 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(pdisplay);
515 display = *pdisplay;
516
517 if (!display)
518 return UWAC_ERROR_INVALID_DISPLAYcxx . . $ UWAC_ERROR_INVALID_DISPLAY.;
519
520 /* destroy windows */
521 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(window, tmpWindow, &display->windows, link)
522 {
523 UwacDestroyWindowcxx . . $ UwacDestroyWindow(269435b7a2b1d8cb).(&window);
524 }
525 /* destroy seats */
526 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(seat, tmpSeat, &display->seats, link)
527 {
528 UwacSeatDestroycxx . . $ UwacSeatDestroy(9917d0f05d90b4b8).(seat);
529 }
530 /* destroy output */
531 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(output, tmpOutput, &display->outputs, link)
532 {
533 UwacDestroyOutputcxx . . $ UwacDestroyOutput(55d00f29aa353ae5).(output);
534 }
535 /* destroy globals */
536 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(global, tmpGlobal, &display->globals, link)
537 {
538 UwacDestroyGlobalcxx . . $ UwacDestroyGlobal(8980c366bb37471a).(global);
539 }
540
541 if (display->compositorcxx . . $ uwac_display#compositor.)
542 wl_compositor_destroycxx . . $ wl_compositor_destroy(17c06d38fba8d2b5).(display->compositorcxx . . $ uwac_display#compositor.);
543
544 if (display->keyboard_inhibit_managercxx . . $ uwac_display#keyboard_inhibit_manager.)
545 zwp_keyboard_shortcuts_inhibit_manager_v1_destroycxx . . $ zwp_keyboard_shortcuts_inhibit_manager_v1_destroy(3ec1782d05a1e12c).(display->keyboard_inhibit_managercxx . . $ uwac_display#keyboard_inhibit_manager.);
546
547 if (display->deco_managercxx . . $ uwac_display#deco_manager.)
548 zxdg_decoration_manager_v1_destroycxx . . $ zxdg_decoration_manager_v1_destroy(6cc8cbd2d8305e18).(display->deco_managercxx . . $ uwac_display#deco_manager.);
549
550 if (display->kde_deco_managercxx . . $ uwac_display#kde_deco_manager.)
551 org_kde_kwin_server_decoration_manager_destroycxx . . $ org_kde_kwin_server_decoration_manager_destroy(56692b912759fc68).(display->kde_deco_managercxx . . $ uwac_display#kde_deco_manager.);
552
553 #ifdef BUILD_FULLSCREEN_SHELLcxx . . $ `<built-in>:410:9`!
554
555 if (display->fullscreen_shellcxx . . $ uwac_display#fullscreen_shell.)
556 zwp_fullscreen_shell_v1_destroycxx . . $ zwp_fullscreen_shell_v1_destroy(edae017c9c26b325).(display->fullscreen_shellcxx . . $ uwac_display#fullscreen_shell.);
557
558 #endif
559 #ifdef BUILD_IVIcxx . . $ `<built-in>:411:9`!
560
561 if (display->ivi_applicationcxx . . $ uwac_display#ivi_application.)
562 ivi_application_destroycxx . . $ ivi_application_destroy(a169ac6fa11cc00b).(display->ivi_applicationcxx . . $ uwac_display#ivi_application.);
563
564 #endif
565
566 if (display->xdg_toplevelcxx . . $ uwac_display#xdg_toplevel.)
567 xdg_toplevel_destroycxx . . $ xdg_toplevel_destroy(51631a71212a91a3).(display->xdg_toplevelcxx . . $ uwac_display#xdg_toplevel.);
568
569 if (display->xdg_basecxx . . $ uwac_display#xdg_base.)
570 xdg_wm_base_destroycxx . . $ xdg_wm_base_destroy(a03043c2a69a08c8).(display->xdg_basecxx . . $ uwac_display#xdg_base.);
571
572 if (display->shellcxx . . $ uwac_display#shell.)
573 wl_shell_destroycxx . . $ wl_shell_destroy(43df09e9d54d4fd6).(display->shellcxx . . $ uwac_display#shell.);
574
575 if (display->shmcxx . . $ uwac_display#shm.)
576 wl_shm_destroycxx . . $ wl_shm_destroy(2351d7182276a0e8).(display->shmcxx . . $ uwac_display#shm.);
577
578 if (display->viewportercxx . . $ uwac_display#viewporter.)
579 wp_viewporter_destroycxx . . $ wp_viewporter_destroy(bc2f3da9f68df15e).(display->viewportercxx . . $ uwac_display#viewporter.);
580
581 if (display->subcompositorcxx . . $ uwac_display#subcompositor.)
582 wl_subcompositor_destroycxx . . $ wl_subcompositor_destroy(736249a2900cebcb).(display->subcompositorcxx . . $ uwac_display#subcompositor.);
583
584 if (display->data_device_managercxx . . $ uwac_display#data_device_manager.)
585 wl_data_device_manager_destroycxx . . $ wl_data_device_manager_destroy(41ca79a473158015).(display->data_device_managercxx . . $ uwac_display#data_device_manager.);
586
587 freecxx . . $ free(5d22bdacc48458e8).(display->shm_formatscxx . . $ uwac_display#shm_formats.);
588 wl_registry_destroycxx . . $ wl_registry_destroy(8f8fd4354233e784).(display->registrycxx . . $ uwac_display#registry.);
589 closecxx . . $ close(7864480464b09eea).(display->epoll_fdcxx . . $ uwac_display#epoll_fd.);
590 wl_display_disconnectcxx . . $ wl_display_disconnect(dfc29eeec957a140).(display->displaycxx . . $ uwac_display#display.);
591
592 /* cleanup the event queue */
593 while (display->push_queuecxx . . $ uwac_display#push_queue.)
594 {
595 UwacEventListItemcxx . . $ UwacEventListItem#* item = display->push_queuecxx . . $ uwac_display#push_queue.;
596 display->push_queuecxx . . $ uwac_display#push_queue. = item->tailcxx . . $ uwac_event_list_item#tail.;
597 freecxx . . $ free(5d22bdacc48458e8).(item);
598 }
599
600 freecxx . . $ free(5d22bdacc48458e8).(display);
601 *pdisplay = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
602 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
603 }
604
605 int UwacDisplayGetFdcxx . . $ UwacDisplayGetFd(be83306c83479a15).(UwacDisplaycxx . . $ UwacDisplay#* display)
606 {
607 return display->epoll_fdcxx . . $ uwac_display#epoll_fd.;
608 }
609
610 static const char* errorStringscxx . . $ errorStrings.[] = {
611 "success",
612 "out of memory error",
613 "unable to connect to wayland display",
614 "invalid UWAC display",
615 "not enough resources",
616 "timed out",
617 "not found",
618 "closed connection",
619
620 "internal error",
621 };
622
623 const char* UwacErrorStringcxx . . $ UwacErrorString(d47aa90c2c6f1ead).(UwacReturnCodecxx . . $ UwacReturnCode# error)
624 {
625 if (error < UWAC_SUCCESScxx . . $ UWAC_SUCCESS. || error >= UWAC_ERROR_LASTcxx . . $ UWAC_ERROR_LAST.)
626 return "invalid error code";
627
628 return errorStringscxx . . $ errorStrings.[error];
629 }
630
631 UwacReturnCodecxx . . $ UwacReturnCode# UwacDisplayQueryInterfaceVersioncxx . . $ UwacDisplayQueryInterfaceVersion(665c6a83e154848f).(const UwacDisplaycxx . . $ UwacDisplay#* display, const char* name,
632 uint32_tcxx . . $ uint32_t#* version)
633 {
634 const UwacGlobalcxx . . $ UwacGlobal#* global = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
635 const UwacGlobalcxx . . $ UwacGlobal#* tmp = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
636
637 if (!display)
638 return UWAC_ERROR_INVALID_DISPLAYcxx . . $ UWAC_ERROR_INVALID_DISPLAY.;
639
640 wl_list_for_each_safecxx . . $ `<external>/3134019334663324116/wayland-util.h:478:9`!(global, tmp, &display->globals, link)
641 {
642 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(global->interfacecxx . . $ uwac_global#interface., name) == 0)
643 {
644 if (version)
645 *version = global->versioncxx . . $ uwac_global#version.;
646
647 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
648 }
649 }
650 return UWAC_NOT_FOUNDcxx . . $ UWAC_NOT_FOUND.;
651 }
652
653 uint32_tcxx . . $ uint32_t# UwacDisplayQueryGetNbShmFormatscxx . . $ UwacDisplayQueryGetNbShmFormats(d326cfce5682ad12).(UwacDisplaycxx . . $ UwacDisplay#* display)
654 {
655 if (!display)
656 {
657 return 0;
658 }
659
660 if (!display->shmcxx . . $ uwac_display#shm.)
661 {
662 display->last_errorcxx . . $ uwac_display#last_error. = UWAC_NOT_FOUNDcxx . . $ UWAC_NOT_FOUND.;
663 return 0;
664 }
665
666 display->last_errorcxx . . $ uwac_display#last_error. = UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
667 return display->shm_formats_nbcxx . . $ uwac_display#shm_formats_nb.;
668 }
669
670 UwacReturnCodecxx . . $ UwacReturnCode# UwacDisplayQueryShmFormatscxx . . $ UwacDisplayQueryShmFormats(9d71bf31a3ee4a84).(const UwacDisplaycxx . . $ UwacDisplay#* display, enum wl_shm_formatcxx . . $ wl_shm_format#* formats,
671 int formats_size, int* filled)
672 {
673 if (!display)
674 return UWAC_ERROR_INVALID_DISPLAYcxx . . $ UWAC_ERROR_INVALID_DISPLAY.;
675
676 *filled = mincxx . . $ `uwac/libuwac/uwac-utils.h:31:9`!((int64_t)display->shm_formats_nb, formats_size);
677 memcpycxx . . $ memcpy(cc817cb175f282d).(formats, (const void*)display->shm_formatscxx . . $ uwac_display#shm_formats., *filled * sizeof(enum wl_shm_formatcxx . . $ wl_shm_format#));
678 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
679 }
680
681 uint32_tcxx . . $ uint32_t# UwacDisplayGetNbOutputscxx . . $ UwacDisplayGetNbOutputs(1df39cccd3470045).(const UwacDisplaycxx . . $ UwacDisplay#* display)
682 {
683 return wl_list_lengthcxx . . $ wl_list_length(ae2146931880bdc7).(&display->outputscxx . . $ uwac_display#outputs.);
684 }
685
686 const UwacOutputcxx . . $ UwacOutput#* UwacDisplayGetOutputcxx . . $ UwacDisplayGetOutput(f940d398dbf01339).(UwacDisplaycxx . . $ UwacDisplay#* display, int index)
687 {
688 int i = 0;
689 int display_count = 0;
690 UwacOutputcxx . . $ UwacOutput#* ret = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
691
692 if (!display)
693 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
694
695 display_count = wl_list_lengthcxx . . $ wl_list_length(ae2146931880bdc7).(&display->outputscxx . . $ uwac_display#outputs.);
696 if (display_count <= index)
697 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
698
699 wl_list_for_eachcxx . . $ `<external>/3134019334663324116/wayland-util.h:458:9`!(ret, &display->outputs, link)
700 {
701 if (i == index)
702 break;
703 i++;
704 }
705
706 if (!ret)
707 {
708 display->last_errorcxx . . $ uwac_display#last_error. = UWAC_NOT_FOUNDcxx . . $ UWAC_NOT_FOUND.;
709 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
710 }
711
712 display->last_errorcxx . . $ uwac_display#last_error. = UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
713 return ret;
714 }
715
716 UwacReturnCodecxx . . $ UwacReturnCode# UwacOutputGetResolutioncxx . . $ UwacOutputGetResolution(e78d90e73efcc3bb).(const UwacOutputcxx . . $ UwacOutput#* output, UwacSizecxx . . $ UwacSize#* resolution)
717 {
718 if ((output->resolutioncxx . . $ uwac_output#resolution..heightcxx . . $ uwac_size#height. <= 0) || (output->resolutioncxx . . $ uwac_output#resolution..widthcxx . . $ uwac_size#width. <= 0))
719 return UWAC_ERROR_INTERNALcxx . . $ UWAC_ERROR_INTERNAL.;
720
721 *resolution = output->resolutioncxx . . $ uwac_output#resolution.;
722 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
723 }
724
725 UwacReturnCodecxx . . $ UwacReturnCode# UwacOutputGetPositioncxx . . $ UwacOutputGetPosition(1b9dc8a41b6c9371).(const UwacOutputcxx . . $ UwacOutput#* output, UwacPositioncxx . . $ UwacPosition#* pos)
726 {
727 *pos = output->positioncxx . . $ uwac_output#position.;
728 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
729 }
730
731 UwacEventcxx . . $ UwacEvent#* UwacDisplayNewEventcxx . . $ UwacDisplayNewEvent(f698cd9f7a1e75c).(UwacDisplaycxx . . $ UwacDisplay#* display, int type)
732 {
733 UwacEventListItemcxx . . $ UwacEventListItem#* ret = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
734
735 if (!display)
736 {
737 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
738 }
739
740 ret = xzalloccxx . . $ xzalloc(bfcfa4d6b7f7ef64).(sizeof(UwacEventListItemcxx . . $ UwacEventListItem#));
741
742 if (!ret)
743 {
744 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(uwacErrorHandler(display, UWAC_ERROR_NOMEMORY, "unable to allocate a '%s' event",
745 event_names[type]));
746 display->last_errorcxx . . $ uwac_display#last_error. = UWAC_ERROR_NOMEMORYcxx . . $ UWAC_ERROR_NOMEMORY.;
747 return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
748 }
749
750 ret->eventcxx . . $ uwac_event_list_item#event..typecxx . . $ uwac_event#type. = type;
751 ret->tailcxx . . $ uwac_event_list_item#tail. = display->push_queuecxx . . $ uwac_display#push_queue.;
752
753 if (ret->tailcxx . . $ uwac_event_list_item#tail.)
754 ret->tailcxx . . $ uwac_event_list_item#tail.->headcxx . . $ uwac_event_list_item#head. = ret;
755 else
756 display->pop_queuecxx . . $ uwac_display#pop_queue. = ret;
757
758 display->push_queuecxx . . $ uwac_display#push_queue. = ret;
759 return &ret->eventcxx . . $ uwac_event_list_item#event.;
760 }
761
762 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! UwacHasEventcxx . . $ UwacHasEvent(eafb252842f06162).(UwacDisplaycxx . . $ UwacDisplay#* display)
763 {
764 return display->pop_queuecxx . . $ uwac_display#pop_queue. != nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
765 }
766
767 UwacReturnCodecxx . . $ UwacReturnCode# UwacNextEventcxx . . $ UwacNextEvent(85f8d44e40787a3).(UwacDisplaycxx . . $ UwacDisplay#* display, UwacEventcxx . . $ UwacEvent#* event)
768 {
769 UwacEventListItemcxx . . $ UwacEventListItem#* prevItem = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
770 int ret = 0;
771
772 if (!display)
773 return UWAC_ERROR_INVALID_DISPLAYcxx . . $ UWAC_ERROR_INVALID_DISPLAY.;
774
775 while (!display->pop_queuecxx . . $ uwac_display#pop_queue.)
776 {
777 ret = UwacDisplayDispatchcxx . . $ UwacDisplayDispatch(447a1ee01e23a2a1).(display, 1 * 1000);
778
779 if (ret < 0)
780 return UWAC_ERROR_INTERNALcxx . . $ UWAC_ERROR_INTERNAL.;
781 else if (ret == 0)
782 return UWAC_ERROR_CLOSEDcxx . . $ UWAC_ERROR_CLOSED.;
783 }
784
785 prevItem = display->pop_queuecxx . . $ uwac_display#pop_queue.->headcxx . . $ uwac_event_list_item#head.;
786 *event = display->pop_queuecxx . . $ uwac_display#pop_queue.->eventcxx . . $ uwac_event_list_item#event.;
787 freecxx . . $ free(5d22bdacc48458e8).(display->pop_queuecxx . . $ uwac_display#pop_queue.);
788 display->pop_queuecxx . . $ uwac_display#pop_queue. = prevItem;
789
790 if (prevItem)
791 prevItem->tailcxx . . $ uwac_event_list_item#tail. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
792 else
793 display->push_queuecxx . . $ uwac_display#push_queue. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!;
794
795 return UWAC_SUCCESScxx . . $ UWAC_SUCCESS.;
796 }