about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedwaylandclient.c
blob: 4fe3b8f61d230672ac3d23ec16ed014fd4875f22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <dlfcn.h>

#include "wrappedlibs.h"

#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "box64context.h"
#include "librarian.h"
#include "myalign.h"


const char* waylandclientName = "libwayland-client.so.0";
#define LIBNAME waylandclient

#define ADDED_FUNCTIONS() \

#include "generated/wrappedwaylandclienttypes.h"

#include "wrappercallback.h"

#define SUPER() \
GO(0)   \
GO(1)   \
GO(2)   \
GO(3)   \
GO(4)

// wl_registry_listener ...
typedef struct my_wl_registry_listener_s {
    uintptr_t   global; //vFppupu
    uintptr_t   global_remove;  //vFppu
} my_wl_registry_listener_t;
#define GO(A)   \
static my_wl_registry_listener_t* ref_wl_registry_listener_##A = NULL;                              \
static void my_wl_registry_listener_global_##A(void* a, void* b, uint32_t c, void* d, uint32_t e)   \
{                                                                                                   \
    RunFunctionFmt(ref_wl_registry_listener_##A->global, "ppupu", a, b, c, d, e);                   \
}                                                                                                   \
static void my_wl_registry_listener_global_remove_##A(void* a, void* b, uint32_t c)                 \
{                                                                                                   \
    RunFunctionFmt(ref_wl_registry_listener_##A->global_remove, "ppu", a, b, c);                    \
}                                                                                                   \
static my_wl_registry_listener_t my_wl_registry_listener_fct_##A = {                                \
    (uintptr_t)my_wl_registry_listener_global_##A,                                                  \
    (uintptr_t)my_wl_registry_listener_global_remove_##A                                            \
};
SUPER()
#undef GO
static void* find_wl_registry_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_registry_listener_##A == fct) return &my_wl_registry_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_registry_listener_##A == 0) {ref_wl_registry_listener_##A = fct; return &my_wl_registry_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_registry_listener callback\n");
    return NULL;
}
// xdg_surface_listener ...
typedef struct my_xdg_surface_listener_s {
    uintptr_t   configure; //vFppiipu
    uintptr_t   close;  //vFpp
} my_xdg_surface_listener_t;
#define GO(A)   \
static my_xdg_surface_listener_t* ref_xdg_surface_listener_##A = NULL;                                  \
static void my_xdg_surface_listener_configure_##A(void* a, void* b, int c, int d, void* e, uint32_t f)  \
{                                                                                                       \
    RunFunctionFmt(ref_xdg_surface_listener_##A->configure, "ppiipu", a, b, c, d, e, f);                \
}                                                                                                       \
static void my_xdg_surface_listener_close_##A(void* a, void* b)                                         \
{                                                                                                       \
    RunFunctionFmt(ref_xdg_surface_listener_##A->close, "pp", a, b);                                    \
}                                                                                                       \
static my_xdg_surface_listener_t my_xdg_surface_listener_fct_##A = {                                    \
    (uintptr_t)my_xdg_surface_listener_configure_##A,                                                   \
    (uintptr_t)my_xdg_surface_listener_close_##A                                                        \
};
SUPER()
#undef GO
static void* find_xdg_surface_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_xdg_surface_listener_##A == fct) return &my_xdg_surface_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_xdg_surface_listener_##A == 0) {ref_xdg_surface_listener_##A = fct; return &my_xdg_surface_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client xdg_surface_listener callback\n");
    return NULL;
}
// xdg_toplevel_listener ...
typedef struct my_xdg_toplevel_listener_s {
    uintptr_t   configure; //vFppiip
    uintptr_t   close;  //vFpp
} my_xdg_toplevel_listener_t;
#define GO(A)   \
static my_xdg_toplevel_listener_t* ref_xdg_toplevel_listener_##A = NULL;                            \
static void my_xdg_toplevel_listener_configure_##A(void* a, void* b, int c, int d, void* e)         \
{                                                                                                   \
    RunFunctionFmt(ref_xdg_toplevel_listener_##A->configure, "ppiip", a, b, c, d, e);               \
}                                                                                                   \
static void my_xdg_toplevel_listener_close_##A(void* a, void* b)                                    \
{                                                                                                   \
    RunFunctionFmt(ref_xdg_toplevel_listener_##A->close, "pp", a, b);                               \
}                                                                                                   \
static my_xdg_toplevel_listener_t my_xdg_toplevel_listener_fct_##A = {                              \
    (uintptr_t)my_xdg_toplevel_listener_configure_##A,                                              \
    (uintptr_t)my_xdg_toplevel_listener_close_##A                                                   \
};
SUPER()
#undef GO
static void* find_xdg_toplevel_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_xdg_toplevel_listener_##A == fct) return &my_xdg_toplevel_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_xdg_toplevel_listener_##A == 0) {ref_xdg_toplevel_listener_##A = fct; return &my_xdg_toplevel_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client xdg_toplevel_listener callback\n");
    return NULL;
}
// xdg_wm_base_listener ...
typedef struct my_xdg_wm_base_listener_s {
    uintptr_t   ping; //vFppu
} my_xdg_wm_base_listener_t;
#define GO(A)   \
static my_xdg_wm_base_listener_t* ref_xdg_wm_base_listener_##A = NULL;                \
static void my_xdg_wm_base_listener_ping_##A(void* a, void* b, uint32_t c)            \
{                                                                                     \
    RunFunctionFmt(ref_xdg_wm_base_listener_##A->ping, "ppu", a, b, c);               \
}                                                                                     \
static my_xdg_wm_base_listener_t my_xdg_wm_base_listener_fct_##A = {                  \
    (uintptr_t)my_xdg_wm_base_listener_ping_##A,                                      \
};
SUPER()
#undef GO
static void* find_xdg_wm_base_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_xdg_wm_base_listener_##A == fct) return &my_xdg_wm_base_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_xdg_wm_base_listener_##A == 0) {ref_xdg_wm_base_listener_##A = fct; return &my_xdg_wm_base_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client xdg_wm_base_listener callback\n");
    return NULL;
}
// wl_shm_listener ...
typedef struct my_wl_shm_listener_s {
    uintptr_t   format; //vFppu
} my_wl_shm_listener_t;
#define GO(A)   \
static my_wl_shm_listener_t* ref_wl_shm_listener_##A = NULL;                       \
static void my_wl_shm_listener_format_##A(void* a, void* b, uint32_t c)            \
{                                                                                  \
    RunFunctionFmt(ref_wl_shm_listener_##A->format, "ppu", a, b, c);               \
}                                                                                  \
static my_wl_shm_listener_t my_wl_shm_listener_fct_##A = {                         \
    (uintptr_t)my_wl_shm_listener_format_##A,                                      \
};
SUPER()
#undef GO
static void* find_wl_shm_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_shm_listener_##A == fct) return &my_wl_shm_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_shm_listener_##A == 0) {ref_wl_shm_listener_##A = fct; return &my_wl_shm_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_shm_listener callback\n");
    return NULL;
}
// wl_output_listener ...
typedef struct my_wl_output_listener_s {
    uintptr_t   geometry; //vFppiiiiippi
    uintptr_t   mode;  //vFppuiii
    uintptr_t   done;  //vFpp
    uintptr_t   scale;  //vFppi
    uintptr_t   name;   //vFppp
    uintptr_t   description;   //vFppp
} my_wl_output_listener_t;
#define GO(A)   \
static my_wl_output_listener_t* ref_wl_output_listener_##A = NULL;                                                            \
static void my_wl_output_listener_geometry_##A(void* a, void* b, int c, int d, int e, int f, int g, void* h, void* i, int j)  \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->geometry, "ppiiiiippi", a, b, c, d, e, f, g, h, i, j);                         \
}                                                                                                                             \
static void my_wl_output_listener_mode_##A(void* a, void* b, uint32_t c, int d, int e, int f)                                 \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->mode, "ppuiii", a, b, c, d, e, f);                                             \
}                                                                                                                             \
static void my_wl_output_listener_done_##A(void* a, void* b)                                                                  \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->done, "pp", a, b);                                                             \
}                                                                                                                             \
static void my_wl_output_listener_scale_##A(void* a, void* b, int c)                                                          \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->scale, "ppi", a, b, c);                                                        \
}                                                                                                                             \
static void my_wl_output_listener_name_##A(void* a, void* b, void* c)                                                         \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->name, "ppp", a, b, c);                                                         \
}                                                                                                                             \
static void my_wl_output_listener_description_##A(void* a, void* b, void* c)                                                  \
{                                                                                                                             \
    RunFunctionFmt(ref_wl_output_listener_##A->description, "ppp", a, b, c);                                                  \
}                                                                                                                             \
static my_wl_output_listener_t my_wl_output_listener_fct_##A = {                                                              \
    (uintptr_t)my_wl_output_listener_geometry_##A,                                                                            \
    (uintptr_t)my_wl_output_listener_mode_##A,                                                                                \
    (uintptr_t)my_wl_output_listener_done_##A,                                                                                \
    (uintptr_t)my_wl_output_listener_scale_##A,                                                                               \
    (uintptr_t)my_wl_output_listener_name_##A,                                                                                \
    (uintptr_t)my_wl_output_listener_description_##A                                                                          \
};
SUPER()
#undef GO
static void* find_wl_output_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_output_listener_##A == fct) return &my_wl_output_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_output_listener_##A == 0) {ref_wl_output_listener_##A = fct; return &my_wl_output_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_output_listener callback\n");
    return NULL;
}
// wl_seat_listener ...
typedef struct my_wl_seat_listener_s {
    uintptr_t   capabilities; //vFppu
    uintptr_t   name;  //vFppp
} my_wl_seat_listener_t;
#define GO(A)   \
static my_wl_seat_listener_t* ref_wl_seat_listener_##A = NULL;                            \
static void my_wl_seat_listener_capabilities_##A(void* a, void* b, uint32_t c)            \
{                                                                                         \
    RunFunctionFmt(ref_wl_seat_listener_##A->capabilities, "ppu", a, b, c);               \
}                                                                                         \
static void my_wl_seat_listener_name_##A(void* a, void* b, void* c)                       \
{                                                                                         \
    RunFunctionFmt(ref_wl_seat_listener_##A->name, "ppp", a, b, c);                       \
}                                                                                         \
static my_wl_seat_listener_t my_wl_seat_listener_fct_##A = {                              \
    (uintptr_t)my_wl_seat_listener_capabilities_##A,                                      \
    (uintptr_t)my_wl_seat_listener_name_##A                                               \
};
SUPER()
#undef GO
static void* find_wl_seat_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_seat_listener_##A == fct) return &my_wl_seat_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_seat_listener_##A == 0) {ref_wl_seat_listener_##A = fct; return &my_wl_seat_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_seat_listener callback\n");
    return NULL;
}
// wl_pointer_listener ...
typedef struct my_wl_pointer_listener_s {
    uintptr_t   enter; //vFppupii
    uintptr_t   leave;  //vFppup
    uintptr_t   motion;  //vFppuii
    uintptr_t   button;  //vFppuuuu
    uintptr_t   axis;   //vFppuui
    uintptr_t   frame;   //vFpp
    uintptr_t   axis_source;   //vFppu
    uintptr_t   axis_stop;   //vFppuu
    uintptr_t   axis_discrete;   //vFppui
    uintptr_t   axis_value120;   //vFppui
    uintptr_t   axis_relative_direction;   //vFppuu
} my_wl_pointer_listener_t;
#define GO(A)   \
static my_wl_pointer_listener_t* ref_wl_pointer_listener_##A = NULL;                                             \
static void my_wl_pointer_listener_enter_##A(void* a, void* b, uint32_t c, void* d, int e, int f)                \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->enter, "ppupii", a, b, c, d, e, f);                              \
}                                                                                                                \
static void my_wl_pointer_listener_leave_##A(void* a, void* b, uint32_t c, void* d)                              \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->leave, "ppup", a, b, c, d);                                      \
}                                                                                                                \
static void my_wl_pointer_listener_motion_##A(void* a, void* b, uint32_t c, int d, int e)                        \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->motion, "ppuii", a, b, c, d, e);                                 \
}                                                                                                                \
static void my_wl_pointer_listener_button_##A(void* a, void* b, uint32_t c, uint32_t d, uint32_t e, uint32_t f)  \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->button, "ppuuuu", a, b, c, d, e, f);                             \
}                                                                                                                \
static void my_wl_pointer_listener_axis_##A(void* a, void* b, uint32_t c, uint32_t d, int e)                     \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis, "ppuui", a, b, c, d, e);                                   \
}                                                                                                                \
static void my_wl_pointer_listener_frame_##A(void* a, void* b)                                                   \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->frame, "pp", a, b);                                              \
}                                                                                                                \
static void my_wl_pointer_listener_axis_source_##A(void* a, void* b, uint32_t c)                                 \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis_source, "ppu", a, b, c);                                    \
}                                                                                                                \
static void my_wl_pointer_listener_axis_stop_##A(void* a, void* b, uint32_t c, uint32_t d)                       \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis_stop, "ppuu", a, b, c, d);                                  \
}                                                                                                                \
static void my_wl_pointer_listener_axis_discrete_##A(void* a, void* b, uint32_t c, int d)                        \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis_discrete, "ppui", a, b, c, d);                              \
}                                                                                                                \
static void my_wl_pointer_listener_axis_value120_##A(void* a, void* b, uint32_t c, int d)                        \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis_value120, "ppui", a, b, c, d);                              \
}                                                                                                                \
static void my_wl_pointer_listener_axis_relative_direction_##A(void* a, void* b, uint32_t c, uint32_t d)         \
{                                                                                                                \
    RunFunctionFmt(ref_wl_pointer_listener_##A->axis_relative_direction, "ppuu", a, b, c, d);                    \
}                                                                                                                \
static my_wl_pointer_listener_t my_wl_pointer_listener_fct_##A = {                                               \
    (uintptr_t)my_wl_pointer_listener_enter_##A,                                                                 \
    (uintptr_t)my_wl_pointer_listener_leave_##A,                                                                 \
    (uintptr_t)my_wl_pointer_listener_motion_##A,                                                                \
    (uintptr_t)my_wl_pointer_listener_button_##A,                                                                \
    (uintptr_t)my_wl_pointer_listener_axis_##A,                                                                  \
    (uintptr_t)my_wl_pointer_listener_frame_##A,                                                                 \
    (uintptr_t)my_wl_pointer_listener_axis_source_##A,                                                           \
    (uintptr_t)my_wl_pointer_listener_axis_stop_##A,                                                             \
    (uintptr_t)my_wl_pointer_listener_axis_discrete_##A,                                                         \
    (uintptr_t)my_wl_pointer_listener_axis_value120_##A,                                                         \
    (uintptr_t)my_wl_pointer_listener_axis_relative_direction_##A                                                \
};
SUPER()
#undef GO
static void* find_wl_pointer_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_pointer_listener_##A == fct) return &my_wl_pointer_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_pointer_listener_##A == 0) {ref_wl_pointer_listener_##A = fct; return &my_wl_pointer_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_pointer_listener callback\n");
    return NULL;
}
// wl_keyboard_listener ...
typedef struct my_wl_keyboard_listener_s {
    uintptr_t   keymap; //vFppuiu
    uintptr_t   enter;  //vFppup
    uintptr_t   leave;  //vFppup
    uintptr_t   key;  //vFppuuuuu
    uintptr_t   modifiers;   //vFppuuuuu
    uintptr_t   repeat_info;   //vFppii
} my_wl_keyboard_listener_t;
#define GO(A)   \
static my_wl_keyboard_listener_t* ref_wl_keyboard_listener_##A = NULL;                                                           \
static void my_wl_keyboard_listener_keymap_##A(void* a, void* b, uint32_t c, int d, uint32_t e)                                  \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->keymap, "ppuiu", a, b, c, d, e);                                                \
}                                                                                                                                \
static void my_wl_keyboard_listener_enter_##A(void* a, void* b, uint32_t c, void* d)                                             \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->enter, "ppup", a, b, c, d);                                                     \
}                                                                                                                                \
static void my_wl_keyboard_listener_leave_##A(void* a, void* b, uint32_t c, void* d)                                             \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->leave, "ppup", a, b, c, d);                                                     \
}                                                                                                                                \
static void my_wl_keyboard_listener_key_##A(void* a, void* b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g)        \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->key, "ppuuuuu", a, b, c, d, e, f, g);                                           \
}                                                                                                                                \
static void my_wl_keyboard_listener_modifiers_##A(void* a, void* b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g)  \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->modifiers, "ppuuuuu", a, b, c, d, e, f, g);                                     \
}                                                                                                                                \
static void my_wl_keyboard_listener_repeat_info_##A(void* a, void* b, int c, int d)                                              \
{                                                                                                                                \
    RunFunctionFmt(ref_wl_keyboard_listener_##A->repeat_info, "ppii", a, b, c, d);                                               \
}                                                                                                                                \
static my_wl_keyboard_listener_t my_wl_keyboard_listener_fct_##A = {                                                             \
    (uintptr_t)my_wl_keyboard_listener_keymap_##A,                                                                               \
    (uintptr_t)my_wl_keyboard_listener_enter_##A,                                                                                \
    (uintptr_t)my_wl_keyboard_listener_leave_##A,                                                                                \
    (uintptr_t)my_wl_keyboard_listener_key_##A,                                                                                  \
    (uintptr_t)my_wl_keyboard_listener_modifiers_##A,                                                                            \
    (uintptr_t)my_wl_keyboard_listener_repeat_info_##A                                                                           \
};
SUPER()
#undef GO
static void* find_wl_keyboard_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_keyboard_listener_##A == fct) return &my_wl_keyboard_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_keyboard_listener_##A == 0) {ref_wl_keyboard_listener_##A = fct; return &my_wl_keyboard_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_keyboard_listener callback\n");
    return NULL;
}
// wl_buffer_listener ...
typedef struct my_wl_buffer_listener_s {
    uintptr_t   release; //vFpp
} my_wl_buffer_listener_t;
#define GO(A)   \
static my_wl_buffer_listener_t* ref_wl_buffer_listener_##A = NULL;                 \
static void my_wl_buffer_listener_release_##A(void* a, void* b)                    \
{                                                                                  \
    RunFunctionFmt(ref_wl_buffer_listener_##A->release, "pp", a, b);               \
}                                                                                  \
static my_wl_buffer_listener_t my_wl_buffer_listener_fct_##A = {                   \
    (uintptr_t)my_wl_buffer_listener_release_##A,                                  \
};
SUPER()
#undef GO
static void* find_wl_buffer_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_wl_buffer_listener_##A == fct) return &my_wl_buffer_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_wl_buffer_listener_##A == 0) {ref_wl_buffer_listener_##A = fct; return &my_wl_buffer_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client wl_buffer_listener callback\n");
    return NULL;
}
// zwp_relative_pointer_v1_listener ...
typedef struct my_zwp_relative_pointer_v1_listener_s {
    uintptr_t   relative_motion; //vFppuuiiii
} my_zwp_relative_pointer_v1_listener_t;
#define GO(A)   \
static my_zwp_relative_pointer_v1_listener_t* ref_zwp_relative_pointer_v1_listener_##A = NULL;                                              \
static void my_zwp_relative_pointer_v1_listener_relative_motion_##A(void* a, void* b, uint32_t c, uint32_t d, int e, int f, int g, int h)   \
{                                                                                                                                           \
    RunFunctionFmt(ref_zwp_relative_pointer_v1_listener_##A->relative_motion, "ppuuiiii", a, b, c, d, e, f, g, h);                          \
}                                                                                                                                           \
static my_zwp_relative_pointer_v1_listener_t my_zwp_relative_pointer_v1_listener_fct_##A = {                                                \
    (uintptr_t)my_zwp_relative_pointer_v1_listener_relative_motion_##A,                                                                     \
};
SUPER()
#undef GO
static void* find_zwp_relative_pointer_v1_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_zwp_relative_pointer_v1_listener_##A == fct) return &my_zwp_relative_pointer_v1_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_zwp_relative_pointer_v1_listener_##A == 0) {ref_zwp_relative_pointer_v1_listener_##A = fct; return &my_zwp_relative_pointer_v1_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client zwp_relative_pointer_v1_listener callback\n");
    return NULL;
}
// zxdg_output_v1_listener ...
typedef struct my_zxdg_output_v1_listener_s {
    uintptr_t   logical_position; //vFppii
    uintptr_t   logical_size; //vFppii
    uintptr_t   done; //vFpp
    uintptr_t   name; //vFppp
    uintptr_t   description; //vFppp
} my_zxdg_output_v1_listener_t;
#define GO(A)   \
static my_zxdg_output_v1_listener_t* ref_zxdg_output_v1_listener_##A = NULL;                             \
static void my_zxdg_output_v1_listener_logical_position_##A(void* a, void* b, int32_t c, int32_t d)      \
{                                                                                                        \
    RunFunctionFmt(ref_zxdg_output_v1_listener_##A->logical_position, "ppii", a, b, c, d);               \
}                                                                                                        \
static void my_zxdg_output_v1_listener_logical_size_##A(void* a, void* b, int32_t c, int32_t d)          \
{                                                                                                        \
    RunFunctionFmt(ref_zxdg_output_v1_listener_##A->logical_size, "ppii", a, b, c, d);                   \
}                                                                                                        \
static void my_zxdg_output_v1_listener_done_##A(void* a, void* b)                                        \
{                                                                                                        \
    RunFunctionFmt(ref_zxdg_output_v1_listener_##A->done, "pp", a, b);                                   \
}                                                                                                        \
static void my_zxdg_output_v1_listener_name_##A(void* a, void* b, void* c)                               \
{                                                                                                        \
    RunFunctionFmt(ref_zxdg_output_v1_listener_##A->name, "ppp", a, b, c);                               \
}                                                                                                        \
static void my_zxdg_output_v1_listener_description_##A(void* a, void* b, void* c)                        \
{                                                                                                        \
    RunFunctionFmt(ref_zxdg_output_v1_listener_##A->description, "ppp", a, b, c);                        \
}                                                                                                        \
static my_zxdg_output_v1_listener_t my_zxdg_output_v1_listener_fct_##A = {                               \
    (uintptr_t)my_zxdg_output_v1_listener_logical_position_##A,                                          \
    (uintptr_t)my_zxdg_output_v1_listener_logical_size_##A,                                              \
    (uintptr_t)my_zxdg_output_v1_listener_done_##A,                                                      \
    (uintptr_t)my_zxdg_output_v1_listener_name_##A,                                                      \
    (uintptr_t)my_zxdg_output_v1_listener_description_##A,                                               \
};
SUPER()
#undef GO
static void* find_zxdg_output_v1_listener_Fct(void* fct)
{
    if(!fct) return fct;
    #define GO(A) if(ref_zxdg_output_v1_listener_##A == fct) return &my_zxdg_output_v1_listener_fct_##A;
    SUPER()
    #undef GO
    #define GO(A) if(ref_zxdg_output_v1_listener_##A == 0) {ref_zxdg_output_v1_listener_##A = fct; return &my_zxdg_output_v1_listener_fct_##A; }
    SUPER()
    #undef GO
    printf_log(LOG_NONE, "Warning, no more slot for wayland-client zxdg_output_v1_listener callback\n");
    return NULL;
}

#undef SUPER

EXPORT int my_wl_proxy_add_listener(x64emu_t* emu, void* proxy, void** l, void* data)
{
    const char* proxy_name = **(const char***)proxy;
    if(!strcmp(proxy_name, "wl_registry")) {
        l = find_wl_registry_listener_Fct(l);
    } else if(!strcmp(proxy_name, "xdg_surface")) {
        l = find_xdg_surface_listener_Fct(l);
    } else if(!strcmp(proxy_name, "xdg_toplevel")) {
        l = find_xdg_toplevel_listener_Fct(l);
    } else if(!strcmp(proxy_name, "xdg_wm_base")) {
        l = find_xdg_wm_base_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_shm")) {
        l = find_wl_shm_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_output")) {
        l = find_wl_output_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_seat")) {
        l = find_wl_seat_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_pointer")) {
        l = find_wl_pointer_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_keyboard")) {
        l = find_wl_keyboard_listener_Fct(l);
    } else if(!strcmp(proxy_name, "wl_buffer")) {
        l = find_wl_buffer_listener_Fct(l);
    } else if(!strcmp(proxy_name, "zwp_relative_pointer_v1")) {
        l = find_zwp_relative_pointer_v1_listener_Fct(l);
    } else if(!strcmp(proxy_name, "zxdg_output_v1")) {
        l = find_zxdg_output_v1_listener_Fct(l);
    } else
        printf_log(LOG_INFO, "BOX64: Error, Wayland-client, add_listener to %s unknown, will crash soon!\n", proxy_name);
    return my->wl_proxy_add_listener(proxy, l, data);
}

#include "wrappedlib_init.h"