Commit f57a27e4 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

ozone/wayland: support libwayland <1.10

Some internal methods use wl_proxy_get_version and
wl_proxy_marshal_constructor_versioned that were defined in
libwayland 1.10. However, we fail to resolve to map with these
symbols when Chromium is run against older versions and that
results in failures.

Thus, fix that by checking if these exist by redeclaring them
with weak function attribute.

Bug: 1123005
Change-Id: I4407e0a6917f951b0ccfe3f9ffd366bc64dc9838
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379917Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Maksim Sisov (GMT+3) <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#802714}
parent 529c0640
...@@ -16,6 +16,8 @@ source_set("wayland") { ...@@ -16,6 +16,8 @@ source_set("wayland") {
"client_native_pixmap_factory_wayland.h", "client_native_pixmap_factory_wayland.h",
"common/data_util.cc", "common/data_util.cc",
"common/data_util.h", "common/data_util.h",
"common/wayland.cc",
"common/wayland.h",
"common/wayland_object.cc", "common/wayland_object.cc",
"common/wayland_object.h", "common/wayland_object.h",
"common/wayland_util.cc", "common/wayland_util.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/wayland/common/wayland.h"
namespace wl {
void* bind_registry(struct wl_registry* registry,
uint32_t name,
const struct wl_interface* interface,
uint32_t version) {
if (wl_proxy_marshal_constructor_versioned) {
return wl_registry_bind(registry, name, interface, version);
} else {
return wl_proxy_marshal_constructor(reinterpret_cast<wl_proxy*>(registry),
WL_REGISTRY_BIND, interface, name,
interface->name, version, nullptr);
}
NOTREACHED();
return nullptr;
}
} // namespace wl
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_H_
#define UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_H_
// This header includes wayland-client-core.h and wayland-client-protocol.h
#include <wayland-client.h>
#include "base/notreached.h"
#define WEAK_WAYLAND_FN(x) extern "C" __attribute__((weak)) decltype(x) x
// These functions are used by wl_proxy_get_version and wl_registry_bind.
// However, they were introduced in libwayland 1.10, and if we run Chromium with
// older library, these symbols are undefined. Thus, check their availability
// and use some older API.
//
// TODO(msisov): Remove these once support for Ubuntu Trusty is dropped.
WEAK_WAYLAND_FN(wl_proxy_marshal_constructor_versioned);
WEAK_WAYLAND_FN(wl_proxy_get_version);
namespace wl {
template <typename T>
uint32_t get_version_of_object(T* obj) {
if (wl_proxy_get_version)
return wl_proxy_get_version(reinterpret_cast<wl_proxy*>(obj));
// Older version of the libwayland-client didn't support version of objects.
return 0;
}
void* bind_registry(struct wl_registry* registry,
uint32_t name,
const struct wl_interface* interface,
uint32_t version);
} // namespace wl
#endif // UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_H_
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux-explicit-synchronization-unstable-v1-client-protocol.h> #include <linux-explicit-synchronization-unstable-v1-client-protocol.h>
#include <presentation-time-client-protocol.h> #include <presentation-time-client-protocol.h>
#include <text-input-unstable-v1-client-protocol.h> #include <text-input-unstable-v1-client-protocol.h>
#include <wayland-client.h>
#include <wayland-drm-client-protocol.h> #include <wayland-drm-client-protocol.h>
#include <xdg-shell-client-protocol.h> #include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h> #include <xdg-shell-unstable-v6-client-protocol.h>
...@@ -20,35 +19,35 @@ namespace wl { ...@@ -20,35 +19,35 @@ namespace wl {
namespace { namespace {
void delete_keyboard(wl_keyboard* keyboard) { void delete_keyboard(wl_keyboard* keyboard) {
if (wl_keyboard_get_version(keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION) if (wl::get_version_of_object(keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
wl_keyboard_release(keyboard); wl_keyboard_release(keyboard);
else else
wl_keyboard_destroy(keyboard); wl_keyboard_destroy(keyboard);
} }
void delete_pointer(wl_pointer* pointer) { void delete_pointer(wl_pointer* pointer) {
if (wl_pointer_get_version(pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) if (wl::get_version_of_object(pointer) >= WL_POINTER_RELEASE_SINCE_VERSION)
wl_pointer_release(pointer); wl_pointer_release(pointer);
else else
wl_pointer_destroy(pointer); wl_pointer_destroy(pointer);
} }
void delete_seat(wl_seat* seat) { void delete_seat(wl_seat* seat) {
if (wl_seat_get_version(seat) >= WL_SEAT_RELEASE_SINCE_VERSION) if (wl::get_version_of_object(seat) >= WL_SEAT_RELEASE_SINCE_VERSION)
wl_seat_release(seat); wl_seat_release(seat);
else else
wl_seat_destroy(seat); wl_seat_destroy(seat);
} }
void delete_touch(wl_touch* touch) { void delete_touch(wl_touch* touch) {
if (wl_touch_get_version(touch) >= WL_TOUCH_RELEASE_SINCE_VERSION) if (wl::get_version_of_object(touch) >= WL_TOUCH_RELEASE_SINCE_VERSION)
wl_touch_release(touch); wl_touch_release(touch);
else else
wl_touch_destroy(touch); wl_touch_destroy(touch);
} }
void delete_data_device(wl_data_device* data_device) { void delete_data_device(wl_data_device* data_device) {
if (wl_data_device_get_version(data_device) >= if (wl::get_version_of_object(data_device) >=
WL_DATA_DEVICE_RELEASE_SINCE_VERSION) { WL_DATA_DEVICE_RELEASE_SINCE_VERSION) {
wl_data_device_release(data_device); wl_data_device_release(data_device);
} else { } else {
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_
#define UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_ #define UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_
#include <wayland-client-core.h>
#include <memory> #include <memory>
#include "ui/ozone/platform/wayland/common/wayland.h"
struct gtk_primary_selection_device; struct gtk_primary_selection_device;
struct gtk_primary_selection_device_manager; struct gtk_primary_selection_device_manager;
struct gtk_primary_selection_offer; struct gtk_primary_selection_offer;
...@@ -364,7 +365,7 @@ class Object : public std::unique_ptr<T, Deleter> { ...@@ -364,7 +365,7 @@ class Object : public std::unique_ptr<T, Deleter> {
template <typename T> template <typename T>
wl::Object<T> Bind(wl_registry* registry, uint32_t name, uint32_t version) { wl::Object<T> Bind(wl_registry* registry, uint32_t name, uint32_t version) {
return wl::Object<T>(static_cast<T*>( return wl::Object<T>(static_cast<T*>(
wl_registry_bind(registry, name, ObjectTraits<T>::interface, version))); wl::bind_registry(registry, name, ObjectTraits<T>::interface, version)));
} }
} // namespace wl } // namespace wl
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <vector> #include <vector>
#include <wayland-client.h>
#include "base/callback.h" #include "base/callback.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CURSOR_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CURSOR_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CURSOR_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CURSOR_H_
#include <wayland-client.h>
#include <vector> #include <vector>
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_H_
#include <wayland-client.h>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <string> #include <string>
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_data_device_manager.h" #include "ui/ozone/platform/wayland/host/wayland_data_device_manager.h"
#include <wayland-client-protocol.h>
#include <memory> #include <memory>
#include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h"
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_data_drag_controller.h" #include "ui/ozone/platform/wayland/host/wayland_data_drag_controller.h"
#include <wayland-client-protocol.h>
#include <cstdint> #include <cstdint>
#include "base/check.h" #include "base/check.h"
......
...@@ -26,7 +26,7 @@ WaylandDataOffer::~WaylandDataOffer() { ...@@ -26,7 +26,7 @@ WaylandDataOffer::~WaylandDataOffer() {
void WaylandDataOffer::SetAction(uint32_t dnd_actions, void WaylandDataOffer::SetAction(uint32_t dnd_actions,
uint32_t preferred_action) { uint32_t preferred_action) {
if (wl_data_offer_get_version(data_offer_.get()) >= if (wl::get_version_of_object(data_offer_.get()) >=
WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION) { WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION) {
wl_data_offer_set_actions(data_offer_.get(), dnd_actions, preferred_action); wl_data_offer_set_actions(data_offer_.get(), dnd_actions, preferred_action);
} }
...@@ -62,9 +62,10 @@ base::ScopedFD WaylandDataOffer::Receive(const std::string& mime_type) { ...@@ -62,9 +62,10 @@ base::ScopedFD WaylandDataOffer::Receive(const std::string& mime_type) {
} }
void WaylandDataOffer::FinishOffer() { void WaylandDataOffer::FinishOffer() {
if (wl_data_offer_get_version(data_offer_.get()) >= if (wl::get_version_of_object(data_offer_.get()) >=
WL_DATA_OFFER_FINISH_SINCE_VERSION) WL_DATA_OFFER_FINISH_SINCE_VERSION) {
wl_data_offer_finish(data_offer_.get()); wl_data_offer_finish(data_offer_.get());
}
} }
uint32_t WaylandDataOffer::source_actions() const { uint32_t WaylandDataOffer::source_actions() const {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_H_
#include <wayland-client.h>
#include <string> #include <string>
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "ui/ozone/platform/wayland/host/wayland_data_source.h" #include "ui/ozone/platform/wayland/host/wayland_data_source.h"
#include <gtk-primary-selection-client-protocol.h> #include <gtk-primary-selection-client-protocol.h>
#include <wayland-client-protocol.h>
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
...@@ -111,7 +110,7 @@ void DataSource<T>::SetAction(int operation) { ...@@ -111,7 +110,7 @@ void DataSource<T>::SetAction(int operation) {
template <> template <>
void DataSource<wl_data_source>::SetAction(int operation) { void DataSource<wl_data_source>::SetAction(int operation) {
if (wl_data_source_get_version(data_source_.get()) >= if (wl::get_version_of_object(data_source_.get()) >=
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION) { WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION) {
uint32_t dnd_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; uint32_t dnd_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
if (operation & ui::DragDropTypes::DRAG_COPY) if (operation & ui::DragDropTypes::DRAG_COPY)
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include <linux/input.h> #include <linux/input.h>
#include <wayland-client-protocol.h>
#include <wayland-server-core.h>
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/platform/wayland/host/wayland_event_source.h" #include "ui/ozone/platform/wayland/host/wayland_event_source.h"
......
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
#include "ui/ozone/platform/wayland/host/wayland_event_watcher.h" #include "ui/ozone/platform/wayland/host/wayland_event_watcher.h"
#include <wayland-client-core.h>
#include <wayland-client-protocol.h>
#include "base/bind.h" #include "base/bind.h"
#include "base/check.h" #include "base/check.h"
#include "base/task/current_thread.h" #include "base/task/current_thread.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/ozone/platform/wayland/common/wayland.h"
namespace ui { namespace ui {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_KEYBOARD_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_KEYBOARD_H_
#include <keyboard-extension-unstable-v1-client-protocol.h> #include <keyboard-extension-unstable-v1-client-protocol.h>
#include <wayland-client.h>
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/base/buildflags.h" #include "ui/base/buildflags.h"
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_output.h" #include "ui/ozone/platform/wayland/host/wayland_output.h"
#include <wayland-client.h>
#include "ui/gfx/color_space.h" #include "ui/gfx/color_space.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include "ui/ozone/platform/wayland/host/wayland_pointer.h" #include "ui/ozone/platform/wayland/host/wayland_pointer.h"
#include <linux/input.h> #include <linux/input.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h>
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/types/event_type.h" #include "ui/events/types/event_type.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SHM_BUFFER_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SHM_BUFFER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SHM_BUFFER_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SHM_BUFFER_H_
#include <wayland-client.h>
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_subsurface.h" #include "ui/ozone/platform/wayland/host/wayland_subsurface.h"
#include <wayland-client.h>
#include <cstdint> #include <cstdint>
#include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/common/wayland_util.h"
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_touch.h" #include "ui/ozone/platform/wayland/host/wayland_touch.h"
#include <wayland-client.h>
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/common/wayland_util.h"
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "ui/ozone/platform/wayland/host/wayland_window.h" #include "ui/ozone/platform/wayland/host/wayland_window.h"
#include <wayland-client.h>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
......
...@@ -57,8 +57,7 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd, ...@@ -57,8 +57,7 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(base::ScopedFD fd,
// It's possible to avoid waiting until the buffer is created and have it // It's possible to avoid waiting until the buffer is created and have it
// immediately. This method is only available since the protocol version 3. // immediately. This method is only available since the protocol version 3.
if (zwp_linux_dmabuf_v1_get_version(zwp_linux_dmabuf_.get()) >= if (wl::get_version_of_object(zwp_linux_dmabuf_.get()) >= kImmedVerstion) {
kImmedVerstion) {
wl::Object<wl_buffer> buffer(zwp_linux_buffer_params_v1_create_immed( wl::Object<wl_buffer> buffer(zwp_linux_buffer_params_v1_create_immed(
params, size.width(), size.height(), format, 0)); params, size.width(), size.height(), format, 0));
std::move(callback).Run(std::move(buffer)); std::move(callback).Run(std::move(buffer));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment