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.
Simon Ser 2 years ago
parent 11192e6930
commit a28caf08e3

@ -10,6 +10,8 @@ static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_BUFFER | WLR_OUTPUT_STATE_BUFFER |
WLR_OUTPUT_STATE_MODE; WLR_OUTPUT_STATE_MODE;
static size_t last_output_num = 0;
static struct wlr_headless_output *headless_output_from_output( static struct wlr_headless_output *headless_output_from_output(
struct wlr_output *wlr_output) { struct wlr_output *wlr_output) {
assert(wlr_output_is_headless(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); output_set_custom_mode(output, width, height, 0);
size_t output_num = ++last_output_num;
char name[64]; 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); wlr_output_set_name(wlr_output, name);
char description[128]; char description[128];
snprintf(description, sizeof(description), snprintf(description, sizeof(description), "Headless output %zu", output_num);
"Headless output %zu", backend->last_output_num);
wlr_output_set_description(wlr_output, description); wlr_output_set_description(wlr_output, description);
struct wl_event_loop *ev = wl_display_get_event_loop(backend->display); struct wl_event_loop *ev = wl_display_get_event_loop(backend->display);

@ -32,6 +32,8 @@ static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_MODE |
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED; WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
static size_t last_output_num = 0;
static struct wlr_wl_output *get_wl_output_from_output( static struct wlr_wl_output *get_wl_output_from_output(
struct wlr_output *wlr_output) { struct wlr_output *wlr_output) {
assert(wlr_output_is_wl(wlr_output)); assert(wlr_output_is_wl(wlr_output));
@ -525,13 +527,14 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED; wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED;
size_t output_num = ++last_output_num;
char name[64]; char name[64];
snprintf(name, sizeof(name), "WL-%zu", ++backend->last_output_num); snprintf(name, sizeof(name), "WL-%zu", output_num);
wlr_output_set_name(wlr_output, name); wlr_output_set_name(wlr_output, name);
char description[128]; char description[128];
snprintf(description, sizeof(description), snprintf(description, sizeof(description), "Wayland output %zu", output_num);
"Wayland output %zu", backend->last_output_num);
wlr_output_set_description(wlr_output, description); wlr_output_set_description(wlr_output, description);
output->backend = backend; output->backend = backend;

@ -29,6 +29,8 @@ static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_MODE |
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED; WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
static size_t last_output_num = 0;
static void parse_xcb_setup(struct wlr_output *output, static void parse_xcb_setup(struct wlr_output *output,
xcb_connection_t *xcb) { xcb_connection_t *xcb) {
const xcb_setup_t *xcb_setup = xcb_get_setup(xcb); const xcb_setup_t *xcb_setup = xcb_get_setup(xcb);
@ -518,15 +520,16 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
wlr_output_update_custom_mode(wlr_output, 1024, 768, 0); wlr_output_update_custom_mode(wlr_output, 1024, 768, 0);
size_t output_num = ++last_output_num;
char name[64]; char name[64];
snprintf(name, sizeof(name), "X11-%zu", ++x11->last_output_num); snprintf(name, sizeof(name), "X11-%zu", output_num);
wlr_output_set_name(wlr_output, name); wlr_output_set_name(wlr_output, name);
parse_xcb_setup(wlr_output, x11->xcb); parse_xcb_setup(wlr_output, x11->xcb);
char description[128]; char description[128];
snprintf(description, sizeof(description), snprintf(description, sizeof(description), "X11 output %zu", output_num);
"X11 output %zu", x11->last_output_num);
wlr_output_set_description(wlr_output, description); wlr_output_set_description(wlr_output, description);
// The X11 protocol requires us to set a colormap and border pixel if the // The X11 protocol requires us to set a colormap and border pixel if the

@ -10,7 +10,6 @@ struct wlr_headless_backend {
struct wlr_backend backend; struct wlr_backend backend;
struct wl_display *display; struct wl_display *display;
struct wl_list outputs; struct wl_list outputs;
size_t last_output_num;
struct wl_listener display_destroy; struct wl_listener display_destroy;
bool started; bool started;
}; };

@ -25,7 +25,6 @@ struct wlr_wl_backend {
int drm_fd; int drm_fd;
struct wl_list buffers; // wlr_wl_buffer.link struct wl_list buffers; // wlr_wl_buffer.link
size_t requested_outputs; size_t requested_outputs;
size_t last_output_num;
struct wl_listener local_display_destroy; struct wl_listener local_display_destroy;
char *activation_token; char *activation_token;

@ -74,7 +74,6 @@ struct wlr_x11_backend {
uint32_t dri3_major_version, dri3_minor_version; uint32_t dri3_major_version, dri3_minor_version;
size_t requested_outputs; size_t requested_outputs;
size_t last_output_num;
struct wl_list outputs; // wlr_x11_output::link struct wl_list outputs; // wlr_x11_output::link
struct wlr_keyboard keyboard; struct wlr_keyboard keyboard;

Loading…
Cancel
Save