Commit 37a0eedb authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Restore CustomWindowTargeter after creating/deleting wideframe.

ImmersiveFullscreenController replaces the targeter to
ResizeHandleWindowTargeter, which will make the input hit test not
considering Chrome caption.

BUG=b:113815571
TEST="Manual tests. exo_unittests."

Change-Id: I9de803b24cf64034f2c0f60e04acf147a230ec95
Reviewed-on: https://chromium-review.googlesource.com/1226812Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591462}
parent c9b93154
......@@ -970,6 +970,9 @@ void ClientControlledShellSurface::UpdateFrame() {
ash::ImmersiveFullscreenController::EnableForWidget(widget_, false);
wide_frame_->Init(immersive_fullscreen_controller_.get());
wide_frame_->GetWidget()->Show();
// Restoring window targeter replaced by ImmersiveFullscreenController.
InstallCustomWindowTargeter();
UpdateCaptionButtonModel();
}
} else {
......@@ -978,6 +981,9 @@ void ClientControlledShellSurface::UpdateFrame() {
wide_frame_.reset();
GetFrameView()->InitImmersiveFullscreenControllerForView(
immersive_fullscreen_controller_.get());
// Restoring window targeter replaced by ImmersiveFullscreenController.
InstallCustomWindowTargeter();
UpdateCaptionButtonModel();
}
UpdateFrameWidth();
......
......@@ -1490,6 +1490,7 @@ TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
std::unique_ptr<Buffer> desktop_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(64, 64))));
surface->Attach(desktop_buffer.get());
surface->SetInputRegion(gfx::Rect(0, 0, 64, 64));
shell_surface->SetGeometry(gfx::Rect(0, 0, 64, 64));
shell_surface->SetMaximized();
surface->SetFrame(SurfaceFrameType::NORMAL);
......@@ -1499,6 +1500,36 @@ TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
ASSERT_TRUE(wide_frame);
EXPECT_FALSE(wide_frame->header_view()->in_immersive_mode());
// Check targeter is still CustomWindowTargeter.
aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
ASSERT_TRUE(window->parent());
auto* custom_targeter = window->targeter();
gfx::Point mouse_location(1, 50);
auto* root = window->GetRootWindow();
aura::WindowTargeter targeter;
aura::Window* target;
{
ui::MouseEvent event(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
target =
static_cast<aura::Window*>(targeter.FindTargetForEvent(root, &event));
}
EXPECT_EQ(surface->window(), target);
// Disable input region and the targeter no longer find the surface.
surface->SetInputRegion(gfx::Rect(0, 0, 0, 0));
surface->Commit();
{
ui::MouseEvent event(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
target =
static_cast<aura::Window*>(targeter.FindTargetForEvent(root, &event));
}
EXPECT_NE(surface->window(), target);
// Test AUTOHIDE -> NORMAL
surface->SetFrame(SurfaceFrameType::AUTOHIDE);
surface->Commit();
......@@ -1508,6 +1539,8 @@ TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
surface->Commit();
EXPECT_FALSE(wide_frame->header_view()->in_immersive_mode());
EXPECT_EQ(custom_targeter, window->targeter());
// Test AUTOHIDE -> NONE
surface->SetFrame(SurfaceFrameType::AUTOHIDE);
surface->Commit();
......@@ -1517,10 +1550,31 @@ TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
surface->Commit();
EXPECT_FALSE(wide_frame->header_view()->in_immersive_mode());
EXPECT_EQ(custom_targeter, window->targeter());
// Unmaximize it and the frame should be normal.
shell_surface->SetRestored();
surface->Commit();
EXPECT_FALSE(shell_surface->wide_frame_for_test());
{
ui::MouseEvent event(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
target =
static_cast<aura::Window*>(targeter.FindTargetForEvent(root, &event));
}
EXPECT_NE(surface->window(), target);
// Re-enable input region and the targeter should find the surface again.
surface->SetInputRegion(gfx::Rect(0, 0, 64, 64));
surface->Commit();
{
ui::MouseEvent event(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
target =
static_cast<aura::Window*>(targeter.FindTargetForEvent(root, &event));
}
EXPECT_EQ(surface->window(), target);
}
TEST_F(ClientControlledShellSurfaceTest, NoFrameOnModalContainer) {
......
......@@ -984,8 +984,7 @@ void ShellSurfaceBase::CreateShellSurfaceWidget(
// Works for both mash and non-mash. https://crbug.com/839521
window->SetEventTargetingPolicy(
ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
window->SetEventTargeter(std::make_unique<CustomWindowTargeter>(
widget_, client_controlled_move_resize_));
InstallCustomWindowTargeter();
SetApplicationId(window, application_id_);
SetStartupId(window, startup_id_);
SetMainSurface(window, root_surface());
......@@ -1128,6 +1127,12 @@ gfx::Rect ShellSurfaceBase::GetShadowBounds() const {
: gfx::ScaleToEnclosedRect(*shadow_bounds_, 1.f / GetScale());
}
void ShellSurfaceBase::InstallCustomWindowTargeter() {
aura::Window* window = widget_->GetNativeWindow();
window->SetEventTargeter(std::make_unique<CustomWindowTargeter>(
widget_, client_controlled_move_resize_));
}
////////////////////////////////////////////////////////////////////////////////
// ShellSurfaceBase, private:
......
......@@ -250,6 +250,9 @@ class ShellSurfaceBase : public SurfaceTreeHost,
const gfx::Rect& geometry() const { return geometry_; }
// Install custom window targeter. Used to restore window targeter.
void InstallCustomWindowTargeter();
views::Widget* widget_ = nullptr;
aura::Window* parent_ = nullptr;
bool movement_disabled_ = false;
......
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