Commit 714a6231 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/wayland] Implement listen to close requests from Wayland

Users may request to close a browser window using close requests
originated from Wayland compositors. These requests can be envoked
by Mod+Shift+Q, for example.

The API responsible for this feature is the listener interface of
xdg_v5 and zxdg_v6 surfaces.

We have already had a dumb implementation for them, but the calls
have not been plumbed. Thus, just forward the calls to the
WaylandWindow and that's it.

Bug: 989043
Test: WaylandWindowTest.OnCloseRequest
Change-Id: I748fa93738900313013a0c4f48a709f28c24c352
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728549
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarAntonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#682687}
parent adab4b6d
...@@ -1144,6 +1144,17 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) { ...@@ -1144,6 +1144,17 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) {
VerifyAndClearExpectations(); VerifyAndClearExpectations();
} }
TEST_P(WaylandWindowTest, OnCloseRequest) {
EXPECT_CALL(delegate_, OnCloseRequest());
if (xdg_surface_->xdg_toplevel())
zxdg_toplevel_v6_send_close(xdg_surface_->xdg_toplevel()->resource());
else
xdg_surface_send_close(xdg_surface_->resource());
Sync();
}
INSTANTIATE_TEST_SUITE_P(XdgVersionV5Test, INSTANTIATE_TEST_SUITE_P(XdgVersionV5Test,
WaylandWindowTest, WaylandWindowTest,
::testing::Values(kXdgShellV5)); ::testing::Values(kXdgShellV5));
......
...@@ -87,7 +87,7 @@ void XDGSurfaceWrapperV5::Configure(void* data, ...@@ -87,7 +87,7 @@ void XDGSurfaceWrapperV5::Configure(void* data,
int32_t height, int32_t height,
wl_array* states, wl_array* states,
uint32_t serial) { uint32_t serial) {
XDGSurfaceWrapperV5* surface = static_cast<XDGSurfaceWrapperV5*>(data); auto* surface = static_cast<XDGSurfaceWrapperV5*>(data);
bool is_maximized = bool is_maximized =
CheckIfWlArrayHasValue(states, XDG_SURFACE_STATE_MAXIMIZED); CheckIfWlArrayHasValue(states, XDG_SURFACE_STATE_MAXIMIZED);
...@@ -103,7 +103,9 @@ void XDGSurfaceWrapperV5::Configure(void* data, ...@@ -103,7 +103,9 @@ void XDGSurfaceWrapperV5::Configure(void* data,
// static // static
void XDGSurfaceWrapperV5::Close(void* data, xdg_surface* obj) { void XDGSurfaceWrapperV5::Close(void* data, xdg_surface* obj) {
NOTIMPLEMENTED(); auto* surface = static_cast<XDGSurfaceWrapperV5*>(data);
DCHECK(surface);
surface->wayland_window_->OnCloseRequest();
} }
} // namespace ui } // namespace ui
...@@ -120,7 +120,8 @@ void XDGSurfaceWrapperV6::SetWindowGeometry(const gfx::Rect& bounds) { ...@@ -120,7 +120,8 @@ void XDGSurfaceWrapperV6::SetWindowGeometry(const gfx::Rect& bounds) {
void XDGSurfaceWrapperV6::Configure(void* data, void XDGSurfaceWrapperV6::Configure(void* data,
struct zxdg_surface_v6* zxdg_surface_v6, struct zxdg_surface_v6* zxdg_surface_v6,
uint32_t serial) { uint32_t serial) {
XDGSurfaceWrapperV6* surface = static_cast<XDGSurfaceWrapperV6*>(data); auto* surface = static_cast<XDGSurfaceWrapperV6*>(data);
DCHECK(surface);
surface->pending_configure_serial_ = serial; surface->pending_configure_serial_ = serial;
if (surface->surface_for_popup_) if (surface->surface_for_popup_)
...@@ -134,7 +135,8 @@ void XDGSurfaceWrapperV6::ConfigureTopLevel( ...@@ -134,7 +135,8 @@ void XDGSurfaceWrapperV6::ConfigureTopLevel(
int32_t width, int32_t width,
int32_t height, int32_t height,
struct wl_array* states) { struct wl_array* states) {
XDGSurfaceWrapperV6* surface = static_cast<XDGSurfaceWrapperV6*>(data); auto* surface = static_cast<XDGSurfaceWrapperV6*>(data);
DCHECK(surface);
bool is_maximized = bool is_maximized =
CheckIfWlArrayHasValue(states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED); CheckIfWlArrayHasValue(states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED);
...@@ -151,7 +153,9 @@ void XDGSurfaceWrapperV6::ConfigureTopLevel( ...@@ -151,7 +153,9 @@ void XDGSurfaceWrapperV6::ConfigureTopLevel(
void XDGSurfaceWrapperV6::CloseTopLevel( void XDGSurfaceWrapperV6::CloseTopLevel(
void* data, void* data,
struct zxdg_toplevel_v6* zxdg_toplevel_v6) { struct zxdg_toplevel_v6* zxdg_toplevel_v6) {
NOTIMPLEMENTED(); auto* surface = static_cast<XDGSurfaceWrapperV6*>(data);
DCHECK(surface);
surface->wayland_window_->OnCloseRequest();
} }
zxdg_surface_v6* XDGSurfaceWrapperV6::xdg_surface() const { zxdg_surface_v6* XDGSurfaceWrapperV6::xdg_surface() const {
......
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