Commit 93e52146 authored by Katie D's avatar Katie D Committed by Commit Bot

Fixes visual bug where autoclick shadow was cropped by widget bounds.

The widget had no insets in which to display the shadow. In this change,
add insets to the widget, and ensure they are taken into account after
calculating the preferred layout for the autoclick menu view.

Bug: 966153
Change-Id: If43a4f3e91f20261195102018aad90c8427ac9a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636285Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665947}
parent 09f515d6
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "ash/wm/workspace/workspace_layout_manager.h" #include "ash/wm/workspace/workspace_layout_manager.h"
#include "ash/wm/workspace_controller.h" #include "ash/wm/workspace_controller.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
namespace ash { namespace ash {
...@@ -23,6 +25,7 @@ namespace ash { ...@@ -23,6 +25,7 @@ namespace ash {
namespace { namespace {
// Autoclick menu constants. // Autoclick menu constants.
const int kAutoclickMenuWidth = 321; const int kAutoclickMenuWidth = 321;
const int kAutoclickMenuHeight = 64;
} // namespace } // namespace
AutoclickMenuBubbleController::AutoclickMenuBubbleController() { AutoclickMenuBubbleController::AutoclickMenuBubbleController() {
...@@ -72,18 +75,24 @@ void AutoclickMenuBubbleController::SetPosition( ...@@ -72,18 +75,24 @@ void AutoclickMenuBubbleController::SetPosition(
gfx::Rect new_bounds; gfx::Rect new_bounds;
switch (new_position) { switch (new_position) {
case mojom::AutoclickMenuPosition::kBottomRight: case mojom::AutoclickMenuPosition::kBottomRight:
new_bounds = gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); new_bounds = gfx::Rect(work_area.right() - kAutoclickMenuWidth,
work_area.bottom() - kAutoclickMenuHeight,
kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case mojom::AutoclickMenuPosition::kBottomLeft: case mojom::AutoclickMenuPosition::kBottomLeft:
new_bounds = gfx::Rect(work_area.x(), work_area.bottom(), 0, 0); new_bounds =
gfx::Rect(work_area.x(), work_area.bottom() - kAutoclickMenuHeight,
kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case mojom::AutoclickMenuPosition::kTopLeft: case mojom::AutoclickMenuPosition::kTopLeft:
// Setting the top to 1 instead of 0 so that the view is drawn on screen. // Setting the top to 1 instead of 0 so that the view is drawn on screen.
new_bounds = gfx::Rect(work_area.x(), 1, 0, 0); new_bounds = gfx::Rect(work_area.x(), 1, kAutoclickMenuWidth,
kAutoclickMenuHeight);
break; break;
case mojom::AutoclickMenuPosition::kTopRight: case mojom::AutoclickMenuPosition::kTopRight:
// Setting the top to 1 instead of 0 so that the view is drawn on screen. // Setting the top to 1 instead of 0 so that the view is drawn on screen.
new_bounds = gfx::Rect(work_area.right(), 1, 0, 0); new_bounds = gfx::Rect(work_area.right() - kAutoclickMenuWidth, 1,
kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case mojom::AutoclickMenuPosition::kSystemDefault: case mojom::AutoclickMenuPosition::kSystemDefault:
return; return;
...@@ -95,10 +104,19 @@ void AutoclickMenuBubbleController::SetPosition( ...@@ -95,10 +104,19 @@ void AutoclickMenuBubbleController::SetPosition(
bubble_widget_->GetNativeWindow()), bubble_widget_->GetNativeWindow()),
new_bounds, new_bounds,
CollisionDetectionUtils::RelativePriority::kAutomaticClicksMenu); CollisionDetectionUtils::RelativePriority::kAutomaticClicksMenu);
if (bubble_view_->anchor_rect() == resting_bounds)
// Un-inset the bounds to get the widget's bounds, which includes the drop
// shadow.
resting_bounds.Inset(-kCollisionWindowWorkAreaInsetsDp,
-kCollisionWindowWorkAreaInsetsDp);
if (bubble_widget_->GetWindowBoundsInScreen() == resting_bounds)
return; return;
bubble_view_->MoveToPosition(resting_bounds); ui::ScopedLayerAnimationSettings settings(
bubble_widget_->GetLayer()->GetAnimator());
settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
bubble_widget_->SetBounds(resting_bounds);
} }
void AutoclickMenuBubbleController::ShowBubble( void AutoclickMenuBubbleController::ShowBubble(
...@@ -116,7 +134,7 @@ void AutoclickMenuBubbleController::ShowBubble( ...@@ -116,7 +134,7 @@ void AutoclickMenuBubbleController::ShowBubble(
init_params.parent_window = Shell::GetContainer( init_params.parent_window = Shell::GetContainer(
Shell::GetPrimaryRootWindow(), kShellWindowId_AutoclickContainer); Shell::GetPrimaryRootWindow(), kShellWindowId_AutoclickContainer);
init_params.anchor_mode = TrayBubbleView::AnchorMode::kRect; init_params.anchor_mode = TrayBubbleView::AnchorMode::kRect;
init_params.insets = gfx::Insets(); init_params.insets = gfx::Insets(kCollisionWindowWorkAreaInsetsDp);
init_params.min_width = kAutoclickMenuWidth; init_params.min_width = kAutoclickMenuWidth;
init_params.max_width = kAutoclickMenuWidth; init_params.max_width = kAutoclickMenuWidth;
init_params.corner_radius = kUnifiedTrayCornerRadius; init_params.corner_radius = kUnifiedTrayCornerRadius;
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
...@@ -144,14 +142,6 @@ bool AutoclickMenuBubbleView::IsAnchoredToStatusArea() const { ...@@ -144,14 +142,6 @@ bool AutoclickMenuBubbleView::IsAnchoredToStatusArea() const {
return false; return false;
} }
void AutoclickMenuBubbleView::MoveToPosition(const gfx::Rect& rect) {
ui::ScopedLayerAnimationSettings settings(
GetWidget()->GetLayer()->GetAnimator());
settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
SetAnchorRect(rect);
}
const char* AutoclickMenuBubbleView::GetClassName() const { const char* AutoclickMenuBubbleView::GetClassName() const {
return "AutoclickMenuBubbleView"; return "AutoclickMenuBubbleView";
} }
......
...@@ -23,8 +23,6 @@ class AutoclickMenuBubbleView : public TrayBubbleView { ...@@ -23,8 +23,6 @@ class AutoclickMenuBubbleView : public TrayBubbleView {
// TrayBubbleView: // TrayBubbleView:
bool IsAnchoredToStatusArea() const override; bool IsAnchoredToStatusArea() const override;
void MoveToPosition(const gfx::Rect& rect);
// views::View: // views::View:
const char* GetClassName() const override; const char* GetClassName() const override;
......
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