Commit e0beb2d0 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Toggle overview if during app window dragging.

Bug: 847587
Change-Id: I4f274158d78f8935339c42bbe15b21dbd4a72736
Reviewed-on: https://chromium-review.googlesource.com/1130464
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575063}
parent 5fbc1731
...@@ -66,9 +66,10 @@ bool ShouldExcludeWindowFromOverview(const aura::Window* window) { ...@@ -66,9 +66,10 @@ bool ShouldExcludeWindowFromOverview(const aura::Window* window) {
return true; return true;
} }
// The window that is currently in tab-dragging process should be ignored in // The window that currently being dragged should be ignored in overview grid.
// overview grid. // e.g, a browser window can be dragged through tabs, or app windows can be
if (ash::wm::IsDraggingTabs(window)) // dragged through swiping from the specific top area of the display.
if (wm::GetWindowState(window)->is_dragged())
return true; return true;
return false; return false;
......
...@@ -2173,6 +2173,15 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest { ...@@ -2173,6 +2173,15 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest {
float scroll_delta, float scroll_delta,
aura::Window* window) { aura::Window* window) {
base::TimeTicks timestamp = base::TimeTicks::Now(); base::TimeTicks timestamp = base::TimeTicks::Now();
SendScrollStartAndUpdate(start, scroll_delta, timestamp, window);
EndScrollSequence(start, scroll_delta, timestamp, window);
}
void SendScrollStartAndUpdate(const gfx::Point& start,
float scroll_delta,
base::TimeTicks& timestamp,
aura::Window* window) {
SendGestureEventToController( SendGestureEventToController(
start.x(), start.y(), timestamp, start.x(), start.y(), timestamp,
ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0), window); ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0), window);
...@@ -2182,7 +2191,12 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest { ...@@ -2182,7 +2191,12 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest {
start.x(), start.y() + scroll_delta, timestamp, start.x(), start.y() + scroll_delta, timestamp,
ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 0, scroll_delta), ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 0, scroll_delta),
window); window);
}
void EndScrollSequence(const gfx::Point& start,
float scroll_delta,
base::TimeTicks& timestamp,
aura::Window* window) {
timestamp += base::TimeDelta::FromMilliseconds(100); timestamp += base::TimeDelta::FromMilliseconds(100);
SendGestureEventToController( SendGestureEventToController(
start.x(), start.y() + scroll_delta, timestamp, start.x(), start.y() + scroll_delta, timestamp,
...@@ -2224,8 +2238,18 @@ TEST_F(SplitViewAppDraggingTest, DragMaximizedWindow) { ...@@ -2224,8 +2238,18 @@ TEST_F(SplitViewAppDraggingTest, DragMaximizedWindow) {
// Drag the window long enough (pass one fourth of the screen vertical // Drag the window long enough (pass one fourth of the screen vertical
// height) to snap the window to splitscreen. // height) to snap the window to splitscreen.
SendGestureEvents(gfx::Point(0, 0), display_bounds.height() / 4 + 5, const float long_scroll_delta = display_bounds.height() / 4 + 5;
window.get()); base::TimeTicks timestamp = base::TimeTicks::Now();
gfx::Point start = gfx::Point(0, 0);
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp, window.get());
WindowSelectorController* window_selector_controller =
Shell::Get()->window_selector_controller();
EXPECT_TRUE(window_selector_controller->IsSelecting());
EXPECT_FALSE(
window_selector_controller->window_selector()->IsWindowInOverview(
window.get()));
EndScrollSequence(start, long_scroll_delta, timestamp, window.get());
EXPECT_TRUE(window_selector_controller->IsSelecting());
EXPECT_TRUE(split_view_controller()->IsSplitViewModeActive()); EXPECT_TRUE(split_view_controller()->IsSplitViewModeActive());
EXPECT_EQ(split_view_controller()->left_window(), window.get()); EXPECT_EQ(split_view_controller()->left_window(), window.get());
EXPECT_EQ(split_view_controller()->state(), EXPECT_EQ(split_view_controller()->state(),
...@@ -2238,8 +2262,15 @@ TEST_F(SplitViewAppDraggingTest, DragMaximizedWindow) { ...@@ -2238,8 +2262,15 @@ TEST_F(SplitViewAppDraggingTest, DragMaximizedWindow) {
static_cast<aura::test::TestWindowDelegate*>(window->delegate()); static_cast<aura::test::TestWindowDelegate*>(window->delegate());
delegate->set_minimum_size( delegate->set_minimum_size(
gfx::Size(display_bounds.width() * 0.67f, display_bounds.height())); gfx::Size(display_bounds.width() * 0.67f, display_bounds.height()));
SendGestureEvents(gfx::Point(0, 0), display_bounds.height() / 4 + 5, timestamp = base::TimeTicks::Now();
window.get()); SendScrollStartAndUpdate(start, long_scroll_delta, timestamp, window.get());
window_selector_controller = Shell::Get()->window_selector_controller();
EXPECT_TRUE(window_selector_controller->IsSelecting());
EXPECT_FALSE(
window_selector_controller->window_selector()->IsWindowInOverview(
window.get()));
EndScrollSequence(start, long_scroll_delta, timestamp, window.get());
EXPECT_FALSE(window_selector_controller->IsSelecting());
EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive()); EXPECT_FALSE(split_view_controller()->IsSplitViewModeActive());
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
} }
......
...@@ -4,8 +4,12 @@ ...@@ -4,8 +4,12 @@
#include "ash/wm/tablet_mode/tablet_mode_app_window_drag_controller.h" #include "ash/wm/tablet_mode/tablet_mode_app_window_drag_controller.h"
#include "ash/shell.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/splitview/split_view_drag_indicators.h" #include "ash/wm/splitview/split_view_drag_indicators.h"
#include "ash/wm/tablet_mode/tablet_mode_window_drag_delegate.h" #include "ash/wm/tablet_mode/tablet_mode_window_drag_delegate.h"
#include "ash/wm/window_state.h"
#include "ui/base/hit_test.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
...@@ -36,7 +40,7 @@ bool TabletModeAppWindowDragController::DragWindowFromTop( ...@@ -36,7 +40,7 @@ bool TabletModeAppWindowDragController::DragWindowFromTop(
return true; return true;
} }
if (!is_in_window_drag_) if (!drag_delegate_->dragged_window())
return false; return false;
if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE) { if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE) {
...@@ -58,8 +62,14 @@ void TabletModeAppWindowDragController::StartWindowDrag( ...@@ -58,8 +62,14 @@ void TabletModeAppWindowDragController::StartWindowDrag(
ui::GestureEvent* event) { ui::GestureEvent* event) {
drag_delegate_->OnWindowDragStarted( drag_delegate_->OnWindowDragStarted(
static_cast<aura::Window*>(event->target())); static_cast<aura::Window*>(event->target()));
is_in_window_drag_ = true;
initial_location_in_screen_ = GetEventLocationInScreen(event); initial_location_in_screen_ = GetEventLocationInScreen(event);
wm::GetWindowState(drag_delegate_->dragged_window())
->CreateDragDetails(initial_location_in_screen_, HTCLIENT,
::wm::WINDOW_MOVE_SOURCE_TOUCH);
if (!Shell::Get()->window_selector_controller()->IsSelecting())
Shell::Get()->window_selector_controller()->ToggleOverview();
gesture_drag_amount_.SetPoint(0.f, 0.f); gesture_drag_amount_.SetPoint(0.f, 0.f);
} }
...@@ -92,8 +102,8 @@ void TabletModeAppWindowDragController::EndWindowDrag( ...@@ -92,8 +102,8 @@ void TabletModeAppWindowDragController::EndWindowDrag(
wm::WmToplevelWindowEventHandler::DragResult result) { wm::WmToplevelWindowEventHandler::DragResult result) {
const gfx::Point location_in_screen(GetEventLocationInScreen(event)); const gfx::Point location_in_screen(GetEventLocationInScreen(event));
drag_delegate_->dragged_window()->SetTransform(gfx::Transform()); drag_delegate_->dragged_window()->SetTransform(gfx::Transform());
wm::GetWindowState(drag_delegate_->dragged_window())->DeleteDragDetails();
drag_delegate_->OnWindowDragEnded(result, location_in_screen); drag_delegate_->OnWindowDragEnded(result, location_in_screen);
is_in_window_drag_ = false;
gesture_drag_amount_.SetPoint(0.f, 0.f); gesture_drag_amount_.SetPoint(0.f, 0.f);
} }
......
...@@ -37,10 +37,9 @@ class ASH_EXPORT TabletModeAppWindowDragController { ...@@ -37,10 +37,9 @@ class ASH_EXPORT TabletModeAppWindowDragController {
std::unique_ptr<TabletModeWindowDragDelegate> drag_delegate_; std::unique_ptr<TabletModeWindowDragDelegate> drag_delegate_;
bool is_in_window_drag_ = false;
gfx::Point initial_location_in_screen_; gfx::Point initial_location_in_screen_;
// Tracks the amount of the drag. Only valid if |is_in_window_drag_| is true. // Tracks the amount of the drag. Only valid if window is being dragged.
gfx::PointF gesture_drag_amount_; gfx::PointF gesture_drag_amount_;
DISALLOW_COPY_AND_ASSIGN(TabletModeAppWindowDragController); DISALLOW_COPY_AND_ASSIGN(TabletModeAppWindowDragController);
......
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