Skip to content

Commit

Permalink
Added patch that lets chromium-ozone-wayland track additional Wayland…
Browse files Browse the repository at this point in the history
… seats, i.e. in the case of VNC/RDP

Tested with desktop-shell for main compositor, and fullscreen-shell for VNC compositor.
  • Loading branch information
Lachlan-Frawley committed Jun 24, 2023
1 parent b279a4d commit a0c7258
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions meta-chromium/recipes-browser/chromium/chromium-gn.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SRC_URI += " \
file://0024-Backport-Fix-erroneous-SupportsOstreamOperator-int-i.patch \
file://0025-Backport-Do-not-use-std-monospace-for-absl-variant.patch \
file://0026-Backport-std-string-ends_with-is-C-20.-Use-base-Ends.patch \
file://0027-Track-Wayland-seats-other-than-primary.patch \
"

SRC_URI:append:libc-musl = "\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From d2f5a74f9d9afc5bbbb550570b972fb5784e0b09 Mon Sep 17 00:00:00 2001
From: Lachlan Frawley <[email protected]>
Date: Thu, 22 Jun 2023 22:38:29 +0000
Subject: [PATCH] Track Wayland seats other than primary

---
.../wayland/host/wayland_connection.cc | 7 ++++++
.../wayland/host/wayland_connection.h | 1 +
.../platform/wayland/host/wayland_seat.cc | 24 ++++++++++++++-----
3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc
index f04dbf016..01005d419 100644
--- a/ui/ozone/platform/wayland/host/wayland_connection.cc
+++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
@@ -609,6 +609,13 @@ void WaylandConnection::GlobalRemove(void* data,
wl_registry* registry,
uint32_t name) {
auto* connection = static_cast<WaylandConnection*>(data);
+
+ // We track the names of seats locally
+ auto extra_seat_it = connection->extra_seats_.find(name);
+ if(extra_seat_it != connection->extra_seats_.end()) {
+ connection->extra_seats_.erase(extra_seat_it);
+ }
+
// The Wayland protocol distinguishes global objects by unique numeric names,
// which the WaylandOutputManager uses as unique output ids. But, it is only
// possible to figure out, what global object is going to be removed on the
diff --git a/ui/ozone/platform/wayland/host/wayland_connection.h b/ui/ozone/platform/wayland/host/wayland_connection.h
index c0197481b..e48f995ae 100644
--- a/ui/ozone/platform/wayland/host/wayland_connection.h
+++ b/ui/ozone/platform/wayland/host/wayland_connection.h
@@ -429,6 +429,7 @@ class WaylandConnection {
zwp_relative_pointer_manager_;
std::unique_ptr<WaylandZwpPointerGestures> zwp_pointer_gestures_;
std::unique_ptr<WaylandSeat> seat_;
+ base::flat_map<uint32_t, std::unique_ptr<WaylandSeat>> extra_seats_;
std::unique_ptr<WaylandBufferManagerHost> buffer_manager_host_;
std::unique_ptr<XdgActivation> xdg_activation_;
std::unique_ptr<XdgForeignWrapper> xdg_foreign_;
diff --git a/ui/ozone/platform/wayland/host/wayland_seat.cc b/ui/ozone/platform/wayland/host/wayland_seat.cc
index 061e0560d..08b4b1380 100644
--- a/ui/ozone/platform/wayland/host/wayland_seat.cc
+++ b/ui/ozone/platform/wayland/host/wayland_seat.cc
@@ -33,8 +33,9 @@ void WaylandSeat::Instantiate(WaylandConnection* connection,
CHECK_EQ(interface, kInterfaceName) << "Expected \"" << kInterfaceName
<< "\" but got \"" << interface << "\"";

- if (connection->seat_ ||
- !wl::CanBind(interface, version, kMinVersion, kMaxVersion)) {
+ // Only check if we can bind the interface
+ if(!wl::CanBind(interface, version, kMinVersion, kMaxVersion)) {
+ LOG(ERROR) << "Cannot bind wl_seat";
return;
}

@@ -44,11 +45,22 @@ void WaylandSeat::Instantiate(WaylandConnection* connection,
LOG(ERROR) << "Failed to bind to wl_seat global";
return;
}
- connection->seat_ = std::make_unique<WaylandSeat>(seat.release(), connection);

- // The seat is one of objects needed for data exchange. Notify the connection
- // so it might set up the rest if all other parts are in place.
- connection->CreateDataObjectsIfReady();
+ // If we have no "primary" seat, then assume whatever seat we get first is
+ // meant to be the primary seat
+ if(!connection->seat_) {
+ connection->seat_ = std::make_unique<WaylandSeat>(seat.release(), connection);
+
+ // The seat is one of objects needed for data exchange. Notify the connection
+ // so it might set up the rest if all other parts are in place.
+ connection->CreateDataObjectsIfReady();
+ } else {
+ if(connection->extra_seats_.find(name) != connection->extra_seats_.end()) {
+ LOG(ERROR) << "Seat with name already exists";
+ return;
+ }
+ connection->extra_seats_.emplace(name, std::make_unique<WaylandSeat>(seat.release(), connection));
+ }
}

WaylandSeat::WaylandSeat(wl_seat* seat, WaylandConnection* connection)
--
2.34.1

0 comments on commit a0c7258

Please sign in to comment.