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