1 From 10d1d855a0ce4557cb710e73e3e7c9ab0dd0e734 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Mon, 4 Dec 2023 14:16:36 +0200
4 Subject: [PATCH 1/2] display: Add support for wl_output version 4
6 This allows support for wl_output.name and wl_output.desc be sent out
7 by the compositor that supports it.
9 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
11 shell/wayland/display.cc | 34 ++++++++++++++++++++++++++++++----
12 shell/wayland/display.h | 28 ++++++++++++++++++++++++++++
13 2 files changed, 58 insertions(+), 4 deletions(-)
15 diff --git a/shell/wayland/display.cc b/shell/wayland/display.cc
16 index 8e309ef..3ee814a 100644
17 --- a/shell/wayland/display.cc
18 +++ b/shell/wayland/display.cc
19 @@ -191,9 +191,16 @@ void Display::registry_handle_global(void* data,
20 auto oi = std::make_shared<output_info_t>();
21 std::fill_n(oi.get(), 1, output_info_t{});
23 - oi->output = static_cast<struct wl_output*>(
24 - wl_registry_bind(registry, name, &wl_output_interface,
25 - std::min(static_cast<uint32_t>(2), version)));
26 + // be compat with v2 as well
27 + if (version >= WL_OUTPUT_NAME_SINCE_VERSION &&
28 + version >= WL_OUTPUT_DESCRIPTION_SINCE_VERSION)
29 + oi->output = static_cast<struct wl_output*>(
30 + wl_registry_bind(registry, name, &wl_output_interface,
31 + std::min(static_cast<uint32_t>(4), version)));
33 + oi->output = static_cast<struct wl_output*>(
34 + wl_registry_bind(registry, name, &wl_output_interface,
35 + std::min(static_cast<uint32_t>(2), version)));
36 wl_output_add_listener(oi->output, &output_listener, oi.get());
37 SPDLOG_DEBUG("Wayland: Output [{}]", d->m_all_outputs.size());
38 d->m_all_outputs.push_back(oi);
39 @@ -299,9 +306,28 @@ void Display::display_handle_done(void* data,
43 +void Display::display_handle_name(void* data,
44 + struct wl_output* /* wl_output */,
46 + auto* oi = static_cast<output_info_t*>(data);
47 + oi->name = std::string(name);
50 +void Display::display_handle_desc(void* data,
51 + struct wl_output* /* wl_output */,
53 + auto* oi = static_cast<output_info_t*>(data);
54 + oi->desc = std::string(desc);
57 const struct wl_output_listener Display::output_listener = {
58 display_handle_geometry, display_handle_mode, display_handle_done,
59 - display_handle_scale};
60 + display_handle_scale
61 +#if defined(WL_OUTPUT_NAME_SINCE_VERSION) && \
62 + defined(WL_OUTPUT_DESCRIPTION_SINCE_VERSION)
63 + , display_handle_name, display_handle_desc
67 void Display::shm_format(void* /* data */,
68 struct wl_shm* /* wl_shm */,
69 diff --git a/shell/wayland/display.h b/shell/wayland/display.h
70 index cc3f4be..a0756f0 100644
71 --- a/shell/wayland/display.h
72 +++ b/shell/wayland/display.h
73 @@ -329,6 +329,8 @@ class Display {
75 MAYBE_UNUSED bool done;
81 struct pointer_event {
82 @@ -520,6 +522,32 @@ class Display {
84 static void display_handle_done(void* data, struct wl_output* wl_output);
87 + * @brief Set the display output name
88 + * @param[in,out] data Data of type output_info_t*
89 + * @param[in] wl_output No use
90 + * @param[in] output_name Display name
93 + * wayland - since @v4 of wl_output
95 + static void display_handle_name(void* data,
96 + struct wl_output* wl_output,
97 + const char* output_name);
100 + * @brief Set the display description
101 + * @param[in,out] data Data of type output_info_t*
102 + * @param[in] wl_output No use
103 + * @param[in] desc_name Display description name
106 + * wayland - since @v4 of wl_output
108 + static void display_handle_desc(void* data,
109 + struct wl_output* wl_output,
110 + const char* desc_name);
112 static const struct wl_shm_listener shm_listener;