aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-03-15 11:49:21 -0400
committeremersion <contact@emersion.fr>2019-03-15 18:38:12 +0200
commit6b7f5e4010103bffaf4666b77f7a4369295588d8 (patch)
treebc130cd2fb65236d63f5c5080826a6f4ee4001c0
parentc97f0eb0f2b9f349b573d83f67b0a20f00c2f9c8 (diff)
backend/noop: improve output number handling
This improves the way the output numbers are handled for the noop backend. Instead of using the number of active outputs plus one, the last used number is stored and new outputs will increment it. This fixes the situation where you start with one output, create a second, close the first, and create a third. Without this, both outputs will be NOOP-2, which causes an issue since the identifier will also be identical. With this, the last output is NOOP-3 and the outputs can be distinguished.
-rw-r--r--backend/noop/output.c4
-rw-r--r--include/backend/noop.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/backend/noop/output.c b/backend/noop/output.c
index a2595eff..14ba5ed0 100644
--- a/backend/noop/output.c
+++ b/backend/noop/output.c
@@ -61,8 +61,8 @@ struct wlr_output *wlr_noop_add_output(struct wlr_backend *wlr_backend) {
strncpy(wlr_output->make, "noop", sizeof(wlr_output->make));
strncpy(wlr_output->model, "noop", sizeof(wlr_output->model));
- snprintf(wlr_output->name, sizeof(wlr_output->name), "NOOP-%d",
- wl_list_length(&backend->outputs) + 1);
+ snprintf(wlr_output->name, sizeof(wlr_output->name), "NOOP-%ld",
+ ++backend->last_output_num);
wl_list_insert(&backend->outputs, &output->link);
diff --git a/include/backend/noop.h b/include/backend/noop.h
index 4198baad..e301eb07 100644
--- a/include/backend/noop.h
+++ b/include/backend/noop.h
@@ -8,6 +8,7 @@ struct wlr_noop_backend {
struct wlr_backend backend;
struct wl_display *display;
struct wl_list outputs;
+ size_t last_output_num;
bool started;
};