Skip to content

Commit

Permalink
ozone/wayland: remove CHROME_WAYLAND_CHECK_VERSION from wayland_object.h
Browse files Browse the repository at this point in the history
Currently, CHROME_WAYLAND_CHECK_VERSION is used for some Wayland
interface listener declarations, to prevent "Excess elements in struct
initializer" errors when compiling with older versions of libwayland
(use_system_libwayland = true).

We can instead check if the matching <INTERFACE>_<EVENT>_SINCE_VERSION
variable has been `#define`d to guard the listener declarations. This
is more readable and does not require manually checking since what
version of the Wayland protocol the event exists.

This CL does not touch CHROME_WAYLAND_CHECK_VERSION in
//third_party/wayland/stubs/libwayland_variadic_support.cc.

Bug: 578890
Change-Id: Iedb052be87feba15d41bdbb4c4d6c4bfb4d9457d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4013308
Reviewed-by: Alexander Dunaev <adunaev@igalia.com>
Commit-Queue: Max Ihlenfeldt <max@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1069084}
  • Loading branch information
MaxIhlenfeldt authored and Chromium LUCI CQ committed Nov 9, 2022
1 parent 6e4aff8 commit baf075c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
6 changes: 0 additions & 6 deletions ui/ozone/platform/wayland/common/wayland_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
#include "base/check.h"
#include "ui/ozone/platform/wayland/common/wayland.h"

#define CHROME_WAYLAND_CHECK_VERSION(x, y, z) \
(WAYLAND_VERSION_MAJOR > x || \
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && \
WAYLAND_VERSION_MICRO >= z))

struct wl_proxy;

namespace ui {
Expand Down
23 changes: 11 additions & 12 deletions ui/ozone/platform/wayland/host/wayland_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "base/strings/string_util.h"
#include "ui/display/display.h"
#include "ui/gfx/color_space.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_output.h"
Expand Down Expand Up @@ -116,15 +115,15 @@ void WaylandOutput::Initialize(Delegate* delegate) {
DCHECK(!delegate_);
delegate_ = delegate;
static constexpr wl_output_listener output_listener = {
&OutputHandleGeometry,
&OutputHandleMode,
&OutputHandleDone,
&OutputHandleScale,
#if CHROME_WAYLAND_CHECK_VERSION(1, 20, 0)
// since protocol version 4 and Wayland version 1.20
&OutputHandleName,
&OutputHandleDescription,
&OutputHandleGeometry, &OutputHandleMode,
&OutputHandleDone, &OutputHandleScale,
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
&OutputHandleName,
#endif
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
&OutputHandleDescription,
#endif

};
wl_output_add_listener(output_.get(), &output_listener, this);
}
Expand Down Expand Up @@ -249,16 +248,17 @@ void WaylandOutput::OutputHandleScale(void* data,
wayland_output->scale_factor_ = factor;
}

#if CHROME_WAYLAND_CHECK_VERSION(1, 20, 0)

#ifdef WL_OUTPUT_NAME_SINCE_VERSION
// static
void WaylandOutput::OutputHandleName(void* data,
struct wl_output* wl_output,
const char* name) {
if (WaylandOutput* wayland_output = static_cast<WaylandOutput*>(data))
wayland_output->name_ = name ? std::string(name) : std::string{};
}
#endif

#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
// static
void WaylandOutput::OutputHandleDescription(void* data,
struct wl_output* wl_output,
Expand All @@ -268,7 +268,6 @@ void WaylandOutput::OutputHandleDescription(void* data,
description ? std::string(description) : std::string{};
}
}

#endif

} // namespace ui
4 changes: 3 additions & 1 deletion ui/ozone/platform/wayland/host/wayland_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ class WaylandOutput : public wl::GlobalObjectRegistrar<WaylandOutput> {
static void OutputHandleScale(void* data,
struct wl_output* wl_output,
int32_t factor);
#if CHROME_WAYLAND_CHECK_VERSION(1, 20, 0)
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
static void OutputHandleName(void* data,
struct wl_output* wl_output,
const char* name);
#endif
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
static void OutputHandleDescription(void* data,
struct wl_output* wl_output,
const char* description);
Expand Down

0 comments on commit baf075c

Please sign in to comment.