0

Dynamically load libwayland-client and libwayland-egl on Linux

This is needed since some distros do not have libwayland-client
available.  If systems don't have libwayland-client, they definitely
won't have a wayland server either, so it doesn't make sense to
statically link libwayland-client, which won't make wayland work and
will only waste binary size.  Instead, this CL dynamically loads
libwayland-client if available.

Also, this CL includes some misc fixes to fix the 'ninja all' build
for Linux/ozone.

R=msisov

Bug: 1126894
Change-Id: Ice0fd0b113f5d804cd05089bfad54168d94c53e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416941
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Maksim Sisov (GMT+3) <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#810784}
This commit is contained in:
Tom Anderson
2020-09-25 21:35:23 +00:00
committed by Commit Bot
parent 4a255bbb3b
commit 63eccefc79
22 changed files with 303 additions and 134 deletions

@ -1,75 +0,0 @@
libwayland-client.so.0 libwayland-client0 #MINVER#
* Build-Depends-Package: libwayland-dev
wl_array_add@Base 1.0.2
wl_array_copy@Base 1.0.2
wl_array_init@Base 1.0.2
wl_array_release@Base 1.0.2
wl_buffer_interface@Base 1.0.2
wl_callback_interface@Base 1.0.2
wl_compositor_interface@Base 1.0.2
wl_data_device_interface@Base 1.0.2
wl_data_device_manager_interface@Base 1.0.2
wl_data_offer_interface@Base 1.0.2
wl_data_source_interface@Base 1.0.2
wl_display_cancel_read@Base 1.2.0
wl_display_connect@Base 1.0.2
wl_display_connect_to_fd@Base 1.0.2
wl_display_create_queue@Base 1.0.2
wl_display_disconnect@Base 1.0.2
wl_display_dispatch@Base 1.0.2
wl_display_dispatch_pending@Base 1.0.2
wl_display_dispatch_queue@Base 1.0.2
wl_display_dispatch_queue_pending@Base 1.0.2
wl_display_flush@Base 1.0.2
wl_display_get_error@Base 1.0.2
wl_display_get_fd@Base 1.0.2
wl_display_get_protocol_error@Base 1.5.91
wl_display_interface@Base 1.0.2
wl_display_prepare_read@Base 1.2.0
wl_display_prepare_read_queue@Base 1.2.0
wl_display_read_events@Base 1.2.0
wl_display_roundtrip@Base 1.0.2
wl_display_roundtrip_queue@Base 1.5.91
wl_event_queue_destroy@Base 1.0.2
wl_keyboard_interface@Base 1.0.2
wl_list_empty@Base 1.0.2
wl_list_init@Base 1.0.2
wl_list_insert@Base 1.0.2
wl_list_insert_list@Base 1.0.2
wl_list_length@Base 1.0.2
wl_list_remove@Base 1.0.2
wl_log_set_handler_client@Base 1.0.2
wl_output_interface@Base 1.0.2
wl_pointer_interface@Base 1.0.2
wl_proxy_add_dispatcher@Base 1.3.0
wl_proxy_add_listener@Base 1.0.2
wl_proxy_create@Base 1.0.2
wl_proxy_create_wrapper@Base 1.11.0
wl_proxy_destroy@Base 1.0.2
wl_proxy_get_class@Base 1.1.0
wl_proxy_get_id@Base 1.0.2
wl_proxy_get_listener@Base 1.3.0
wl_proxy_get_tag@Base 1.17.93
wl_proxy_get_user_data@Base 1.0.2
wl_proxy_get_version@Base 1.9.91
wl_proxy_marshal@Base 1.0.2
wl_proxy_marshal_array@Base 1.3.0
wl_proxy_marshal_array_constructor@Base 1.3.92
wl_proxy_marshal_array_constructor_versioned@Base 1.9.91
wl_proxy_marshal_constructor@Base 1.3.92
wl_proxy_marshal_constructor_versioned@Base 1.9.91
wl_proxy_set_queue@Base 1.0.2
wl_proxy_set_tag@Base 1.17.93
wl_proxy_set_user_data@Base 1.0.2
wl_proxy_wrapper_destroy@Base 1.11.0
wl_region_interface@Base 1.0.2
wl_registry_interface@Base 1.0.2
wl_seat_interface@Base 1.0.2
wl_shell_interface@Base 1.0.2
wl_shell_surface_interface@Base 1.0.2
wl_shm_interface@Base 1.0.2
wl_shm_pool_interface@Base 1.0.2
wl_subcompositor_interface@Base 1.3.92
wl_subsurface_interface@Base 1.3.92
wl_surface_interface@Base 1.0.2
wl_touch_interface@Base 1.0.2

@ -326,22 +326,16 @@ HacksAndPatchesCommon() {
sed -i -e 's|/usr/lib/${arch}-${os}/||g' ${lscripts}
sed -i -e 's|/lib/${arch}-${os}/||g' ${lscripts}
# Unversion libdbus, libxkbcommon, and libwayland-client symbols.
# This is required because libdbus-1-3, libwayland-client0 and
# libxkbcommon0 switched from unversioned symbols to versioned
# ones, and we must still support distros using the unversioned library.
# This hack can be removed once support for Ubuntu Trusty and Debian
# Jessie are dropped.
# Unversion libdbus and libxkbcommon symbols. This is required because
# libdbus-1-3 and libxkbcommon0 switched from unversioned symbols to versioned
# ones, and we must still support distros using the unversioned library. This
# hack can be removed once support for Ubuntu Trusty and Debian Jessie are
# dropped.
${strip} -R .gnu.version_d -R .gnu.version \
"${INSTALL_ROOT}/lib/${arch}-${os}/libdbus-1.so.3"
cp "${SCRIPT_DIR}/libdbus-1-3-symbols" \
"${INSTALL_ROOT}/debian/libdbus-1-3/DEBIAN/symbols"
${strip} -R .gnu.version_d -R .gnu.version \
"${INSTALL_ROOT}/usr/lib/${arch}-${os}/libwayland-client.so.0.3.0"
cp "${SCRIPT_DIR}/libwayland-client-symbols" \
"${INSTALL_ROOT}/debian/libwayland-client0/DEBIAN/symbols"
${strip} -R .gnu.version_d -R .gnu.version \
"${INSTALL_ROOT}/usr/lib/${arch}-${os}/libxkbcommon.so.0.0.0"
cp "${SCRIPT_DIR}/libxkbcommon0-symbols" \

@ -21,7 +21,6 @@
"libpangocairo-1.0-0": "1.42.4-7~deb10u1",
"libstdc++6": "8.3.0-6",
"libuuid1": "2.33.1-0.1",
"libwayland-client0": "1.16.0-1",
"libx11-6": "2:1.6.7-1",
"libx11-xcb1": "2:1.6.7-1",
"libxcb-dri3-0": "1.13.1-2",
@ -60,7 +59,6 @@
"libpangocairo-1.0-0": "1.36.8-3",
"libstdc++6": "4.9.2-10+deb8u2",
"libuuid1": "2.25.2-6",
"libwayland-client0": "1.6.0-2",
"libx11-6": "2:1.6.2-3+deb8u2",
"libx11-xcb1": "2:1.6.2-3+deb8u2",
"libxcb-dri3-0": "1.10-3+b1",
@ -99,7 +97,6 @@
"libpangocairo-1.0-0": "1.40.5-1",
"libstdc++6": "6.3.0-18+deb9u1",
"libuuid1": "2.29.2-1+deb9u1",
"libwayland-client0": "1.12.0-1+deb9u1",
"libx11-6": "2:1.6.4-3+deb9u2",
"libx11-xcb1": "2:1.6.4-3+deb9u2",
"libxcb-dri3-0": "1.12-1",
@ -138,7 +135,6 @@
"libpangocairo-1.0-0": "1.36.3-1ubuntu1.1",
"libstdc++6": "4.8.4-2ubuntu1~14.04.4",
"libuuid1": "2.20.1-5.1ubuntu20.9",
"libwayland-client0": "1.4.0-1ubuntu1.1",
"libx11-6": "2:1.6.2-1ubuntu2.1",
"libx11-xcb1": "2:1.6.2-1ubuntu2.1",
"libxcb-dri3-0": "1.10-2ubuntu1",
@ -177,7 +173,6 @@
"libpangocairo-1.0-0": "1.38.1-1",
"libstdc++6": "5.4.0-6ubuntu1~16.04.12",
"libuuid1": "2.27.1-6ubuntu3.10",
"libwayland-client0": "1.12.0-1~ubuntu16.04.3",
"libx11-6": "2:1.6.3-1ubuntu2.1",
"libx11-xcb1": "2:1.6.3-1ubuntu2.1",
"libxcb-dri3-0": "1.11.1-1ubuntu1",
@ -216,7 +211,6 @@
"libpangocairo-1.0-0": "1.40.14-1ubuntu0.1",
"libstdc++6": "8.4.0-1ubuntu1~18.04",
"libuuid1": "2.31.1-0.4ubuntu3.6",
"libwayland-client0": "1.16.0-1ubuntu1.1~18.04.3",
"libx11-6": "2:1.6.4-3ubuntu0.1",
"libx11-xcb1": "2:1.6.4-3ubuntu0.1",
"libxcb-dri3-0": "1.13-2~ubuntu18.04",
@ -255,7 +249,6 @@
"libpangocairo-1.0-0": "1.42.4-7",
"libstdc++6": "9.2.1-9ubuntu2",
"libuuid1": "2.34-0.1ubuntu2.4",
"libwayland-client0": "1.17.0-1",
"libx11-6": "2:1.6.8-1",
"libx11-xcb1": "2:1.6.8-1",
"libxcb-dri3-0": "1.13.1-2",
@ -294,7 +287,6 @@
"libpangocairo-1.0-0": "1.44.7-2ubuntu4",
"libstdc++6": "10-20200411-0ubuntu1",
"libuuid1": "2.34-0.1ubuntu9",
"libwayland-client0": "1.18.0-1",
"libx11-6": "2:1.6.9-2ubuntu1",
"libx11-xcb1": "2:1.6.9-2ubuntu1",
"libxcb-dri3-0": "1.14-2",

@ -57,7 +57,6 @@ PACKAGE_FILTER = set([
"libpangocairo-1.0-0",
"libstdc++6",
"libuuid1",
"libwayland-client0",
"libx11-6",
"libx11-xcb1",
"libxkbcommon0",

@ -270,7 +270,6 @@
"libuuid.so.1(UUID_1.0)(64bit)",
"libuuid.so.1(UUID_2.20)(64bit)",
"libuuid.so.1(UUID_2.31)(64bit)",
"libwayland-client.so.0()(64bit)",
"libxcb-dri3.so.0()(64bit)",
"libxcb.so.1()(64bit)",
"libxkbcommon.so.0()(64bit)",
@ -546,7 +545,6 @@
"libuuid.so.1(UUID_1.0)(64bit)",
"libuuid.so.1(UUID_2.20)(64bit)",
"libuuid.so.1(UUID_2.31)(64bit)",
"libwayland-client.so.0()(64bit)",
"libxcb-dri3.so.0()(64bit)",
"libxcb.so.1()(64bit)",
"libxkbcommon.so.0()(64bit)",
@ -1085,8 +1083,6 @@
"libuuid.so.1(UUID_2.20)(64bit)",
"libuuid.so.1(UUID_2.31)",
"libuuid.so.1(UUID_2.31)(64bit)",
"libwayland-client.so.0",
"libwayland-client.so.0()(64bit)",
"libxcb-dri3.so.0",
"libxcb-dri3.so.0()(64bit)",
"libxcb.so.1",
@ -1632,8 +1628,6 @@
"libuuid.so.1(UUID_2.20)(64bit)",
"libuuid.so.1(UUID_2.31)",
"libuuid.so.1(UUID_2.31)(64bit)",
"libwayland-client.so.0",
"libwayland-client.so.0()(64bit)",
"libxcb-dri3.so.0",
"libxcb-dri3.so.0()(64bit)",
"libxcb.so.1",

@ -58,7 +58,6 @@ LIBRARY_FILTER = set([
"libsmime3.so",
"libstdc++.so",
"libuuid.so",
"libwayland-client.so",
"libxkbcommon.so.0",
"libxcb.so",
"libxcb-dri3.so.0",

@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/linux/pkg_config.gni")
import("//third_party/wayland/features.gni")
import("//tools/generate_stubs/rules.gni")
if (!use_system_libwayland) {
config("wayland_config") {
@ -117,7 +118,9 @@ if (!use_system_libwayland) {
public_configs = [ ":wayland_config" ]
}
}
if (!use_system_wayland_scanner) {
config("wayland_scanner_config") {
cflags = [
"-Wno-int-conversion",
@ -171,4 +174,41 @@ if (use_system_libwayland) {
group("wayland_egl") {
public_configs = [ ":wayland_egl_config" ]
}
generate_stubs("wayland_wrappers") {
visibility = [ ":wayland_stubs" ]
extra_header = "stubs/libwayland.fragment"
sigs = [
"stubs/libwayland-client.sigs",
"stubs/libwayland-egl.sigs",
]
output_name = "libwayland_stubs"
deps = [ "//base" ]
}
# This is a source_set, not a component, because we don't want to leak
# our own wayland symbols in component builds, which can interfere with
# the system libEGL's usage of wayland.
source_set("wayland_stubs") {
public_deps = [ ":wayland_wrappers" ]
sources = [
# Provide data symbols which generate_stubs.py cannot wrap -- only
# functions are wrappable. wayland-protocol.c contains only data and
# no code.
"protocol/wayland-protocol.c",
# Provide implementations of C variadic functions, which
# generate_stubs.py cannot generate forwarding-functions for.
"stubs/libwayland_variadic_support.cc",
]
# This is a hack to hide the symbols annoted with
# attribute((visibility("default"))) in wayland-protocol.c since libwayland
# currently doesn't provide a way to override this behavior. This can be
# removed once https://gitlab.freedesktop.org/wayland/wayland/-/issues/179
# is fixed and we can switch to overriding WL_EXPORT directly.
defines = [ "visibility(x)=visibility(\"hidden\")" ]
}
}

@ -2,12 +2,21 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/ui_mode.gni")
declare_args() {
# Controls whether the build should use the version of Wayland
# library shipped with the system or Chromium third_party.
use_system_libwayland = false
use_system_libwayland =
is_desktop_linux && !is_chromecast && !chromeos_is_browser_only &&
default_toolchain != "//build/toolchain/cros:target"
# Path to wayland-scanner. Has effect only when the system libwayland is used.
assert(host_os == "linux")
system_wayland_scanner_path = "/usr/bin/wayland-scanner"
# This may be set by Chromium packagers who do not wish to use the bundled
# wayland scanner.
use_system_wayland_scanner = false
}

@ -0,0 +1,44 @@
// These signatures are obtained by hand from wayland-client-core.h.
void wl_event_queue_destroy(struct wl_event_queue* queue);
void wl_proxy_marshal_array(struct wl_proxy* p, uint32_t opcode, union wl_argument* args);
struct wl_proxy* wl_proxy_create(struct wl_proxy* factory, const struct wl_interface* interface);
void* wl_proxy_create_wrapper(void* proxy);
void wl_proxy_wrapper_destroy(void* proxy_wrapper);
struct wl_proxy* wl_proxy_marshal_array_constructor(struct wl_proxy* proxy, uint32_t opcode, union wl_argument* args, const struct wl_interface* interface);
struct wl_proxy* wl_proxy_marshal_array_constructor_versioned(struct wl_proxy* proxy, uint32_t opcode, union wl_argument* args, const struct wl_interface* interface, uint32_t version);
void wl_proxy_destroy(struct wl_proxy* proxy);
int wl_proxy_add_listener(struct wl_proxy* proxy, wl_proxy_listener_impl implementation, void* data);
const void* wl_proxy_get_listener(struct wl_proxy* proxy);
int wl_proxy_add_dispatcher(struct wl_proxy* proxy, wl_dispatcher_func_t dispatcher_func, const void* dispatcher_data, void* data);
void wl_proxy_set_user_data(struct wl_proxy* proxy, void* user_data);
void* wl_proxy_get_user_data(struct wl_proxy* proxy);
uint32_t wl_proxy_get_version(struct wl_proxy* proxy);
uint32_t wl_proxy_get_id(struct wl_proxy* proxy);
const char* wl_proxy_get_class(struct wl_proxy* proxy);
void wl_proxy_set_queue(struct wl_proxy* proxy, struct wl_event_queue* queue);
struct wl_display* wl_display_connect(const char* name);
struct wl_display* wl_display_connect_to_fd(int fd);
void wl_display_disconnect(struct wl_display* display);
int wl_display_get_fd(struct wl_display* display);
int wl_display_dispatch(struct wl_display* display);
int wl_display_dispatch_queue(struct wl_display* display, struct wl_event_queue* queue);
int wl_display_dispatch_queue_pending(struct wl_display* display, struct wl_event_queue* queue);
int wl_display_dispatch_pending(struct wl_display* display);
int wl_display_get_error(struct wl_display* display);
uint32_t wl_display_get_protocol_error(struct wl_display* display, const struct wl_interface** interface, uint32_t* id);
int wl_display_flush(struct wl_display* display);
int wl_display_roundtrip_queue(struct wl_display* display, struct wl_event_queue* queue);
int wl_display_roundtrip(struct wl_display* display);
struct wl_event_queue* wl_display_create_queue(struct wl_display* display);
int wl_display_prepare_read_queue(struct wl_display* display, struct wl_event_queue* queue);
int wl_display_prepare_read(struct wl_display* display);
void wl_display_cancel_read(struct wl_display* display);
int wl_display_read_events(struct wl_display* display);
void wl_log_set_handler_client(wl_log_func_t handler);
// generate_stubs cannot generate forwarding functions for variadic functions.
// These are left commented here for completeness.
// void wl_proxy_marshal(struct wl_proxy* p, uint32_t opcode, ...);
// struct wl_proxy* wl_proxy_marshal_constructor(struct wl_proxy* proxy, uint32_t opcode, const struct wl_interface* interface, ...);
// struct wl_proxy* wl_proxy_marshal_constructor_versioned(struct wl_proxy* proxy, uint32_t opcode, const struct wl_interface* interface, uint32_t version, ...);

@ -0,0 +1,6 @@
// These signatures are obtained by hand from wayland-egl-core.h.
struct wl_egl_window * wl_egl_window_create(struct wl_surface *surface, int width, int height);
void wl_egl_window_destroy(struct wl_egl_window *egl_window);
void wl_egl_window_resize(struct wl_egl_window *egl_window, int width, int height, int dx, int dy);
void wl_egl_window_get_attached_size(struct wl_egl_window *egl_window, int *width, int *height);

@ -0,0 +1,11 @@
// The extra include header needed in the generated stub file for defining
// various libwayland types.
extern "C" {
#include <wayland-client.h>
}
// generate_stubs.py has trouble parsing function pointers, so use an alias.
using wl_proxy_listener_impl = void (**)(void);

@ -0,0 +1,139 @@
// 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.
// This file contains a subset of wayland's connection.c. It's necessary to
// provide implementations of variadic functions which generate_stubs.py cannot
// generate forwarding functions for. Fortunately, libwayland-client exposes
// non-variadic equivalents for these functions that we can forward to.
#include <wayland-client.h>
#include <wayland-server.h>
#include <cstdarg>
#include <cstdint>
#define WL_CLOSURE_MAX_ARGS 20
extern "C" {
struct argument_details {
char type;
int nullable;
};
const char* get_next_argument(const char* signature,
struct argument_details* details) {
details->nullable = 0;
for (; *signature; ++signature) {
switch (*signature) {
case 'i':
case 'u':
case 'f':
case 's':
case 'o':
case 'n':
case 'a':
case 'h':
details->type = *signature;
return signature + 1;
case '?':
details->nullable = 1;
}
}
details->type = '\0';
return signature;
}
void wl_argument_from_va_list(const char* signature,
union wl_argument* args,
int count,
va_list ap) {
int i;
const char* sig_iter;
struct argument_details arg;
sig_iter = signature;
for (i = 0; i < count; i++) {
sig_iter = get_next_argument(sig_iter, &arg);
switch (arg.type) {
case 'i':
args[i].i = va_arg(ap, int32_t);
break;
case 'u':
args[i].u = va_arg(ap, uint32_t);
break;
case 'f':
args[i].f = va_arg(ap, wl_fixed_t);
break;
case 's':
args[i].s = va_arg(ap, const char*);
break;
case 'o':
args[i].o = va_arg(ap, struct wl_object*);
break;
case 'n':
args[i].o = va_arg(ap, struct wl_object*);
break;
case 'a':
args[i].a = va_arg(ap, struct wl_array*);
break;
case 'h':
args[i].h = va_arg(ap, int32_t);
break;
case '\0':
return;
}
}
}
void wl_proxy_marshal(struct wl_proxy* proxy, uint32_t opcode, ...) {
union wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, opcode);
wl_argument_from_va_list(
reinterpret_cast<wl_object*>(proxy)->interface->methods[opcode].signature,
args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);
wl_proxy_marshal_array_constructor(proxy, opcode, args, nullptr);
}
struct wl_proxy* wl_proxy_marshal_constructor(
struct wl_proxy* proxy,
uint32_t opcode,
const struct wl_interface* interface,
...) {
union wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, interface);
wl_argument_from_va_list(
reinterpret_cast<wl_object*>(proxy)->interface->methods[opcode].signature,
args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);
return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface);
}
struct wl_proxy* wl_proxy_marshal_constructor_versioned(
struct wl_proxy* proxy,
uint32_t opcode,
const struct wl_interface* interface,
uint32_t version,
...) {
union wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, version);
wl_argument_from_va_list(
reinterpret_cast<wl_object*>(proxy)->interface->methods[opcode].signature,
args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);
return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, args,
interface, version);
}
}

@ -52,7 +52,7 @@ template("wayland_protocol") {
rebase_path(root_gen_dir, root_build_dir),
]
if (use_system_libwayland) {
if (use_system_wayland_scanner) {
args += [
"--cmd",
system_wayland_scanner_path,

@ -33,11 +33,17 @@ def main(argv):
root_gen_dir = options.root_gen_dir
protocols = options.protocols
version = subprocess.check_output([cmd, '--version'],
stderr=subprocess.STDOUT)
# The version is of the form "wayland-scanner 1.18.0\n"
version = tuple([int(x) for x in version.strip().split(' ')[1].split('.')])
for protocol in protocols:
protocol_path = os.path.join(src_root, protocol)
protocol_without_extension = protocol.rsplit(".", 1)[0]
out_base_name = os.path.join(root_gen_dir, protocol_without_extension)
generate_code(cmd, "private-code", protocol_path,
code_cmd = 'private-code' if version > (1, 14, 90) else 'code'
generate_code(cmd, code_cmd, protocol_path,
out_base_name + "-protocol.c")
generate_code(cmd, "client-header", protocol_path,
out_base_name + "-client-protocol.h")

@ -232,7 +232,8 @@ source_set("clipboard_test") {
]
}
if (use_aura && !chromeos_is_browser_only && !use_x11 && !is_win) {
if (use_aura && !chromeos_is_browser_only && !use_x11 && !is_win &&
!use_ozone) {
sources += [
"clipboard_data_unittest.cc",
"clipboard_non_backed_unittest.cc",

@ -52,7 +52,7 @@
#include "ui/base/clipboard/clipboard_util_win.h"
#endif
#if defined(USE_X11)
#if defined(USE_X11) || defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/events/platform/platform_event_source.h"
#endif

@ -8,6 +8,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/linux/pkg_config.gni")
import("//gpu/vulkan/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/wayland/features.gni")
import("//ui/ozone/platform/wayland/wayland.gni")
source_set("wayland") {
@ -150,7 +151,6 @@ source_set("wayland") {
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//skia",
"//third_party/wayland:wayland_egl",
"//third_party/wayland-protocols:gtk_primary_selection_protocol",
"//third_party/wayland-protocols:keyboard_extension_protocol",
"//third_party/wayland-protocols:linux_dmabuf_protocol",
@ -185,18 +185,6 @@ source_set("wayland") {
"//ui/platform_window/wm",
]
# TODO(msisov): we should do the following once support for Trusty and Jessie
# are dropped:
# 1. Remove libs=["wayland-client"] and
# add deps+=["//third_party/wayland:wayland_client"]
# 2. Set use_system_libwayland=true for is_desktop_linux.
libs = []
if (!is_chromeos) {
libs = [ "wayland-client" ]
} else {
deps += [ "//third_party/wayland:wayland_client" ]
}
if (is_linux && !is_chromeos) {
deps += [ "//ui/base/ime/linux" ]
}
@ -214,6 +202,16 @@ source_set("wayland") {
defines = [ "OZONE_IMPLEMENTATION" ]
if (use_system_libwayland) {
defines += [ "USE_LIBWAYLAND_STUBS" ]
deps += [ "//third_party/wayland:wayland_stubs" ]
} else {
deps += [
"//third_party/wayland:wayland_client",
"//third_party/wayland:wayland_egl",
]
}
if (use_wayland_gbm) {
defines += [ "WAYLAND_GBM" ]
sources += [

@ -4,6 +4,7 @@ include_rules = [
"+ui/base/ui_base_features.h",
"+ui/gtk/gtk_ui_delegate.h",
"+mojo/public",
"+third_party/wayland",
"+ui/base/clipboard/clipboard_constants.h",
"+ui/base/dragdrop/drag_drop_types.h",
"+ui/base/dragdrop/file_info/file_info.h",

@ -10,7 +10,7 @@ void* bind_registry(struct wl_registry* registry,
uint32_t name,
const struct wl_interface* interface,
uint32_t version) {
if (wl_proxy_marshal_constructor_versioned) {
if (dlsym(RTLD_DEFAULT, "wl_proxy_marshal_constructor_versioned")) {
return wl_registry_bind(registry, name, interface, version);
} else {
return wl_proxy_marshal_constructor(reinterpret_cast<wl_proxy*>(registry),

@ -5,27 +5,17 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_H_
#define UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_H_
#include <dlfcn.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)
if (dlsym(RTLD_DEFAULT, "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;

@ -40,6 +40,12 @@
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
#include "ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h"
#if defined(USE_LIBWAYLAND_STUBS)
#include <dlfcn.h>
#include "third_party/wayland/libwayland_stubs.h" // nogncheck
#endif
namespace ui {
namespace {
@ -66,6 +72,21 @@ WaylandConnection::WaylandConnection() = default;
WaylandConnection::~WaylandConnection() = default;
bool WaylandConnection::Initialize() {
#if defined(USE_LIBWAYLAND_STUBS)
// Use RTLD_NOW to load all symbols, since the stubs will try to load all of
// them anyway. Use RTLD_GLOBAL to add the symbols to the global namespace.
auto dlopen_flags = RTLD_NOW | RTLD_GLOBAL;
if (void* libwayland_client =
dlopen("libwayland-client.so.0", dlopen_flags)) {
third_party_wayland::InitializeLibwaylandclient(libwayland_client);
} else {
LOG(ERROR) << "Failed to load wayland client libraries.";
return false;
}
if (void* libwayland_egl = dlopen("libwayland-egl.so.1", dlopen_flags))
third_party_wayland::InitializeLibwaylandegl(libwayland_egl);
#endif
static const wl_registry_listener registry_listener = {
&WaylandConnection::Global,
&WaylandConnection::GlobalRemove,

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/x/xproto.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/aura/client/aura_constants.h"
@ -24,6 +23,7 @@
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/xproto.h"
#include "ui/views/controls/textfield/textfield.h"
#endif // defined(USE_X11)