commit 502f272

sewn  ·  2026-03-14 08:46:47 +0000 UTC
parent f739312
Implement wl_output version 4
2 files changed,  +12, -2
+11, -2
 1@@ -20,7 +20,7 @@ bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 2 {
 3 	struct output *output = data;
 4 	struct screen *screen = output->screen;
 5-	struct mode *mode;
 6+	struct mode *mode = &screen->planes.primary.mode;
 7 	struct wl_resource *resource;
 8 	uint32_t flags;
 9 
10@@ -54,6 +54,10 @@ bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id)
11 		                    mode->refresh);
12 	}
13 
14+	if (version >= 4) {
15+		wl_output_send_name(resource, output->name);
16+	}
17+
18 	if (version >= 2) {
19 		wl_output_send_done(resource);
20 	}
21@@ -64,6 +68,7 @@ output_new(drmModeConnectorPtr connector)
22 {
23 	struct output *output;
24 	struct mode *modes;
25+	const char *name;
26 	uint32_t i;
27 
28 	if (!(output = malloc(sizeof(*output)))) {
29@@ -71,7 +76,7 @@ output_new(drmModeConnectorPtr connector)
30 		goto error0;
31 	}
32 
33-	output->global = wl_global_create(swc.display, &wl_output_interface, 3,
34+	output->global = wl_global_create(swc.display, &wl_output_interface, 4,
35 	                                  output, &bind_output);
36 
37 	if (!output->global) {
38@@ -112,6 +117,10 @@ output_new(drmModeConnectorPtr connector)
39 		output->preferred_mode = &modes[0];
40 	}
41 
42+	if (!(name = drmModeGetConnectorTypeName(connector->connector_type)))
43+		name = "UNKNOWN";
44+	snprintf(output->name, sizeof(output->name), "%s-%d", name, connector->connector_type_id);
45+
46 	return output;
47 
48 error2:
+1, -0
1@@ -11,6 +11,7 @@ struct wl_display;
2 struct output {
3 	struct screen *screen;
4 
5+	char name[24];
6 	/* The physical dimensions (in mm) of this output */
7 	uint32_t physical_width, physical_height;
8