Skip to content

Commit

Permalink
cherrypick to M113: Revert "Removes zxdg_shell"
Browse files Browse the repository at this point in the history
This reverts commit 37647e0.

Reason for revert: b/273702996. Parallels uses zxdg_shell :/

Bug: b:273702996
Fixes: b:273702996

Original change's description:
> Removes zxdg_shell
>
> Sommelier has stopped using this and Lacros doesn't use it so it doesn't seem like it's being used anywhere
>
> Bug: N/A
> Change-Id: I4e9daf3b4a39de3d19cac83c3f89c16ec4b93cca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4305659
> Commit-Queue: Justin Huang <justinhuang@google.com>
> Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1113197}

(cherry picked from commit cee6ba3)

Bug: N/A
Change-Id: I9ac23cafd88f1717ed78ec60fb4b04d3101f4365
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4369248
Commit-Queue: Justin Huang <justinhuang@google.com>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1122780}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4378700
Cr-Commit-Position: refs/branch-heads/5672@{#92}
Cr-Branched-From: 5f2a724-refs/heads/main@{#1121455}
  • Loading branch information
Justin Huang authored and Chromium LUCI CQ committed Mar 29, 2023
1 parent 6b9fbf0 commit 1433028
Show file tree
Hide file tree
Showing 21 changed files with 1,153 additions and 49 deletions.
2 changes: 2 additions & 0 deletions components/exo/wayland/BUILD.gn
Expand Up @@ -132,6 +132,8 @@ source_set("wayland") {
"zxdg_decoration_manager.h",
"zxdg_output_manager.cc",
"zxdg_output_manager.h",
"zxdg_shell.cc",
"zxdg_shell.h",
]

defines = [ "EXO_IMPLEMENTATION" ]
Expand Down
80 changes: 58 additions & 22 deletions components/exo/wayland/clients/client_base.cc
Expand Up @@ -619,29 +619,65 @@ bool ClientBase::Init(const InitParams& params) {
wl_shell_surface_set_toplevel(shell_surface.get());
}
} else {
xdg_surface_.reset(xdg_wm_base_get_xdg_surface(globals_.xdg_wm_base.get(),
surface_.get()));
if (!xdg_surface_) {
LOG(ERROR) << "Can't get xdg surface";
return false;
}
static const xdg_surface_listener xdg_surface_listener = {
[](void* data, struct xdg_surface* xdg_surface, uint32_t layout_mode) {
xdg_surface_ack_configure(xdg_surface, layout_mode);
},
};
xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this);
xdg_toplevel_.reset(xdg_surface_get_toplevel(xdg_surface_.get()));
if (!xdg_toplevel_) {
LOG(ERROR) << "Can't get xdg toplevel";
return false;
if (!globals_.xdg_wm_base) {
// use zxdg
if (!globals_.xdg_shell_v6) {
LOG(ERROR) << "Can't find xdg_shell or zxdg_shell_v6 interface";
return false;
}

zxdg_surface_.reset(zxdg_shell_v6_get_xdg_surface(
globals_.xdg_shell_v6.get(), surface_.get()));
if (!zxdg_surface_) {
LOG(ERROR) << "Can't get zxdg surface";
return false;
}
static const zxdg_surface_v6_listener zxdg_surface_v6_listener = {
[](void* data, struct zxdg_surface_v6* zxdg_surface_v6,
uint32_t layout_mode) {
zxdg_surface_v6_ack_configure(zxdg_surface_v6, layout_mode);
},
};
zxdg_surface_v6_add_listener(zxdg_surface_.get(),
&zxdg_surface_v6_listener, this);
zxdg_toplevel_.reset(zxdg_surface_v6_get_toplevel(zxdg_surface_.get()));
if (!zxdg_toplevel_) {
LOG(ERROR) << "Can't get zxdg toplevel";
return false;
}
static const zxdg_toplevel_v6_listener zxdg_toplevel_v6_listener = {
[](void* data, struct zxdg_toplevel_v6* zxdg_toplevel_v6,
int32_t width, int32_t height, struct wl_array* states) {},
[](void* data, struct zxdg_toplevel_v6* zxdg_toplevel_v6) {}};
zxdg_toplevel_v6_add_listener(zxdg_toplevel_.get(),
&zxdg_toplevel_v6_listener, this);
} else {
// use xdg
xdg_surface_.reset(xdg_wm_base_get_xdg_surface(globals_.xdg_wm_base.get(),
surface_.get()));
if (!xdg_surface_) {
LOG(ERROR) << "Can't get xdg surface";
return false;
}
static const xdg_surface_listener xdg_surface_listener = {
[](void* data, struct xdg_surface* xdg_surface,
uint32_t layout_mode) {
xdg_surface_ack_configure(xdg_surface, layout_mode);
},
};
xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this);
xdg_toplevel_.reset(xdg_surface_get_toplevel(xdg_surface_.get()));
if (!xdg_toplevel_) {
LOG(ERROR) << "Can't get xdg toplevel";
return false;
}
static const xdg_toplevel_listener xdg_toplevel_listener = {
[](void* data, struct xdg_toplevel* xdg_toplevel, int32_t width,
int32_t height, struct wl_array* states) {},
[](void* data, struct xdg_toplevel* xdg_toplevel) {}};
xdg_toplevel_add_listener(xdg_toplevel_.get(), &xdg_toplevel_listener,
this);
}
static const xdg_toplevel_listener xdg_toplevel_listener = {
[](void* data, struct xdg_toplevel* xdg_toplevel, int32_t width,
int32_t height, struct wl_array* states) {},
[](void* data, struct xdg_toplevel* xdg_toplevel) {}};
xdg_toplevel_add_listener(xdg_toplevel_.get(), &xdg_toplevel_listener,
this);

if (fullscreen_) {
LOG(ERROR) << "full screen not supported yet.";
Expand Down
2 changes: 2 additions & 0 deletions components/exo/wayland/clients/client_base.h
Expand Up @@ -203,6 +203,8 @@ class ClientBase {
std::unique_ptr<wl_shell_surface> shell_surface_;
std::unique_ptr<xdg_surface> xdg_surface_;
std::unique_ptr<xdg_toplevel> xdg_toplevel_;
std::unique_ptr<zxdg_surface_v6> zxdg_surface_;
std::unique_ptr<zxdg_toplevel_v6> zxdg_toplevel_;
std::unique_ptr<wl_pointer> wl_pointer_;
std::unique_ptr<zcr_pointer_stylus_v2> zcr_pointer_stylus_;
Globals globals_;
Expand Down
3 changes: 3 additions & 0 deletions components/exo/wayland/clients/client_helper.cc
Expand Up @@ -83,6 +83,7 @@ DEFAULT_DELETER(wl_data_device_manager, wl_data_device_manager_destroy)
DEFAULT_DELETER(wp_content_type_manager_v1, wp_content_type_manager_v1_destroy)
DEFAULT_DELETER(wp_content_type_v1, wp_content_type_v1_destroy)
DEFAULT_DELETER(wp_viewporter, wp_viewporter_destroy)
DEFAULT_DELETER(zxdg_shell_v6, zxdg_shell_v6_destroy)
DEFAULT_DELETER(xdg_wm_base, xdg_wm_base_destroy)
DEFAULT_DELETER(zwp_text_input_manager_v1, zwp_text_input_manager_v1_destroy)
DEFAULT_DELETER(zcr_secure_output_v1, zcr_secure_output_v1_destroy)
Expand Down Expand Up @@ -111,6 +112,8 @@ DEFAULT_DELETER(zxdg_decoration_manager_v1, zxdg_decoration_manager_v1_destroy)
DEFAULT_DELETER(zcr_extended_drag_v1, zcr_extended_drag_v1_destroy)
DEFAULT_DELETER(xdg_surface, xdg_surface_destroy)
DEFAULT_DELETER(xdg_toplevel, xdg_toplevel_destroy)
DEFAULT_DELETER(zxdg_surface_v6, zxdg_surface_v6_destroy)
DEFAULT_DELETER(zxdg_toplevel_v6, zxdg_toplevel_v6_destroy)
DEFAULT_DELETER(zxdg_output_manager_v1, zxdg_output_manager_v1_destroy)
DEFAULT_DELETER(weston_test, weston_test_destroy)
DEFAULT_DELETER(zwp_idle_inhibit_manager_v1,
Expand Down
4 changes: 4 additions & 0 deletions components/exo/wayland/clients/client_helper.h
Expand Up @@ -43,6 +43,7 @@
#include <xdg-decoration-unstable-v1-client-protocol.h>
#include <xdg-output-unstable-v1-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h>
#include "base/scoped_generic.h"

#if defined(USE_GBM)
Expand Down Expand Up @@ -105,6 +106,7 @@ DEFAULT_DELETER_FDECL(wl_data_device_manager)
DEFAULT_DELETER_FDECL(wp_content_type_manager_v1)
DEFAULT_DELETER_FDECL(wp_content_type_v1)
DEFAULT_DELETER_FDECL(wp_viewporter)
DEFAULT_DELETER_FDECL(zxdg_shell_v6)
DEFAULT_DELETER_FDECL(xdg_wm_base)
DEFAULT_DELETER_FDECL(zwp_text_input_manager_v1)
DEFAULT_DELETER_FDECL(zcr_secure_output_v1)
Expand All @@ -129,6 +131,8 @@ DEFAULT_DELETER_FDECL(zxdg_decoration_manager_v1)
DEFAULT_DELETER_FDECL(zcr_extended_drag_v1)
DEFAULT_DELETER_FDECL(xdg_surface)
DEFAULT_DELETER_FDECL(xdg_toplevel)
DEFAULT_DELETER_FDECL(zxdg_surface_v6)
DEFAULT_DELETER_FDECL(zxdg_toplevel_v6)
DEFAULT_DELETER_FDECL(zxdg_output_manager_v1)
DEFAULT_DELETER_FDECL(weston_test)
DEFAULT_DELETER_FDECL(zwp_idle_inhibit_manager_v1)
Expand Down
1 change: 1 addition & 0 deletions components/exo/wayland/clients/globals.cc
Expand Up @@ -53,6 +53,7 @@ void RegistryHandler(void* data,
BIND(wl_output, output)
BIND(zwp_linux_explicit_synchronization_v1, linux_explicit_synchronization)
BIND(zcr_vsync_feedback_v1, vsync_feedback)
BIND(zxdg_shell_v6, xdg_shell_v6)
BIND(xdg_wm_base, xdg_wm_base)
BIND(zcr_stylus_v2, stylus)
BIND(zcr_remote_shell_v1, cr_remote_shell_v1)
Expand Down
1 change: 1 addition & 0 deletions components/exo/wayland/clients/globals.h
Expand Up @@ -59,6 +59,7 @@ struct Globals {
Object<wl_touch> touch;
Object<zaura_shell> aura_shell;
Object<zaura_output> aura_output;
Object<zxdg_shell_v6> xdg_shell_v6;
Object<xdg_wm_base> xdg_wm_base;
Object<zwp_fullscreen_shell_v1> fullscreen_shell;
Object<zwp_input_timestamps_manager_v1> input_timestamps_manager;
Expand Down
38 changes: 38 additions & 0 deletions components/exo/wayland/clients/security_delegate_binding_test.cc
Expand Up @@ -7,6 +7,7 @@
#include <wayland-client.h>
#include <wayland-server.h>
#include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h>

#include "components/exo/client_controlled_shell_surface.h"
#include "components/exo/shell_surface.h"
Expand Down Expand Up @@ -109,6 +110,43 @@ TEST_F(SecurityDelegateBindingTest, XdgSurfaceHasSecurityDelegate) {
nullptr);
}

TEST_F(SecurityDelegateBindingTest, ZxdgSurfaceV6HasSecurityDelegate) {
class ClientData : public test::TestClient::CustomData {
public:
std::unique_ptr<wl_surface> surface;
std::unique_ptr<zxdg_surface_v6> zxdg_surface;
};

test::ResourceKey zxdg_surface_key;

PostToClientAndWait([&](test::TestClient* client) {
auto data = std::make_unique<ClientData>();

data->surface.reset(wl_compositor_create_surface(client->compositor()));
data->zxdg_surface.reset(zxdg_shell_v6_get_xdg_surface(
client->xdg_shell_v6(), data->surface.get()));

zxdg_surface_key =
test::client_util::GetResourceKey(data->zxdg_surface.get());

client->set_data(std::move(data));
});

EXPECT_EQ(test::server_util::GetUserDataForResource<WaylandXdgSurface>(
server_.get(), zxdg_surface_key)
->shell_surface->GetSecurityDelegate(),
server_security_delegate_);

PostToClientAndWait([](test::TestClient* client) {
// Destroy the client objects.
client->set_data(nullptr);
});

EXPECT_EQ(test::server_util::GetUserDataForResource<WaylandXdgSurface>(
server_.get(), zxdg_surface_key),
nullptr);
}

TEST_F(SecurityDelegateBindingTest, ZcrRemoteSurfaceV1HasSecurityDelegate) {
class ClientData : public test::TestClient::CustomData {
public:
Expand Down
3 changes: 3 additions & 0 deletions components/exo/wayland/clients/test/client_version_test.cc
Expand Up @@ -35,6 +35,7 @@
#include <weston-test-server-protocol.h>
#include <xdg-decoration-unstable-v1-server-protocol.h>
#include <xdg-shell-server-protocol.h>
#include <xdg-shell-unstable-v6-server-protocol.h>

#include <memory>
#include <string>
Expand Down Expand Up @@ -80,6 +81,7 @@ struct Globals {
std::unique_ptr<wl_data_device_manager> wl_data_device_manager;
std::unique_ptr<wp_content_type_manager_v1> wp_content_type_manager_v1;
std::unique_ptr<wp_viewporter> wp_viewporter;
std::unique_ptr<zxdg_shell_v6> zxdg_shell_v6;
std::unique_ptr<xdg_wm_base> xdg_wm_base;
std::unique_ptr<zwp_text_input_manager_v1> zwp_text_input_manager_v1;
std::unique_ptr<zcr_secure_output_v1> zcr_secure_output_v1;
Expand Down Expand Up @@ -174,6 +176,7 @@ void RegistryHandler(void* data,
REGISTRY_CALLBACK(wp_content_type_manager_v1,
wp_content_type_manager_v1),
REGISTRY_CALLBACK(wp_viewporter, wp_viewporter),
REGISTRY_CALLBACK(zxdg_shell_v6, zxdg_shell_v6),
REGISTRY_CALLBACK(xdg_wm_base, xdg_wm_base),
REGISTRY_CALLBACK(zwp_text_input_manager_v1,
zwp_text_input_manager_v1),
Expand Down
1 change: 1 addition & 0 deletions components/exo/wayland/compatibility_test/BUILD.gn
Expand Up @@ -20,6 +20,7 @@ server_wayland_protocols = [
"//third_party/wayland-protocols/src/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml",
"//third_party/wayland-protocols/unstable/alpha-compositing/alpha-compositing-unstable-v1.xml",
"//third_party/wayland-protocols/unstable/cursor-shapes/cursor-shapes-unstable-v1.xml",
"//third_party/wayland-protocols/unstable/gaming-input/gaming-input-unstable-v2.xml",
Expand Down
1 change: 1 addition & 0 deletions components/exo/wayland/fuzzer/BUILD.gn
Expand Up @@ -23,6 +23,7 @@ kDefaultWaylandProtocols = [
"//third_party/wayland-protocols/src/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/relative-pointer/relative-pointer-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/text-input/text-input-unstable-v1.xml",
"//third_party/wayland-protocols/src/unstable/xdg-shell/xdg-shell-unstable-v6.xml",
"//third_party/wayland-protocols/unstable/alpha-compositing/alpha-compositing-unstable-v1.xml",
"//third_party/wayland-protocols/unstable/cursor-shapes/cursor-shapes-unstable-v1.xml",
"//third_party/wayland-protocols/unstable/gaming-input/gaming-input-unstable-v2.xml",
Expand Down
20 changes: 19 additions & 1 deletion components/exo/wayland/fuzzer/wayland_sequencer.py
Expand Up @@ -181,7 +181,25 @@ def GetManualSequences(dep_graph):
c.RecordInterfaceCreated('wl_data_offer')

e = SequenceBuilder('empty', dep_graph)
return [c, e]

p = SequenceBuilder('popup_configuration', dep_graph)
p_positioner = p.BuildInterface('zxdg_positioner_v6')
p_parent = p.BuildInterface('zxdg_toplevel_v6')
p.AppendCall('zxdg_surface_v6', 'set_window_geometry',
[('receiver', p_parent), ('x', 0), ('y', 0), ('width', 10),
('height', 10)])
p.AppendRoundTrip()
p.AppendCall('wl_surface', 'commit', [('receiver', p_parent)])
p.AppendRoundTrip()
p.AppendCall('zxdg_surface_v6', 'ack_configure', [('receiver', p_parent),
('serial', 1)])
p_child = p.BuildInterface('zxdg_surface_v6')
p.AppendCall('zxdg_surface_v6', 'get_popup', [('receiver', p_child),
('parent', p_parent),
('positioner', p_positioner)])
p.AppendRoundTrip()

return [c, e, p]


def SequenceToTemplate(parsed_arguments, builder):
Expand Down
7 changes: 7 additions & 0 deletions components/exo/wayland/server.cc
Expand Up @@ -41,6 +41,7 @@
#include <xdg-decoration-unstable-v1-server-protocol.h>
#include <xdg-output-unstable-v1-server-protocol.h>
#include <xdg-shell-server-protocol.h>
#include <xdg-shell-unstable-v6-server-protocol.h>

#include <linux-dmabuf-unstable-v1-server-protocol.h>
#include <memory>
Expand Down Expand Up @@ -106,6 +107,7 @@
#include "components/exo/wayland/zwp_text_input_manager.h"
#include "components/exo/wayland/zxdg_decoration_manager.h"
#include "components/exo/wayland/zxdg_output_manager.h"
#include "components/exo/wayland/zxdg_shell.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/ozone/public/ozone_platform.h"
Expand Down Expand Up @@ -430,6 +432,11 @@ void Server::Initialize() {
zcr_text_input_extension_data_.get(),
bind_text_input_extension);

zxdg_shell_data_ =
std::make_unique<WaylandZxdgShell>(display_, serial_tracker_.get());
wl_global_create(wl_display_.get(), &zxdg_shell_v6_interface, 1,
zxdg_shell_data_.get(), bind_zxdg_shell_v6);

xdg_shell_data_ =
std::make_unique<WaylandXdgShell>(display_, serial_tracker_.get());
wl_global_create(wl_display_.get(), &xdg_wm_base_interface, 3,
Expand Down
2 changes: 2 additions & 0 deletions components/exo/wayland/server.h
Expand Up @@ -35,6 +35,7 @@ struct WaylandSeat;
struct WaylandTextInputExtension;
struct WaylandTextInputManager;
struct WaylandXdgShell;
struct WaylandZxdgShell;
struct WaylandRemoteShellData;
class WaylandDmabufFeedbackManager;
class WestonTest;
Expand Down Expand Up @@ -142,6 +143,7 @@ class Server : public display::DisplayObserver {
std::unique_ptr<WaylandKeyboardExtension> zcr_keyboard_extension_data_;
std::unique_ptr<WaylandTextInputManager> zwp_text_manager_data_;
std::unique_ptr<WaylandTextInputExtension> zcr_text_input_extension_data_;
std::unique_ptr<WaylandZxdgShell> zxdg_shell_data_;
std::unique_ptr<WaylandXdgShell> xdg_shell_data_;
std::unique_ptr<WaylandRemoteShellData> remote_shell_data_;
std::unique_ptr<WestonTest> weston_test_holder_;
Expand Down
1 change: 1 addition & 0 deletions components/exo/wayland/test/test_client.h
Expand Up @@ -62,6 +62,7 @@ class TestClient {
wl_touch* touch() { return globals().touch.get(); }
zaura_shell* aura_shell() { return globals().aura_shell.get(); }
zaura_output* aura_output() { return globals().aura_output.get(); }
zxdg_shell_v6* xdg_shell_v6() { return globals().xdg_shell_v6.get(); }
xdg_wm_base* xdg_wm_base() { return globals().xdg_wm_base.get(); }
zwp_fullscreen_shell_v1* fullscreen_shell() {
return globals().fullscreen_shell.get();
Expand Down

0 comments on commit 1433028

Please sign in to comment.