commit c4c3286
sewn
·
2026-05-14 11:29:52 +0000 UTC
parent 3ea0875
handle output xy
1 files changed,
+24,
-0
M
wawa.c
M
wawa.c
+24,
-0
1@@ -21,6 +21,7 @@ struct output {
2 struct wl_surface *surface;
3 struct zwlr_layer_surface_v1 *layer_surface;
4
5+ int32_t x, y;
6 uint32_t width, height;
7 uint32_t size, stride;
8
9@@ -52,6 +53,9 @@ static uint32_t color;
10 static void image_fill(unsigned char *dst, struct output *output);
11 static void (*image_modify)(unsigned char *, struct output *) = image_fill;
12
13+static void
14+noop() {}
15+
16 static void
17 die(const char *fmt, ...)
18 {
19@@ -253,6 +257,25 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
20 .closed = layer_surface_handle_closed,
21 };
22
23+static void
24+output_handle_geometry(void *data, struct wl_output *wl_output,
25+ int32_t x, int32_t y, int32_t physical_width, int32_t physical_height,
26+ int32_t subpixel, const char *make, const char *model, int32_t transform)
27+{
28+ struct output *output = data;
29+ output->x = x;
30+ output->y = y;
31+}
32+
33+static const struct wl_output_listener output_listener = {
34+ .geometry = output_handle_geometry,
35+ .mode = noop,
36+ .done = noop,
37+ .scale = noop,
38+ .name = noop,
39+ .description = noop,
40+};
41+
42 static void
43 output_setup_callback(void *data, struct wl_callback *callback,
44 uint32_t time)
45@@ -296,6 +319,7 @@ registry_handle_global(void *data, struct wl_registry *registry,
46 if (!output) die("calloc:");
47 output->wl = wl_registry_bind(registry, name,
48 &wl_output_interface, 1);
49+ wl_output_add_listener(output->wl, &output_listener, output);
50 wl_list_insert(&outputs, &output->link);
51 /*
52 * There is no gurantee of the registry order, ensure a callback is used