commit 470591f

sewn  ·  2026-05-07 20:27:02 +0000 UTC
parent cb31c30
fix some goofs
1 files changed,  +12, -20
M wawa.c
M wawa.c
+12, -20
 1@@ -2,15 +2,10 @@
 2 #include <fcntl.h>
 3 #include <stdbool.h>
 4 #include <sys/mman.h>
 5-#include <math.h>
 6 #include <unistd.h>
 7-#include <malloc.h>
 8 #include <wayland-client-protocol.h>
 9 #include <wayland-client.h>
10-
11-#ifdef __linux__
12 #include <linux/memfd.h>
13-#endif
14 
15 #include "stbi_alloc.h"
16 
17@@ -110,20 +105,7 @@ output_load_image(struct output *output)
18 	data = mmap(NULL, output->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
19 	if (data == MAP_FAILED) die("mmap:");
20 
21-	image_crop(data, output);
22-
23-	/* BGR->RGB */ 
24-	for (int i = 0; i < output->size; i += 4) {
25-		data[i+2] ^= (data[i] ^= data[i+2]);
26-		data[i] ^= data[i+2];
27-	}
28-
29-	munmap(data, output->size);
30-
31-#if defined(__linux__) || \
32-	((defined(__FreeBSD__) && (__FreeBSD_version >= 1300048)))
33 	fcntl(fd, F_ADD_SEALS, F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL);
34-#endif
35 
36 	shm_pool = wl_shm_create_pool(shm, fd, output->size);
37 	buffer = wl_shm_pool_create_buffer(shm_pool, 0,
38@@ -131,6 +113,16 @@ output_load_image(struct output *output)
39 	wl_shm_pool_destroy(shm_pool);
40 	close(fd);
41 
42+	image_crop(data, output);
43+
44+	/* RGBA->BGRA */
45+	for (int i = 0; i < output->size; i += 4) {
46+		data[i] ^= data[i+2];
47+		data[i+2] ^= data[i];
48+		data[i] ^= data[i+2];
49+	}
50+
51+	munmap(data, output->size);
52 	return buffer;
53 }
54 
55@@ -140,6 +132,7 @@ layer_surface_handle_configure(void *data, struct zwlr_layer_surface_v1 *layer_s
56 {
57 	struct wl_buffer *buffer;
58 	struct output *output = data;
59+
60 	zwlr_layer_surface_v1_ack_configure(layer_surface, serial);
61 
62 	output->configured = width == output->width && height == output->height;
63@@ -149,7 +142,7 @@ layer_surface_handle_configure(void *data, struct zwlr_layer_surface_v1 *layer_s
64 		fputs("loaded image", stderr);
65 		if (!(image.data = stbi_load(filename,
66 		                       &image.width, &image.height, NULL, 4)))
67-			die("failed to load image: %s", stbi_failure_reason());	
68+			die("failed to load image: %s", stbi_failure_reason());
69 	}
70 
71 	output->width = width;
72@@ -257,7 +250,6 @@ static const struct wl_registry_listener registry_listener = {
73 int
74 main(int argc, char *argv[])
75 {
76-	struct output *output, *tmp;
77 	if (argc != 2) {
78 		fprintf(stderr, "usage: %s filename\n", argv[0]);
79 		return EXIT_FAILURE;