From 63fd2203fec43c380056a01ace2a3d4294e5e90d Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 9 May 2018 22:13:39 +0100 Subject: [PATCH] Add support for version 2 of the xdg-output protocol --- meson.build | 2 +- types/wlr_xdg_output.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 362de9f6..597236ca 100644 --- a/meson.build +++ b/meson.build @@ -49,7 +49,7 @@ add_project_arguments('-DWL_HIDE_DEPRECATED', language: 'c') wayland_server = dependency('wayland-server') wayland_client = dependency('wayland-client') wayland_egl = dependency('wayland-egl') -wayland_protos = dependency('wayland-protocols', version: '>=1.12') +wayland_protos = dependency('wayland-protocols', version: '>=1.14') egl = dependency('egl') glesv2 = dependency('glesv2') drm = dependency('libdrm') diff --git a/types/wlr_xdg_output.c b/types/wlr_xdg_output.c index ba99cfcb..282968ab 100644 --- a/types/wlr_xdg_output.c +++ b/types/wlr_xdg_output.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -23,11 +24,25 @@ static void output_handle_resource_destroy(struct wl_resource *resource) { static void output_send_details(struct wl_resource *resource, struct wlr_output_layout_output *layout_output) { + struct wlr_output *output = layout_output->output; zxdg_output_v1_send_logical_position(resource, layout_output->x, layout_output->y); + int width, height; wlr_output_effective_resolution(layout_output->output, &width, &height); zxdg_output_v1_send_logical_size(resource, width, height); + + uint32_t version = wl_resource_get_version(resource); + if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) { + zxdg_output_v1_send_name(resource, output->name); + } + if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) { + char description[128]; + snprintf(description, sizeof(description), "%s %s %s (%s)", + output->make, output->model, output->serial, output->name); + zxdg_output_v1_send_description(resource, description); + } + zxdg_output_v1_send_done(resource); } @@ -173,12 +188,11 @@ struct wlr_xdg_output_manager *wlr_xdg_output_manager_create( } manager->layout = layout; manager->global = wl_global_create(display, - &zxdg_output_manager_v1_interface, - OUTPUT_MANAGER_VERSION, manager, output_manager_bind); + &zxdg_output_manager_v1_interface, OUTPUT_MANAGER_VERSION, manager, + output_manager_bind); if (!manager->global) { free(manager); return NULL; - } wl_list_init(&manager->resources);