output: introduce wlr_output_set_name

wlroots picks names for all outputs, but it might be desirable for
compositor to override it.

For instance, Sway will use a headless output as a fallback in
case no outputs are connected. Sway wants to clearly label the
fallback output as such and label "real" headless outputs starting
from HEADLESS-1.
This commit is contained in:
Simon Ser 2021-12-09 15:43:19 +01:00
parent 1fbd13ec79
commit 36a2b19485
6 changed files with 33 additions and 9 deletions

View file

@ -324,6 +324,13 @@ void wlr_output_set_subpixel(struct wlr_output *output,
wlr_output_schedule_done(output);
}
void wlr_output_set_name(struct wlr_output *output, const char *name) {
assert(output->global == NULL);
free(output->name);
output->name = strdup(name);
}
void wlr_output_set_description(struct wlr_output *output, const char *desc) {
if (output->description != NULL && desc != NULL &&
strcmp(output->description, desc) == 0) {
@ -420,6 +427,7 @@ void wlr_output_destroy(struct wlr_output *output) {
wl_event_source_remove(output->idle_done);
}
free(output->name);
free(output->description);
pixman_region32_fini(&output->pending.damage);