-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
772 lines (623 loc) · 22 KB
/
main.c
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <locale.h>
#include <poll.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/signalfd.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <pixman.h>
#include <tllist.h>
#include <wlr-layer-shell-unstable-v1.h>
#define LOG_MODULE "mhalo"
#define LOG_ENABLE_DBG 0
#include "log.h"
#include "shm.h"
#include "version.h"
static int cursor_x = 100;
static int cursor_y = 100;
#define RADIUS 60
/* Top-level globals */
static struct wl_display *display;
static struct wl_registry *registry;
static struct wl_compositor *compositor;
static struct wl_shm *shm;
static struct zwlr_layer_shell_v1 *layer_shell;
static struct wl_seat *seat;
static struct output *current_output = NULL;
static bool should_exit = false;
static bool have_argb8888 = false;
static pixman_image_t *fill = NULL;
struct output {
struct wl_output *wl_output;
uint32_t wl_name;
char *make;
char *model;
int scale;
int width;
int height;
int render_width;
int render_height;
struct wl_surface *surf;
struct zwlr_layer_surface_v1 *layer;
bool configured;
int last_x;
int last_y;
// Add a frame_done flag for each output
bool frame_done;
bool wants_render;
bool rendered_without_cursor;
};
static tll(struct output) outputs;
static bool stretch = false;
static void render(struct output *output);
static void frame_done_callback(void *data, struct wl_callback *callback,
uint32_t time) {
struct output *output = data;
output->frame_done = true; // Mark frame as done for this specific output
wl_callback_destroy(callback);
if (output->wants_render) {
output->wants_render = false;
render(output);
}
}
static const struct wl_callback_listener frame_listener = {
.done = frame_done_callback,
};
static void draw_circle(pixman_image_t *pix, int x, int y, int radius) {
int width = pixman_image_get_width(pix);
int height = pixman_image_get_height(pix);
pixman_color_t white = {0xFFFF, 0xFFFF, 0xFFFF, 0x3FFF};
for (int j = y - radius; j <= y + radius; j++) {
int start = -1, end = -1;
for (int i = x - radius; i <= x + radius; i++) {
if (i >= 0 && i < width && j >= 0 && j < height) {
int dx = i - x;
int dy = j - y;
if (dx * dx + dy * dy <= radius * radius) {
if (start < 0) start = i;
end = i;
}
}
}
if (end > 0) {
pixman_image_fill_rectangles(PIXMAN_OP_HSL_LUMINOSITY, pix, &white, 1,
&(pixman_rectangle16_t){start, j, end-start, 1});
}
}
}
#define double_to_color(x) \
(((uint32_t) ((x)*65536)) - (((uint32_t) ((x)*65536)) >> 16))
#define PIXMAN_STOP(offset,r,g,b,a) \
{ pixman_double_to_fixed (offset), \
{ \
double_to_color (r), \
double_to_color (g), \
double_to_color (b), \
double_to_color (a) \
} \
}
void draw_circle_with_gradient(pixman_image_t* image, int cx, int cy, int radius) {
// Define the points for the radial gradient
pixman_point_fixed_t inner_circle = { pixman_int_to_fixed(radius), pixman_int_to_fixed(radius) };
pixman_point_fixed_t outer_circle = { pixman_int_to_fixed(radius), pixman_int_to_fixed(radius) };
pixman_fixed_t inner_radius = pixman_int_to_fixed(0);
pixman_fixed_t outer_radius = pixman_int_to_fixed(radius);
// Define the colors for the gradient: fully transparent at the center, fully opaque at the outer edge
pixman_gradient_stop_t stops[3] = {
PIXMAN_STOP (0.0, 1, 1, 1, 1),
PIXMAN_STOP (0.7, 1, 1, 1, 1),
PIXMAN_STOP (1.0, 0, 0, 0, 0),
};
pixman_gradient_stop_t stops2[4] = {
PIXMAN_STOP (0.0, 1, 1, 1, 0.15),
PIXMAN_STOP (0.7, 1, 1, 1, 0.1),
PIXMAN_STOP (0.8, 1, 1, 0.31, 0.3),
PIXMAN_STOP (1.0, 0, 0, 0, 0),
};
// Create the gradient
pixman_image_t *radial_gradient = pixman_image_create_radial_gradient(
&inner_circle, &outer_circle,
inner_radius, outer_radius,
stops, 3
);
// Create the gradient
pixman_image_t *radial_gradient2 = pixman_image_create_radial_gradient(
&inner_circle, &outer_circle,
inner_radius, outer_radius,
stops2, 4
);
// Set the gradient as the source and composite it onto the image
pixman_image_composite32(
PIXMAN_OP_OUT_REVERSE,
radial_gradient, // Source: the gradient
NULL, // Mask: no mask
image, // Destination: the image
0, 0, // Source origin
0, 0, // Mask origin
cx - radius, cy - radius, // Destination origin
2 * radius, 2 * radius // Destination size (width and height)
);
pixman_image_composite32(
PIXMAN_OP_OVER,
radial_gradient2, // Source: the gradient
NULL, // Mask: no mask
image, // Destination: the image
0, 0, // Source origin
0, 0, // Mask origin
cx - radius, cy - radius, // Destination origin
2 * radius, 2 * radius // Destination size (width and height)
);
// Cleanup
pixman_image_unref(radial_gradient);
pixman_image_unref(radial_gradient2);
}
static void render(struct output *output) {
if (!output->frame_done) {
output->wants_render = true;
return; // Skip rendering if the previous frame isn't done
}
//
// If the output is not the current output and has already been rendered
// without the cursor, skip rendering
if (output != current_output && output->rendered_without_cursor) {
return;
}
const int width = output->render_width;
const int height = output->render_height;
const int scale = output->scale;
struct buffer *buf =
shm_get_buffer(shm, width * scale, height * scale, (uintptr_t)output);
if (!buf)
return;
output->frame_done = false;
pixman_image_t *src = fill;
pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, buf->pix, 0, 0, 0, 0, 0, 0,
width * scale, height * scale);
wl_surface_set_buffer_scale(output->surf, scale);
wl_surface_attach(output->surf, buf->wl_buf, 0, 0);
// Draw the circle only on the current output
wl_surface_damage_buffer(output->surf, (output->last_x - RADIUS - 1) * scale,
(output->last_y - RADIUS - 1) * scale, (RADIUS +1) * 2 * scale,
(RADIUS +1) * 2 * scale);
if (output->last_x == 0 && output->last_y == 0) {
wl_surface_damage_buffer(output->surf, 0, 0, width * scale, height * scale);
}
if (output == current_output) {
output->last_x = cursor_x;
output->last_y = cursor_y;
if (false) draw_circle(buf->pix, cursor_x * scale, cursor_y * scale, RADIUS * scale);
//draw_circle(buf->pix, cursor_x * scale, cursor_y * scale, 40 * scale);
draw_circle_with_gradient(buf->pix, cursor_x * scale, cursor_y * scale, RADIUS * scale);
wl_surface_damage_buffer(output->surf, (cursor_x - RADIUS - 1) * scale,
(cursor_y - RADIUS - 1) * scale, (RADIUS + 1) * 2 * scale, (RADIUS + 1) * 2 * scale);
output->rendered_without_cursor =
false; // Reset the flag as we're rendering the cursor
} else {
output->rendered_without_cursor =
true; // Set the flag since the output is rendered without the cursor
}
// Create a callback to know when the frame is done
struct wl_callback *callback = wl_surface_frame(output->surf);
wl_callback_add_listener(callback, &frame_listener,
output); // Pass output as data
wl_surface_commit(output->surf);
}
static void layer_surface_configure(void *data,
struct zwlr_layer_surface_v1 *surface,
uint32_t serial, uint32_t w, uint32_t h) {
struct output *output = data;
zwlr_layer_surface_v1_ack_configure(surface, serial);
/* If the size of the last committed buffer has not change, do not
* render a new buffer because it will be identical to the old one. */
/* TODO: should we check the scale? */
if (output->configured && output->render_width == w &&
output->render_height == h) {
wl_surface_commit(output->surf);
return;
}
// TODO: (Re)-Create double buffers
output->render_width = w;
output->render_height = h;
output->configured = true;
render(output);
}
static void output_layer_destroy(struct output *output) {
if (output->layer != NULL)
zwlr_layer_surface_v1_destroy(output->layer);
if (output->surf != NULL)
wl_surface_destroy(output->surf);
output->layer = NULL;
output->surf = NULL;
output->configured = false;
}
static void layer_surface_closed(void *data,
struct zwlr_layer_surface_v1 *surface) {
struct output *output = data;
/* Don’t trust ‘output’ to be valid, in case compositor destroyed
* if before calling closed() */
tll_foreach(outputs, it) {
if (&it->item == output) {
output_layer_destroy(output);
break;
}
}
}
static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
.configure = &layer_surface_configure,
.closed = &layer_surface_closed,
};
static void output_destroy(struct output *output) {
output_layer_destroy(output);
if (output->wl_output != NULL)
wl_output_release(output->wl_output);
output->wl_output = NULL;
free(output->make);
free(output->model);
}
static void output_geometry(void *data, struct wl_output *wl_output, int32_t x,
int32_t y, int32_t physical_width,
int32_t physical_height, int32_t subpixel,
const char *make, const char *model,
int32_t transform) {
struct output *output = data;
free(output->make);
free(output->model);
output->make = make != NULL ? strdup(make) : NULL;
output->model = model != NULL ? strdup(model) : NULL;
}
static void output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
int32_t width, int32_t height, int32_t refresh) {
if ((flags & WL_OUTPUT_MODE_CURRENT) == 0)
return;
struct output *output = data;
output->width = width;
output->height = height;
}
static void output_done(void *data, struct wl_output *wl_output) {
struct output *output = data;
const int width = output->width;
const int height = output->height;
const int scale = output->scale;
LOG_INFO("output: %s %s (%dx%d, scale=%d)", output->make, output->model,
width, height, scale);
}
static void output_scale(void *data, struct wl_output *wl_output,
int32_t factor) {
struct output *output = data;
output->scale = factor;
if (output->configured)
render(output);
}
static const struct wl_output_listener output_listener = {
.geometry = &output_geometry,
.mode = &output_mode,
.done = &output_done,
.scale = &output_scale,
};
static void shm_format(void *data, struct wl_shm *wl_shm, uint32_t format) {
if (format == WL_SHM_FORMAT_ARGB8888)
have_argb8888 = true;
}
static const struct wl_shm_listener shm_listener = {
.format = &shm_format,
};
static void add_surface_to_output(struct output *output) {
if (compositor == NULL || layer_shell == NULL)
return;
if (output->surf != NULL)
return;
struct wl_surface *surf = wl_compositor_create_surface(compositor);
struct zwlr_layer_surface_v1 *layer = zwlr_layer_shell_v1_get_layer_surface(
layer_shell, surf, output->wl_output, ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
"mouse_halo");
zwlr_layer_surface_v1_set_exclusive_zone(layer, -1);
zwlr_layer_surface_v1_set_keyboard_interactivity(layer, 0);
zwlr_layer_surface_v1_set_anchor(layer,
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
output->surf = surf;
output->layer = layer;
zwlr_layer_surface_v1_add_listener(layer, &layer_surface_listener, output);
wl_surface_commit(surf);
}
static void pointer_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t surface_x,
wl_fixed_t surface_y) {
cursor_x = wl_fixed_to_int(surface_x);
cursor_y = wl_fixed_to_int(surface_y);
LOG_DBG("%u %u", cursor_x, cursor_y);
// Redraw the surface when the cursor moves
tll_foreach(outputs, it) render(&it->item);
}
static void pointer_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t surface_x, wl_fixed_t surface_y) {
LOG_DBG("ENTER");
cursor_x = wl_fixed_to_int(surface_x);
cursor_y = wl_fixed_to_int(surface_y);
tll_foreach(outputs, it) {
if (it->item.surf == surface) {
current_output = &it->item;
break;
}
}
render(current_output);
}
static void pointer_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface) {
// When the pointer leaves the current output, set current_output to NULL
current_output = NULL;
}
static void pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button,
uint32_t state) {
should_exit = true;
}
static void pointer_axis(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value) {
should_exit = true;
}
static void pointer_frame(void *data, struct wl_pointer *wl_pointer) {}
static void pointer_axis_source(void *data, struct wl_pointer *wl_pointer,
uint32_t axis_source) {}
static void pointer_axis_stop(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis) {}
static void pointer_axis_discrete(void *data, struct wl_pointer *wl_pointer,
uint32_t axis, int32_t discrete) {
should_exit = true;
}
struct wl_pointer_listener pointer_listener = {
.enter = pointer_enter,
.leave = pointer_leave,
.motion = pointer_motion,
.button = pointer_button,
.axis = pointer_axis,
.frame = pointer_frame,
.axis_source = pointer_axis_source,
.axis_stop = pointer_axis_stop,
.axis_discrete = pointer_axis_discrete,
};
static struct wl_pointer *pointer;
static bool verify_iface_version(const char *iface, uint32_t version,
uint32_t wanted) {
if (version >= wanted)
return true;
LOG_ERR("%s: need interface version %u, but compositor only implements %u",
iface, wanted, version);
return false;
}
static void seat_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability capabilities) {
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
LOG_DBG("ADDED POINTER");
pointer = wl_seat_get_pointer(seat);
wl_pointer_add_listener(pointer, &pointer_listener, NULL);
}
}
static void seat_name(void *data, struct wl_seat *seat, const char *name) {}
static const struct wl_seat_listener seat_listener = {
.capabilities = &seat_capabilities,
.name = &seat_name,
};
static void handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface,
uint32_t version) {
if (strcmp(interface, wl_compositor_interface.name) == 0) {
const uint32_t required = 4;
if (!verify_iface_version(interface, version, required))
return;
compositor =
wl_registry_bind(registry, name, &wl_compositor_interface, required);
}
else if (strcmp(interface, wl_shm_interface.name) == 0) {
const uint32_t required = 1;
if (!verify_iface_version(interface, version, required))
return;
shm = wl_registry_bind(registry, name, &wl_shm_interface, required);
wl_shm_add_listener(shm, &shm_listener, NULL);
}
else if (strcmp(interface, wl_output_interface.name) == 0) {
const uint32_t required = 3;
if (!verify_iface_version(interface, version, required))
return;
struct wl_output *wl_output =
wl_registry_bind(registry, name, &wl_output_interface, required);
tll_push_back(outputs, ((struct output){.wl_output = wl_output,
.wl_name = name,
.surf = NULL,
.layer = NULL,
.frame_done = true}));
struct output *output = &tll_back(outputs);
wl_output_add_listener(wl_output, &output_listener, output);
add_surface_to_output(output);
}
else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
const uint32_t required = 2;
if (!verify_iface_version(interface, version, required))
return;
layer_shell = wl_registry_bind(registry, name,
&zwlr_layer_shell_v1_interface, required);
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
wl_seat_add_listener(seat, &seat_listener, NULL);
}
}
static void handle_global_remove(void *data, struct wl_registry *registry,
uint32_t name) {
tll_foreach(outputs, it) {
if (it->item.wl_name == name) {
LOG_DBG("destroyed: %s %s", it->item.make, it->item.model);
output_destroy(&it->item);
tll_remove(outputs, it);
return;
}
}
}
static const struct wl_registry_listener registry_listener = {
.global = &handle_global,
.global_remove = &handle_global_remove,
};
static void usage(const char *progname) {
printf("Usage: %s [OPTIONS] \n"
"\n"
"Options:\n"
" -v,--version show the version number and quit\n",
progname);
}
static const char *version_and_features(void) {
static char buf[256];
snprintf(buf, sizeof(buf), "version: %s", WBG_VERSION);
return buf;
}
int main(int argc, char *const *argv) {
const char *progname = argv[0];
const struct option longopts[] = {
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{NULL, no_argument, 0, 0},
};
while (true) {
int c = getopt_long(argc, argv, "vh", longopts, NULL);
if (c < 0)
break;
switch (c) {
case 'v':
printf("mhalo version: %s\n", version_and_features());
return EXIT_SUCCESS;
case 'h':
usage(progname);
return EXIT_SUCCESS;
case ':':
fprintf(stderr, "error: -%c: missing required argument\n", optopt);
return EXIT_FAILURE;
case '?':
fprintf(stderr, "error: -%c: invalid option\n", optopt);
return EXIT_FAILURE;
}
}
stretch = (argc == 3);
setlocale(LC_CTYPE, "");
log_init(LOG_COLORIZE_AUTO, false, LOG_FACILITY_DAEMON, LOG_CLASS_WARNING);
LOG_INFO("%s", WBG_VERSION);
pixman_color_t black = {0, 0, 0, 0xbfff};
fill = pixman_image_create_solid_fill(&black);
int exit_code = EXIT_FAILURE;
int sig_fd = -1;
display = wl_display_connect(NULL);
if (display == NULL) {
LOG_ERR("failed to connect to wayland; no compositor running?");
goto out;
}
registry = wl_display_get_registry(display);
if (registry == NULL) {
LOG_ERR("failed to get wayland registry");
goto out;
}
wl_registry_add_listener(registry, ®istry_listener, NULL);
wl_display_roundtrip(display);
if (compositor == NULL) {
LOG_ERR("no compositor");
goto out;
}
if (shm == NULL) {
LOG_ERR("no shared memory buffers interface");
goto out;
}
if (layer_shell == NULL) {
LOG_ERR("no layer shell interface");
goto out;
}
tll_foreach(outputs, it) add_surface_to_output(&it->item);
wl_display_roundtrip(display);
if (!have_argb8888) {
LOG_ERR("shm: XRGB image format not available");
goto out;
}
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGQUIT);
sigprocmask(SIG_BLOCK, &mask, NULL);
if ((sig_fd = signalfd(-1, &mask, 0)) < 0) {
LOG_ERRNO("failed to create signal FD");
goto out;
}
while (true) {
wl_display_flush(display);
struct pollfd fds[] = {
{.fd = wl_display_get_fd(display), .events = POLLIN},
{.fd = sig_fd, .events = POLLIN},
};
int ret = poll(fds, sizeof(fds) / sizeof(fds[0]), -1);
if (ret < 0) {
if (errno == EINTR)
continue;
LOG_ERRNO("failed to poll");
break;
}
if (fds[0].revents & POLLHUP) {
LOG_WARN("disconnected by compositor");
break;
}
if (fds[0].revents & POLLIN) {
if (wl_display_dispatch(display) < 0) {
LOG_ERRNO("failed to dispatch Wayland events");
break;
}
}
if (fds[1].revents & POLLHUP)
abort();
if (fds[1].revents & POLLIN) {
struct signalfd_siginfo info;
ssize_t count = read(sig_fd, &info, sizeof(info));
if (count < 0) {
if (errno == EINTR)
continue;
LOG_ERRNO("failed to read from signal FD");
break;
}
assert(count == sizeof(info));
assert(info.ssi_signo == SIGINT || info.ssi_signo == SIGQUIT);
LOG_INFO("goodbye");
exit_code = EXIT_SUCCESS;
break;
}
if (should_exit) {
LOG_INFO("goodbye");
exit_code = EXIT_SUCCESS;
break;
}
}
out:
if (sig_fd >= 0)
close(sig_fd);
tll_foreach(outputs, it) output_destroy(&it->item);
tll_free(outputs);
if (pointer != NULL)
wl_pointer_destroy(pointer);
if (seat != NULL)
wl_seat_destroy(seat);
if (layer_shell != NULL)
zwlr_layer_shell_v1_destroy(layer_shell);
if (shm != NULL)
wl_shm_destroy(shm);
if (compositor != NULL)
wl_compositor_destroy(compositor);
if (registry != NULL)
wl_registry_destroy(registry);
if (display != NULL)
wl_display_disconnect(display);
if (fill != NULL)
pixman_image_unref(fill);
log_deinit();
return exit_code;
}