Commit c6c1d3b5 authored by David Reveman's avatar David Reveman Committed by Commit Bot

exo: Fix activatable state for transient children

Transient child should not be activatable unless it has an
application id. This allows aura shell clients to create
popup style windows without using the xdg popup API that
requires the ability to dismiss a surface.

Bug: 857465
Test: exo_unittest --gtest_filter=ShellSurface.SetParent
Change-Id: I628e51af113ab7e3cd73925b9af7e339ef1442cd
Reviewed-on: https://chromium-review.googlesource.com/1118855
Commit-Queue: David Reveman <reveman@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571232}
parent 61499787
...@@ -1120,7 +1120,7 @@ void ShellSurfaceBase::OnWindowActivated(ActivationReason reason, ...@@ -1120,7 +1120,7 @@ void ShellSurfaceBase::OnWindowActivated(ActivationReason reason,
if (gained_active == widget_->GetNativeWindow() || if (gained_active == widget_->GetNativeWindow() ||
lost_active == widget_->GetNativeWindow()) { lost_active == widget_->GetNativeWindow()) {
DCHECK(activatable_); DCHECK(CanActivate());
Configure(); Configure();
UpdateShadow(); UpdateShadow();
} }
...@@ -1167,6 +1167,9 @@ void ShellSurfaceBase::CreateShellSurfaceWidget( ...@@ -1167,6 +1167,9 @@ void ShellSurfaceBase::CreateShellSurfaceWidget(
// region is non-empty. See OnCommitSurface() for more details. // region is non-empty. See OnCommitSurface() for more details.
if (container_ == ash::kShellWindowId_SystemModalContainer) if (container_ == ash::kShellWindowId_SystemModalContainer)
activatable &= HasHitTestRegion(); activatable &= HasHitTestRegion();
// Transient child needs to have an application id to be activatable.
if (parent_)
activatable &= application_id_.has_value();
params.activatable = activatable ? views::Widget::InitParams::ACTIVATABLE_YES params.activatable = activatable ? views::Widget::InitParams::ACTIVATABLE_YES
: views::Widget::InitParams::ACTIVATABLE_NO; : views::Widget::InitParams::ACTIVATABLE_NO;
// Note: NativeWidget owns this widget. // Note: NativeWidget owns this widget.
...@@ -1202,7 +1205,7 @@ void ShellSurfaceBase::CreateShellSurfaceWidget( ...@@ -1202,7 +1205,7 @@ void ShellSurfaceBase::CreateShellSurfaceWidget(
window_state->SetHideShelfWhenFullscreen(false); window_state->SetHideShelfWhenFullscreen(false);
// Fade visibility animations for non-activatable windows. // Fade visibility animations for non-activatable windows.
if (!activatable_) { if (!CanActivate()) {
wm::SetWindowVisibilityAnimationType( wm::SetWindowVisibilityAnimationType(
window, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); window, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
} }
...@@ -1357,7 +1360,7 @@ void ShellSurfaceBase::UpdateShadow() { ...@@ -1357,7 +1360,7 @@ void ShellSurfaceBase::UpdateShadow() {
shadow->SetContentBounds(GetShadowBounds()); shadow->SetContentBounds(GetShadowBounds());
// Surfaces that can't be activated are usually menus and tooltips. Use a // Surfaces that can't be activated are usually menus and tooltips. Use a
// small style shadow for them. // small style shadow for them.
if (!activatable_) if (!CanActivate())
shadow->SetElevation(wm::kShadowElevationMenuOrTooltip); shadow->SetElevation(wm::kShadowElevationMenuOrTooltip);
// We don't have rounded corners unless frame is enabled. // We don't have rounded corners unless frame is enabled.
if (!frame_enabled()) if (!frame_enabled())
......
...@@ -144,6 +144,7 @@ TEST_F(ShellSurfaceTest, SetParent) { ...@@ -144,6 +144,7 @@ TEST_F(ShellSurfaceTest, SetParent) {
gfx::PointAtOffsetFromOrigin(gfx::Point(10, 10) - parent_origin)); gfx::PointAtOffsetFromOrigin(gfx::Point(10, 10) - parent_origin));
EXPECT_EQ(gfx::Rect(10, 10, 256, 256), EXPECT_EQ(gfx::Rect(10, 10, 256, 256),
shell_surface->GetWidget()->GetWindowBoundsInScreen()); shell_surface->GetWidget()->GetWindowBoundsInScreen());
EXPECT_FALSE(shell_surface->CanActivate());
} }
TEST_F(ShellSurfaceTest, Maximize) { TEST_F(ShellSurfaceTest, Maximize) {
......
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