Commit 1efa53ef authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Tab dragging: Remove the blur effect.

TabletModeBrowserWindowDragDelegate::scrim_ has two uses: 1) to show the
blurred background and 2) to work with SourceWindowAniamtionObserver to
prevent the dragged window to merge back into its source window during
dragging. Since now the blur effect is not needed as more, remove
|scrim_| and also modify SourceWindowAnimationObserver to make it work
on its own for the purpose 2).

Bug: 887739
Change-Id: Ia36ab16a2715fd761ef4fcbaba11559ecdd22f72
Reviewed-on: https://chromium-review.googlesource.com/1257369Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595950}
parent cc86e6e5
......@@ -1975,8 +1975,10 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
->GetDisplayNearestWindow(window1.get())
.work_area();
EXPECT_EQ(window2->GetBoundsInScreen(), work_area_bounds);
EXPECT_TRUE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
// 2.a. Drag the window a small amount of distance will maximize the window.
// 2.a. Drag the window a small amount of distance and release will maximize
// the window.
DragWindowWithOffset(resizer.get(), 10, 10);
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kNone);
// Drag the window past the indicators threshold to show the indicators.
......@@ -1985,11 +1987,13 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kDragArea);
// The source window should also have been scaled.
EXPECT_NE(window2->GetBoundsInScreen(), work_area_bounds);
EXPECT_FALSE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
CompleteDrag(std::move(resizer));
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(window2.get())->IsMaximized());
// The source window should have restored its bounds.
EXPECT_EQ(window2->GetBoundsInScreen(), work_area_bounds);
EXPECT_TRUE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
// 2.b. Drag the window long enough to snap the window. The source window will
// snap to the other side of the splitscreen.
......@@ -2003,6 +2007,7 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_EQ(window2->GetBoundsInScreen(),
split_view_controller()->GetSnappedWindowBoundsInScreen(
window2.get(), SplitViewController::LEFT));
EXPECT_FALSE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
DragWindowTo(resizer.get(), gfx::Point(0, 300));
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kPreviewAreaLeft);
// The source window's bounds should be the same as the right snapped window
......@@ -2010,6 +2015,7 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_EQ(window2->GetBoundsInScreen(),
split_view_controller()->GetSnappedWindowBoundsInScreen(
window2.get(), SplitViewController::RIGHT));
EXPECT_FALSE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
resizer->CompleteDrag();
EXPECT_EQ(window1->GetProperty(kTabDroppedWindowStateTypeKey),
......@@ -2023,6 +2029,7 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
EXPECT_EQ(split_view_controller()->state(),
SplitViewController::BOTH_SNAPPED);
EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
EXPECT_TRUE(window1->GetProperty(ash::kCanAttachToAnotherWindowKey));
EndSplitView();
EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive());
......
......@@ -8,15 +8,12 @@
#include "ash/wm/tablet_mode/tablet_mode_window_drag_delegate.h"
#include "base/macros.h"
namespace views {
class Widget;
} // namespace views
namespace ash {
// The drag delegate for browser windows. It not only includes the logic in
// TabletModeWindowDragDelegate, but also has special logic for browser windows,
// e.g., scales the source window, shows/hides the blurred background, etc.
// e.g., scales the source window, shows/hides the other windows below the
// source window.
class TabletModeBrowserWindowDragDelegate
: public TabletModeWindowDragDelegate {
public:
......@@ -40,18 +37,6 @@ class TabletModeBrowserWindowDragDelegate
// current drag location for the dragged window.
void UpdateSourceWindow(const gfx::Point& location_in_screen);
// Shows/Hides/Destroies the scrim widget |scrim_| based on the current
// location |location_in_screen|.
void UpdateScrim(const gfx::Point& location_in_screen);
// Shows the scrim with the specified opacity, blur and expected bounds.
void ShowScrim(float opacity, float blur, const gfx::Rect& bounds_in_screen);
// A widget placed below the current dragged window to show the blurred or
// transparent background and to prevent the dragged window merge into any
// browser window beneath it during dragging.
std::unique_ptr<views::Widget> scrim_;
// It's used to hide all visible windows if the source window needs to be
// scaled up/down during dragging a tab out of the source window. It also
// hides the home launcher if home launcher is enabled, blurs and darkens the
......@@ -59,6 +44,13 @@ class TabletModeBrowserWindowDragDelegate
// destruction.
std::unique_ptr<WindowsHider> windows_hider_;
// The observer to observe the source window's bounds change animation during
// dragging. It's used to prevent the dragged window to merge back into the
// source window during dragging. Only when the source window restores to its
// maximized window size, the dragged window can be merged back into the
// source window.
std::unique_ptr<ui::ImplicitAnimationObserver> source_window_bounds_observer_;
DISALLOW_COPY_AND_ASSIGN(TabletModeBrowserWindowDragDelegate);
};
......
......@@ -29,10 +29,6 @@ namespace {
// tablet mode.
constexpr float kIndicatorsThresholdRatio = 0.1;
// The threshold to compute the vertical distance to hide the drag indicators
// and maximize the dragged window after the drag ends.
constexpr float kMaximizeThresholdRatio = 0.4;
// Returns the window selector if overview mode is active, otherwise returns
// nullptr.
WindowSelector* GetWindowSelector() {
......@@ -245,16 +241,6 @@ IndicatorState TabletModeWindowDragDelegate::GetIndicatorState(
return IndicatorState::kNone;
}
// If the event location has passed the maximize vertical threshold, and the
// event location is not in snap indicator area, and overview mode is not
// active at the moment, do not show the drag indicators.
if (location_in_screen.y() >=
GetMaximizeVerticalThreshold(work_area_bounds) &&
snap_position == SplitViewController::NONE &&
!Shell::Get()->window_selector_controller()->IsSelecting()) {
return IndicatorState::kNone;
}
// No top drag indicator if in portrait screen orientation.
if (split_view_controller_->IsCurrentScreenOrientationLandscape())
return can_snap ? IndicatorState::kDragArea : IndicatorState::kCannotSnap;
......@@ -274,12 +260,6 @@ int TabletModeWindowDragDelegate::GetIndicatorsVerticalThreshold(
work_area_bounds.height() * kIndicatorsThresholdRatio;
}
int TabletModeWindowDragDelegate::GetMaximizeVerticalThreshold(
const gfx::Rect& work_area_bounds) const {
return work_area_bounds.y() +
work_area_bounds.height() * kMaximizeThresholdRatio;
}
SplitViewController::SnapPosition TabletModeWindowDragDelegate::GetSnapPosition(
const gfx::Point& location_in_screen) const {
gfx::Rect work_area_bounds = display::Screen::GetScreen()
......
......@@ -81,10 +81,6 @@ class TabletModeWindowDragDelegate {
// will show up.
int GetIndicatorsVerticalThreshold(const gfx::Rect& work_area_bounds) const;
// When the dragged window is dragged past this value, a blured scrim will
// show up, indicating the dragged window will be maximized after releasing.
int GetMaximizeVerticalThreshold(const gfx::Rect& work_area_bounds) const;
// Gets the desired snap position for |location_in_screen|.
SplitViewController::SnapPosition GetSnapPosition(
const gfx::Point& location_in_screen) const;
......
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