Enable cve-check in CI jobs for additional cve log files
[AGL/meta-agl.git] / meta-agl-flutter / recipes-graphics / toyota / files / 0001-display-Add-support-for-wl_output-version-4.patch
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
5
6 This allows support for wl_output.name and wl_output.desc be sent out
7 by the compositor that supports it.
8
9 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
10 ---
11  shell/wayland/display.cc | 34 ++++++++++++++++++++++++++++++----
12  shell/wayland/display.h  | 28 ++++++++++++++++++++++++++++
13  2 files changed, 58 insertions(+), 4 deletions(-)
14
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{});
22      oi->global_id = name;
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)));
32 +    else
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,
40    oi->done = true;
41  }
42  
43 +void Display::display_handle_name(void* data,
44 +                                  struct wl_output* /* wl_output */,
45 +                                  const char* name) {
46 +  auto* oi = static_cast<output_info_t*>(data);
47 +  oi->name = std::string(name);
48 +}
49 +
50 +void Display::display_handle_desc(void* data,
51 +                                  struct wl_output* /* wl_output */,
52 +                                  const char* desc) {
53 +  auto* oi = static_cast<output_info_t*>(data);
54 +  oi->desc = std::string(desc);
55 +}
56 +
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
64 +#endif
65 +};
66  
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 {
74      int32_t scale;
75      MAYBE_UNUSED bool done;
76      int transform;
77 +    std::string name;
78 +    std::string desc;
79    } output_info_t;
80  
81    struct pointer_event {
82 @@ -520,6 +522,32 @@ class Display {
83     */
84    static void display_handle_done(void* data, struct wl_output* wl_output);
85  
86 +  /**
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
91 +   * @return void
92 +   * @relation
93 +   * wayland - since @v4 of wl_output
94 +   */
95 +  static void display_handle_name(void* data,
96 +                                  struct wl_output* wl_output,
97 +                                  const char* output_name);
98 +
99 +  /**
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
104 +   * @return void
105 +   * @relation
106 +   * wayland - since @v4 of wl_output
107 +   */
108 +  static void display_handle_desc(void* data,
109 +                                  struct wl_output* wl_output,
110 +                                  const char* desc_name);
111 +
112    static const struct wl_shm_listener shm_listener;
113  
114    /**
115 -- 
116 2.35.1
117