Commit e4a1eecc authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Always create a backdrop for fullscreen/maximized arc window.

Arc window may be cropped, which can cause showing/hiding
backdrop during the transition, which then may send
unnecessary synthesized mouse move even.

Bug: b/111319005
Test: Covered by unit test. Also tested on play music. See bug for repro step.

Change-Id: Ie030e24095eeadbd549e7cdc8cf7be0438c88d49
Reviewed-on: https://chromium-review.googlesource.com/1162705Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581086}
parent c8a50a98
......@@ -511,7 +511,7 @@ void ClientControlledShellSurface::OnBoundsChangeEvent(
// The client's geometry uses fullscreen in client controlled,
// (but the surface is placed under the frame), so just use
// the window bounds instead for maximixed stte.
// the window bounds instead for maximixed state.
gfx::Rect client_bounds =
widget_->IsMaximized()
? window_bounds
......@@ -615,7 +615,6 @@ bool ClientControlledShellSurface::IsInputEnabled(Surface* surface) const {
void ClientControlledShellSurface::OnSetFrame(SurfaceFrameType type) {
ShellSurfaceBase::OnSetFrame(type);
frame_type_ = type;
UpdateAutoHideFrame();
}
......@@ -955,11 +954,11 @@ void ClientControlledShellSurface::UpdateCaptionButtonModel() {
void ClientControlledShellSurface::UpdateBackdrop() {
aura::Window* window = widget_->GetNativeWindow();
const display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(window);
bool enable_backdrop =
(widget_->IsFullscreen() || widget_->IsMaximized()) &&
!widget_->GetWindowBoundsInScreen().Contains(display.work_area());
// Always create a backdrop regardless of the geometry because
// maximized/fullscreen widget's geometry can be cropped.
bool enable_backdrop = (widget_->IsFullscreen() || widget_->IsMaximized());
ash::BackdropWindowMode target_backdrop_mode =
enable_backdrop ? ash::BackdropWindowMode::kEnabled
: ash::BackdropWindowMode::kAuto;
......
......@@ -28,6 +28,7 @@
#include "ash/wm/window_util.h"
#include "ash/wm/wm_event.h"
#include "ash/wm/workspace_controller_test_api.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "cc/paint/display_item_list.h"
......@@ -41,6 +42,7 @@
#include "components/exo/wm_helper.h"
#include "third_party/skia/include/utils/SkNoDrawCanvas.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
......@@ -520,6 +522,7 @@ TEST_F(ClientControlledShellSurfaceTest, Frame) {
// AutoHide
surface->SetFrame(SurfaceFrameType::AUTOHIDE);
surface->Commit();
EXPECT_TRUE(frame_view->visible());
EXPECT_EQ(fullscreen_bounds, widget->GetWindowBoundsInScreen());
EXPECT_EQ(fullscreen_bounds,
......@@ -554,6 +557,61 @@ TEST_F(ClientControlledShellSurfaceTest, Frame) {
frame_view->GetClientBoundsForWindowBounds(client_bounds));
}
namespace {
class TestEventHandler : public ui::EventHandler {
public:
TestEventHandler() = default;
~TestEventHandler() override = default;
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override { received_event_ = true; }
bool received_event() const { return received_event_; }
private:
bool received_event_ = false;
DISALLOW_COPY_AND_ASSIGN(TestEventHandler);
};
} // namespace
TEST_F(ClientControlledShellSurfaceTest, NoSynthesizedEventOnFrameChange) {
UpdateDisplay("800x600");
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
std::unique_ptr<Surface> surface(new Surface);
gfx::Rect fullscreen_bounds(0, 0, 800, 600);
auto shell_surface =
exo_test_helper()->CreateClientControlledShellSurface(surface.get());
surface->Attach(buffer.get());
surface->SetFrame(SurfaceFrameType::NORMAL);
surface->Commit();
// Maximized
shell_surface->SetMaximized();
shell_surface->SetGeometry(fullscreen_bounds);
surface->Commit();
// AutoHide
base::RunLoop().RunUntilIdle();
auto* env = aura::Env::GetInstance();
gfx::Rect cropped_fullscreen_bounds(0, 0, 800, 400);
env->SetLastMouseLocation(gfx::Point(100, 100));
TestEventHandler handler;
env->AddPreTargetHandler(&handler);
surface->SetFrame(SurfaceFrameType::AUTOHIDE);
shell_surface->SetGeometry(cropped_fullscreen_bounds);
surface->Commit();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(handler.received_event());
env->RemovePreTargetHandler(&handler);
}
TEST_F(ClientControlledShellSurfaceTest, CompositorLockInRotation) {
UpdateDisplay("800x600");
const gfx::Size buffer_size(800, 600);
......@@ -691,11 +749,11 @@ TEST_F(ClientControlledShellSurfaceTest, Maximize) {
EXPECT_TRUE(HasBackdrop());
EXPECT_TRUE(shell_surface->GetWidget()->IsMaximized());
// Enable backdrop only if the shell surface doesn't cover the display.
// We always show backdrop because the window may be cropped.
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
shell_surface->SetGeometry(display.bounds());
surface->Commit();
EXPECT_FALSE(HasBackdrop());
EXPECT_TRUE(HasBackdrop());
shell_surface->SetGeometry(gfx::Rect(0, 0, 100, display.bounds().height()));
surface->Commit();
......@@ -754,11 +812,11 @@ TEST_F(ClientControlledShellSurfaceTest, SetFullscreen) {
surface->Commit();
EXPECT_TRUE(HasBackdrop());
// Enable backdrop only if the shell surface doesn't cover the display.
// We always show backdrop becaues the window can be cropped.
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
shell_surface->SetGeometry(display.bounds());
surface->Commit();
EXPECT_FALSE(HasBackdrop());
EXPECT_TRUE(HasBackdrop());
shell_surface->SetGeometry(gfx::Rect(0, 0, 100, display.bounds().height()));
surface->Commit();
......
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