Commit 2a18383a authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Renable dragging windows on overview title bars.

Change of mind. Mostly a revert of
https://chromium-review.googlesource.com/c/chromium/src/+/911849.

Test: ash_unittests WindowSelectorTest.*
Bug: 825637
Change-Id: I37bead0a8b1d80cd0c89c646feb5af2a1f0ffa1a
Reviewed-on: https://chromium-review.googlesource.com/986942Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546978}
parent 1552f52f
...@@ -256,7 +256,7 @@ class ShieldButton : public views::Button { ...@@ -256,7 +256,7 @@ class ShieldButton : public views::Button {
listener()->HandleReleaseEvent(location); listener()->HandleReleaseEvent(location);
break; break;
case ui::ET_GESTURE_TAP: case ui::ET_GESTURE_TAP:
listener()->ActivateDraggedWindow(location); listener()->ActivateDraggedWindow();
break; break;
case ui::ET_GESTURE_END: case ui::ET_GESTURE_END:
listener()->ResetDraggedWindowGesture(); listener()->ResetDraggedWindowGesture();
...@@ -963,54 +963,27 @@ float WindowSelectorItem::GetItemScale(const gfx::Size& size) { ...@@ -963,54 +963,27 @@ float WindowSelectorItem::GetItemScale(const gfx::Size& size) {
void WindowSelectorItem::HandlePressEvent( void WindowSelectorItem::HandlePressEvent(
const gfx::Point& location_in_screen) { const gfx::Point& location_in_screen) {
// Check the y position instead of using GetBoundsInScreen().Contains() so
// that it includes the image, close button and invisible margins.
tap_down_event_on_title_ = base::nullopt;
if (IsNewOverviewUi() &&
location_in_screen.y() < background_view_->GetBoundsInScreen().bottom()) {
tap_down_event_on_title_ = base::make_optional(location_in_screen);
return;
}
StartDrag(); StartDrag();
window_selector_->InitiateDrag(this, location_in_screen); window_selector_->InitiateDrag(this, location_in_screen);
} }
void WindowSelectorItem::HandleReleaseEvent( void WindowSelectorItem::HandleReleaseEvent(
const gfx::Point& location_in_screen) { const gfx::Point& location_in_screen) {
if (tap_down_event_on_title_) {
SelectWindowIfBelowDistanceThreshold(location_in_screen);
return;
}
EndDrag(); EndDrag();
window_selector_->CompleteDrag(this, location_in_screen); window_selector_->CompleteDrag(this, location_in_screen);
} }
void WindowSelectorItem::HandleDragEvent(const gfx::Point& location_in_screen) { void WindowSelectorItem::HandleDragEvent(const gfx::Point& location_in_screen) {
if (tap_down_event_on_title_)
return;
window_selector_->Drag(this, location_in_screen); window_selector_->Drag(this, location_in_screen);
} }
void WindowSelectorItem::ActivateDraggedWindow( void WindowSelectorItem::ActivateDraggedWindow() {
const gfx::Point& location_in_screen) {
if (tap_down_event_on_title_) {
SelectWindowIfBelowDistanceThreshold(location_in_screen);
return;
}
DCHECK_EQ(this, window_selector_->window_drag_controller()->item()); DCHECK_EQ(this, window_selector_->window_drag_controller()->item());
window_selector_->ActivateDraggedWindow(); window_selector_->ActivateDraggedWindow();
} }
void WindowSelectorItem::ResetDraggedWindowGesture() { void WindowSelectorItem::ResetDraggedWindowGesture() {
OnSelectorItemDragEnded(); OnSelectorItemDragEnded();
if (tap_down_event_on_title_)
return;
DCHECK_EQ(this, window_selector_->window_drag_controller()->item()); DCHECK_EQ(this, window_selector_->window_drag_controller()->item());
window_selector_->ResetDraggedWindowGesture(); window_selector_->ResetDraggedWindowGesture();
} }
...@@ -1329,16 +1302,6 @@ void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { ...@@ -1329,16 +1302,6 @@ void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) {
widget_ptr->SetOpacity(0.f); widget_ptr->SetOpacity(0.f);
} }
void WindowSelectorItem::SelectWindowIfBelowDistanceThreshold(
const gfx::Point& event_location) {
DCHECK(tap_down_event_on_title_.has_value());
const gfx::Vector2d distance =
event_location - tap_down_event_on_title_.value();
if (distance.Length() < OverviewWindowDragController::kMinimumDragOffset)
window_selector_->SelectWindow(this);
}
gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() {
return background_view_ ? background_view_->animation() : nullptr; return background_view_ ? background_view_->animation() : nullptr;
} }
......
...@@ -182,7 +182,7 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -182,7 +182,7 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
void HandlePressEvent(const gfx::Point& location_in_screen); void HandlePressEvent(const gfx::Point& location_in_screen);
void HandleReleaseEvent(const gfx::Point& location_in_screen); void HandleReleaseEvent(const gfx::Point& location_in_screen);
void HandleDragEvent(const gfx::Point& location_in_screen); void HandleDragEvent(const gfx::Point& location_in_screen);
void ActivateDraggedWindow(const gfx::Point& location_in_screen); void ActivateDraggedWindow();
void ResetDraggedWindowGesture(); void ResetDraggedWindowGesture();
// Sets the bounds of the window shadow. If |bounds_in_screen| is nullopt, // Sets the bounds of the window shadow. If |bounds_in_screen| is nullopt,
...@@ -308,11 +308,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -308,11 +308,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// when the item is selected. // when the item is selected.
bool selected_; bool selected_;
// Has a value if last seen tap down event was on the title bar. Behavior of
// subsequent drags/tap up differ if the original event was on the overview
// title.
base::Optional<gfx::Point> tap_down_event_on_title_;
// A widget that covers the |transform_window_|. The widget has // A widget that covers the |transform_window_|. The widget has
// |caption_container_view_| as its contents view. The widget is backed by a // |caption_container_view_| as its contents view. The widget is backed by a
// NOT_DRAWN layer since most of its surface is transparent. // NOT_DRAWN layer since most of its surface is transparent.
...@@ -373,8 +368,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -373,8 +368,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// rounded edges mask applied on entering overview window. // rounded edges mask applied on entering overview window.
std::unique_ptr<ui::Shadow> shadow_; std::unique_ptr<ui::Shadow> shadow_;
bool event_on_title_ = false;
DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
}; };
......
...@@ -4068,47 +4068,6 @@ TEST_F(SplitViewWindowSelectorTest, ...@@ -4068,47 +4068,6 @@ TEST_F(SplitViewWindowSelectorTest,
EXPECT_FALSE(wm::IsActiveWindow(window1.get())); EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
} }
// Verify that events that originate on the overview title bar will not allow
// the item to be dragged or enter splitview, but will still be able to select a
// window.
TEST_F(SplitViewWindowSelectorTest, EventsOnOverviewTitleBar) {
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
ToggleOverview();
const int grid_index = 0;
WindowSelectorItem* selector_item1 =
GetWindowItemForWindow(grid_index, window1.get());
const gfx::Rect original_bounds = selector_item1->target_bounds();
// Click on the title of the selector item.
const gfx::Point point_on_title =
GetLabelView(selector_item1)->GetBoundsInScreen().CenterPoint();
GetEventGenerator().MoveMouseTo(point_on_title);
GetEventGenerator().PressLeftButton();
// Verify that dragging the mouse does change the selector item bounds.
GetEventGenerator().MoveMouseTo(0, 0);
EXPECT_EQ(original_bounds, selector_item1->target_bounds());
// We dragged into the left snap region. Verify that after releasing the
// mouse, we do not enter split view mode, which would be the case if we did
// not click on the title.
GetEventGenerator().ReleaseLeftButton();
EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive());
// Verify that clicking on the title still exits overview and activates the
// associated window of the clicked selector item.
ASSERT_TRUE(window_selector());
GetEventGenerator().MoveMouseTo(point_on_title);
GetEventGenerator().PressLeftButton();
GetEventGenerator().ReleaseLeftButton();
EXPECT_FALSE(window_selector());
EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
}
// Test that when splitview mode is active, minimizing one of the snapped window // Test that when splitview mode is active, minimizing one of the snapped window
// will insert the minimized window back to overview mode if overview mode is // will insert the minimized window back to overview mode if overview mode is
// active at the moment. // active at the moment.
......
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