aboutsummaryrefslogtreecommitdiff
path: root/backend/headless
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-10-13 13:12:43 +0200
committerSimon Ser <contact@emersion.fr>2022-10-13 13:12:43 +0200
commita28caf08e364223339814d2d01cd217433d199e2 (patch)
tree87f415c836bafcbe4ad4d545076da1353768c7af /backend/headless
parent11192e69308ff48c0f3ec40fb572c4e8e4ad13d8 (diff)
backend: use global output name counters
The output names must be globally unique per the Wayland spec, even if the compositor creates multiple backends of the same kind.
Diffstat (limited to 'backend/headless')
-rw-r--r--backend/headless/output.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/backend/headless/output.c b/backend/headless/output.c
index 5350747f..965314d2 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -10,6 +10,8 @@ static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_BUFFER |
WLR_OUTPUT_STATE_MODE;
+static size_t last_output_num = 0;
+
static struct wlr_headless_output *headless_output_from_output(
struct wlr_output *wlr_output) {
assert(wlr_output_is_headless(wlr_output));
@@ -116,13 +118,14 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
output_set_custom_mode(output, width, height, 0);
+ size_t output_num = ++last_output_num;
+
char name[64];
- snprintf(name, sizeof(name), "HEADLESS-%zu", ++backend->last_output_num);
+ snprintf(name, sizeof(name), "HEADLESS-%zu", output_num);
wlr_output_set_name(wlr_output, name);
char description[128];
- snprintf(description, sizeof(description),
- "Headless output %zu", backend->last_output_num);
+ snprintf(description, sizeof(description), "Headless output %zu", output_num);
wlr_output_set_description(wlr_output, description);
struct wl_event_loop *ev = wl_display_get_event_loop(backend->display);