Commit 54aac2d6 authored by Antonio Gomes's avatar Antonio Gomes Committed by Chromium LUCI CQ

fixup! [ozone/wayland] Relax condition to call PlatformWindowDelegate::OnWindowStateChanged()

This CL changes the original fix [1] that relaxed the condition
to call PlatformWindowDelegate::OnWindowStateChanged() from
WaylandToplevelWindow::HandleSurfaceConfigure().

[1] https://crrev.com/c/2601219

Most of the original change in [1] is recovered, and an extra call
to PlatformWindowDelegate::OnWindowStateChanged() was added to
WaylandToplevelWindow::TriggerStateChanges(). This keeps the
synchronous nature expected for the calls coming from the browser
that change window show states.

BUG=1113900
R=msisov@igalia.com

Change-Id: If61d71c3ae885b6ea0e9c1ab8e091694f48db771
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2614433Reviewed-by: default avatarMaksim Sisov <msisov@igalia.com>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#842018}
parent 18dbf946
...@@ -241,6 +241,7 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width, ...@@ -241,6 +241,7 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width,
bool is_activated) { bool is_activated) {
// Store the old state to propagte state changes if Wayland decides to change // Store the old state to propagte state changes if Wayland decides to change
// the state to something else. // the state to something else.
PlatformWindowState old_state = state_;
if (state_ == PlatformWindowState::kMinimized && !is_activated) { if (state_ == PlatformWindowState::kMinimized && !is_activated) {
state_ = PlatformWindowState::kMinimized; state_ = PlatformWindowState::kMinimized;
} else if (is_fullscreen) { } else if (is_fullscreen) {
...@@ -253,6 +254,8 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width, ...@@ -253,6 +254,8 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width,
const bool is_normal = state_ == PlatformWindowState::kNormal; const bool is_normal = state_ == PlatformWindowState::kNormal;
const bool did_window_show_state_change = old_state != state_;
// Update state before notifying delegate. // Update state before notifying delegate.
const bool did_active_change = is_active_ != is_activated; const bool did_active_change = is_active_ != is_activated;
is_active_ = is_activated; is_active_ = is_activated;
...@@ -288,8 +291,10 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width, ...@@ -288,8 +291,10 @@ void WaylandToplevelWindow::HandleSurfaceConfigure(int32_t width,
SetOrResetRestoredBounds(); SetOrResetRestoredBounds();
ApplyPendingBounds(); ApplyPendingBounds();
// Notify the delegate about the latest state set. if (did_window_show_state_change) {
previous_state_ = old_state;
delegate()->OnWindowStateChanged(state_); delegate()->OnWindowStateChanged(state_);
}
if (did_active_change) if (did_active_change)
delegate()->OnActivationChanged(is_active_); delegate()->OnActivationChanged(is_active_);
...@@ -361,6 +366,8 @@ void WaylandToplevelWindow::TriggerStateChanges() { ...@@ -361,6 +366,8 @@ void WaylandToplevelWindow::TriggerStateChanges() {
shell_toplevel_->UnSetMaximized(); shell_toplevel_->UnSetMaximized();
} }
delegate()->OnWindowStateChanged(state_);
connection()->ScheduleFlush(); connection()->ScheduleFlush();
} }
......
...@@ -476,12 +476,11 @@ TEST_P(WaylandWindowTest, StartMaximized) { ...@@ -476,12 +476,11 @@ TEST_P(WaylandWindowTest, StartMaximized) {
// Make sure the window is initialized to normal state from the beginning. // Make sure the window is initialized to normal state from the beginning.
EXPECT_EQ(PlatformWindowState::kNormal, window_->GetPlatformWindowState()); EXPECT_EQ(PlatformWindowState::kNormal, window_->GetPlatformWindowState());
// The state must not be changed to the fullscreen before the surface is // The state gets changed to maximize and the delegate notified.
// activated.
auto* mock_surface = server_.GetObject<wl::MockSurface>( auto* mock_surface = server_.GetObject<wl::MockSurface>(
window->root_surface()->GetSurfaceId()); window->root_surface()->GetSurfaceId());
EXPECT_FALSE(mock_surface->xdg_surface()); EXPECT_FALSE(mock_surface->xdg_surface());
EXPECT_CALL(delegate_, OnWindowStateChanged(_)).Times(0); EXPECT_CALL(delegate_, OnWindowStateChanged(_)).Times(1);
window_->Maximize(); window_->Maximize();
// The state of the window must already be fullscreen one. // The state of the window must already be fullscreen one.
...@@ -489,8 +488,9 @@ TEST_P(WaylandWindowTest, StartMaximized) { ...@@ -489,8 +488,9 @@ TEST_P(WaylandWindowTest, StartMaximized) {
Sync(); Sync();
// Once the surface will be activated, the window state gets updated. // Window show state should be already up to date, so delegate is not
EXPECT_CALL(delegate_, OnWindowStateChanged(_)).Times(1); // notified.
EXPECT_CALL(delegate_, OnWindowStateChanged(_)).Times(0);
EXPECT_EQ(window_->GetPlatformWindowState(), PlatformWindowState::kMaximized); EXPECT_EQ(window_->GetPlatformWindowState(), PlatformWindowState::kMaximized);
// Activate the surface. // Activate the surface.
...@@ -529,6 +529,8 @@ TEST_P(WaylandWindowTest, CompositorSideStateChanges) { ...@@ -529,6 +529,8 @@ TEST_P(WaylandWindowTest, CompositorSideStateChanges) {
EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, normal_bounds.width(), EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, normal_bounds.width(),
normal_bounds.height())); normal_bounds.height()));
Sync();
// Now, set to fullscreen. // Now, set to fullscreen.
AddStateToWlArray(XDG_TOPLEVEL_STATE_FULLSCREEN, states.get()); AddStateToWlArray(XDG_TOPLEVEL_STATE_FULLSCREEN, states.get());
SendConfigureEvent(xdg_surface_, 2005, 2005, 3, states.get()); SendConfigureEvent(xdg_surface_, 2005, 2005, 3, states.get());
......
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