Commit 5078c7a7 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

ozone/wayland: tabdrag: Skip unset_maximized during window drag

Differently from other platforms, under Wayland, unmaximizing the
dragged window before starting the drag loop is not needed as it is
assumed to be handled at compositor side, in extended-drag sessions
[1][2]. Just like in xdg_toplevel_surface's move request.

Thus, this CL patches WaylandToplevelWindow::Restore() function such
that it is no-op if there is a window drag session running.

Bug: 896640
Test: ozone_unittests --gtest_filter='*WaylandWindowDragControllerTest.RestoreDuringWindowDragSession*'

[1] https://docs.google.com/document/d/1s6OwTi_WC-pS21WLGQYI39yw2m42ZlVolUXBclljXB4/edit#heading=h.gjdgxs
[2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/wayland-protocols/unstable/extended-drag/extended-drag-unstable-v1.xml

Change-Id: Ifd07958604554686ca3bd7f7964b2dab80442316
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508235
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Auto-Submit: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarMaksim Sisov (GMT+2) <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#823525}
parent d5f5d54c
...@@ -199,6 +199,17 @@ void WaylandToplevelWindow::Minimize() { ...@@ -199,6 +199,17 @@ void WaylandToplevelWindow::Minimize() {
void WaylandToplevelWindow::Restore() { void WaylandToplevelWindow::Restore() {
DCHECK(shell_surface_); DCHECK(shell_surface_);
// Differently from other platforms, under Wayland, unmaximizing the dragged
// window before starting the drag loop is not needed as it is assumed to be
// handled at compositor side, just like in xdg_toplevel_surface::move. So
// skip it if there's a window drag session running.
auto* drag_controller = connection()->window_drag_controller();
if (drag_controller &&
drag_controller->state() != WaylandWindowDragController::State::kIdle) {
return;
}
SetWindowState(PlatformWindowState::kNormal); SetWindowState(PlatformWindowState::kNormal);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <xdg-shell-server-protocol.h>
#include <cstdint> #include <cstdint>
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include "ui/ozone/platform/wayland/host/wayland_window_manager.h" #include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
#include "ui/ozone/platform/wayland/test/mock_pointer.h" #include "ui/ozone/platform/wayland/test/mock_pointer.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h" #include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/scoped_wl_array.h"
#include "ui/ozone/platform/wayland/test/test_data_device.h" #include "ui/ozone/platform/wayland/test/test_data_device.h"
#include "ui/ozone/platform/wayland/test/test_data_device_manager.h" #include "ui/ozone/platform/wayland/test/test_data_device_manager.h"
#include "ui/ozone/platform/wayland/test/test_data_offer.h" #include "ui/ozone/platform/wayland/test/test_data_offer.h"
...@@ -574,6 +576,39 @@ TEST_P(WaylandWindowDragControllerTest, DragExitAttached) { ...@@ -574,6 +576,39 @@ TEST_P(WaylandWindowDragControllerTest, DragExitAttached) {
screen_->GetLocalProcessWidgetAtPoint({20, 20}, {})); screen_->GetLocalProcessWidgetAtPoint({20, 20}, {}));
} }
TEST_P(WaylandWindowDragControllerTest, RestoreDuringWindowDragSession) {
const gfx::Rect original_bounds = window_->GetBounds();
wl::ScopedWlArray states({XDG_TOPLEVEL_STATE_ACTIVATED});
// Maximize and check restored bounds is correctly set.
const gfx::Rect maximized_bounds = gfx::Rect(0, 0, 1024, 768);
EXPECT_CALL(delegate_, OnBoundsChanged(testing::Eq(maximized_bounds)));
window_->Maximize();
states.AddStateToWlArray(XDG_TOPLEVEL_STATE_MAXIMIZED);
SendConfigureEvent(surface_->xdg_surface(), maximized_bounds.width(),
maximized_bounds.height(), 1, states.get());
Sync();
auto restored_bounds = window_->GetRestoredBoundsInPixels();
EXPECT_EQ(original_bounds, restored_bounds);
// Start a window drag session.
SendPointerEnter(window_.get(), &delegate_);
SendPointerPress(window_.get(), &delegate_, BTN_LEFT);
SendPointerMotion(window_.get(), &delegate_, {10, 10});
Sync();
EXPECT_EQ(window_->GetWidget(),
screen_->GetLocalProcessWidgetAtPoint({10, 10}, {}));
auto* wayland_extension = GetWaylandExtension(*window_);
wayland_extension->StartWindowDraggingSessionIfNeeded();
EXPECT_EQ(WaylandWindowDragController::State::kAttached,
connection_->window_drag_controller()->state());
// Call restore and ensure it's no-op.
window_->Restore();
EXPECT_EQ(PlatformWindowState::kMaximized, window_->GetPlatformWindowState());
}
INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest, INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest,
WaylandWindowDragControllerTest, WaylandWindowDragControllerTest,
::testing::Values(kXdgShellStable)); ::testing::Values(kXdgShellStable));
......
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