Commit 1b849b41 authored by James Cook's avatar James Cook Committed by Commit Bot

ozone/wayland: Bind zcr_cursor_shapes interface if available

The Chrome OS exo Wayland server provides the zcr_cursor_shapes_v1
interface to allow clients to request server-side cursor shapes. Bind
the interface and wrap it in a WaylandZcrCursorShapes class.

Future CLs will use the interface for cursors for Lacros.

Bug: 1143790
Change-Id: Ib6224e6ef5945f9e2f7403b0afd38a53611a88c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518765Reviewed-by: default avatarAntonio Gomes <tonikitoo@igalia.com>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823804}
parent 206db165
......@@ -128,6 +128,8 @@ source_set("wayland") {
"host/wayland_window_observer.h",
"host/wayland_zaura_shell.cc",
"host/wayland_zaura_shell.h",
"host/wayland_zcr_cursor_shapes.cc",
"host/wayland_zcr_cursor_shapes.h",
"host/wayland_zwp_linux_dmabuf.cc",
"host/wayland_zwp_linux_dmabuf.h",
"host/xdg_foreign_wrapper.cc",
......@@ -162,6 +164,7 @@ source_set("wayland") {
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//skia",
"//third_party/wayland-protocols:cursor_shapes_protocol",
"//third_party/wayland-protocols:gtk_primary_selection_protocol",
"//third_party/wayland-protocols:keyboard_extension_protocol",
"//third_party/wayland-protocols:linux_dmabuf_protocol",
......
......@@ -5,6 +5,7 @@
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include <aura-shell-client-protocol.h>
#include <cursor-shapes-unstable-v1-client-protocol.h>
#include <gtk-primary-selection-client-protocol.h>
#include <keyboard-extension-unstable-v1-client-protocol.h>
#include <linux-dmabuf-unstable-v1-client-protocol.h>
......@@ -247,6 +248,11 @@ const wl_interface* ObjectTraits<zaura_surface>::interface =
void (*ObjectTraits<zaura_surface>::deleter)(zaura_surface*) =
&zaura_surface_destroy;
const wl_interface* ObjectTraits<zcr_cursor_shapes_v1>::interface =
&zcr_cursor_shapes_v1_interface;
void (*ObjectTraits<zcr_cursor_shapes_v1>::deleter)(zcr_cursor_shapes_v1*) =
&zcr_cursor_shapes_v1_destroy;
const wl_interface* ObjectTraits<zcr_keyboard_extension_v1>::interface =
&zcr_keyboard_extension_v1_interface;
void (*ObjectTraits<zcr_keyboard_extension_v1>::deleter)(
......
......@@ -48,6 +48,7 @@ struct xdg_popup;
struct xdg_positioner;
struct zaura_shell;
struct zaura_surface;
struct zcr_cursor_shapes_v1;
struct zcr_keyboard_extension_v1;
struct zcr_extended_keyboard_v1;
struct zwp_linux_dmabuf_v1;
......@@ -323,6 +324,12 @@ struct ObjectTraits<zaura_surface> {
static void (*deleter)(zaura_surface*);
};
template <>
struct ObjectTraits<zcr_cursor_shapes_v1> {
static const wl_interface* interface;
static void (*deleter)(zcr_cursor_shapes_v1*);
};
template <>
struct ObjectTraits<zcr_keyboard_extension_v1> {
static const wl_interface* interface;
......
......@@ -38,6 +38,7 @@
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window_drag_controller.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_shell.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h"
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
#include "ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h"
#include "ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.h"
......@@ -52,6 +53,7 @@ namespace ui {
namespace {
constexpr uint32_t kMaxCompositorVersion = 4;
constexpr uint32_t kMaxCursorShapesVersion = 1;
constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1;
constexpr uint32_t kMaxKeyboardExtensionVersion = 1;
constexpr uint32_t kMaxLinuxDmabufVersion = 3;
......@@ -392,6 +394,16 @@ void WaylandConnection::Global(void* data,
(strcmp(interface, "wp_viewporter") == 0)) {
connection->viewporter_ =
wl::Bind<wp_viewporter>(registry, name, kMaxWpViewporterVersion);
} else if (!connection->zcr_cursor_shapes_ &&
strcmp(interface, "zcr_cursor_shapes_v1") == 0) {
auto zcr_cursor_shapes =
wl::Bind<zcr_cursor_shapes_v1>(registry, name, kMaxCursorShapesVersion);
if (!zcr_cursor_shapes) {
LOG(ERROR) << "Failed to bind zcr_cursor_shapes_v1";
return;
}
connection->zcr_cursor_shapes_ = std::make_unique<WaylandZcrCursorShapes>(
zcr_cursor_shapes.release(), connection);
} else if (!connection->keyboard_extension_v1_ &&
strcmp(interface, "zcr_keyboard_extension_v1") == 0) {
connection->keyboard_extension_v1_ = wl::Bind<zcr_keyboard_extension_v1>(
......
......@@ -32,6 +32,7 @@ class WaylandPointer;
class WaylandShm;
class WaylandTouch;
class WaylandZAuraShell;
class WaylandZcrCursorShapes;
class WaylandZwpLinuxDmabuf;
class WaylandDataDeviceManager;
class WaylandCursorPosition;
......@@ -120,6 +121,10 @@ class WaylandConnection {
WaylandZAuraShell* zaura_shell() const { return zaura_shell_.get(); }
WaylandZcrCursorShapes* zcr_cursor_shapes() const {
return zcr_cursor_shapes_.get();
}
WaylandZwpLinuxDmabuf* zwp_dmabuf() const { return zwp_dmabuf_.get(); }
WaylandDrm* drm() const { return drm_.get(); }
......@@ -220,6 +225,7 @@ class WaylandConnection {
std::unique_ptr<WaylandOutputManager> wayland_output_manager_;
std::unique_ptr<WaylandCursorPosition> wayland_cursor_position_;
std::unique_ptr<WaylandZAuraShell> zaura_shell_;
std::unique_ptr<WaylandZcrCursorShapes> zcr_cursor_shapes_;
std::unique_ptr<WaylandZwpLinuxDmabuf> zwp_dmabuf_;
std::unique_ptr<WaylandDrm> drm_;
std::unique_ptr<WaylandShm> shm_;
......
// 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/host/wayland_zcr_cursor_shapes.h"
#include "base/check.h"
namespace ui {
WaylandZcrCursorShapes::WaylandZcrCursorShapes(
zcr_cursor_shapes_v1* zcr_cursor_shapes,
WaylandConnection* connection)
: zcr_cursor_shapes_v1_(zcr_cursor_shapes), connection_(connection) {
DCHECK(zcr_cursor_shapes_v1_);
DCHECK(connection_);
}
WaylandZcrCursorShapes::~WaylandZcrCursorShapes() = default;
} // namespace ui
// 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_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
#include "ui/ozone/platform/wayland/common/wayland_object.h"
namespace ui {
class WaylandConnection;
// Wraps the zcr_cursor_shapes interface for Wayland (exo) server-side cursor
// support. Exists to support Lacros, which uses server-side cursors for
// consistency with ARC++ and for accessibility support.
class WaylandZcrCursorShapes {
public:
WaylandZcrCursorShapes(zcr_cursor_shapes_v1* zcr_cursor_shapes,
WaylandConnection* connection);
WaylandZcrCursorShapes(const WaylandZcrCursorShapes&) = delete;
WaylandZcrCursorShapes& operator=(const WaylandZcrCursorShapes&) = delete;
~WaylandZcrCursorShapes();
private:
wl::Object<zcr_cursor_shapes_v1> zcr_cursor_shapes_v1_;
WaylandConnection* const connection_;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
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