summaryrefslogtreecommitdiffstats
path: root/ash/wm/dock
diff options
context:
space:
mode:
authorvarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 06:25:19 +0000
committervarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 06:25:19 +0000
commitd229cdd7b6b5d261b7c8dbbcacadff3728ea27a7 (patch)
tree6c611cfbc0ad70f2ceaac3cec036df9327f857ed /ash/wm/dock
parentf4de0ad835bdfe0a25acce8d16e753d6486308a1 (diff)
downloadchromium_src-d229cdd7b6b5d261b7c8dbbcacadff3728ea27a7.zip
chromium_src-d229cdd7b6b5d261b7c8dbbcacadff3728ea27a7.tar.gz
chromium_src-d229cdd7b6b5d261b7c8dbbcacadff3728ea27a7.tar.bz2
Avoids updating dock alignment when drag is cancelled
BUG=334313 TEST=ash_unittests --gtest_filter=*RevertDockedDragRevertsAttachment* TEST=Manual on Chromebook Review URL: https://codereview.chromium.org/141053002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/dock')
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc34
-rw-r--r--ash/wm/dock/docked_window_resizer.cc9
-rw-r--r--ash/wm/dock/docked_window_resizer.h5
-rw-r--r--ash/wm/dock/docked_window_resizer_unittest.cc31
4 files changed, 55 insertions, 24 deletions
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index fcbecfc..d5a3734 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -464,6 +464,14 @@ void DockedWindowLayoutManager::StartDragging(aura::Window* window) {
if (dragged_window_->parent() != dock_container_) {
dragged_window_->AddObserver(this);
dragged_state->AddObserver(this);
+ } else if (!IsAnyWindowDocked() &&
+ dragged_state->drag_details() &&
+ !(dragged_state->drag_details()->bounds_change &
+ WindowResizer::kBoundsChange_Resizes)) {
+ // If there are no other docked windows clear alignment when a docked window
+ // is moved (but not when it is resized or the window could get undocked
+ // when resized away from the edge while docked).
+ alignment_ = DOCKED_ALIGNMENT_NONE;
}
is_dragged_from_dock_ = window->parent() == dock_container_;
DCHECK(!is_dragged_window_docked_);
@@ -518,6 +526,12 @@ void DockedWindowLayoutManager::FinishDragging(DockedAction action,
views::corewm::SetWindowShowAnimationDuration(dragged_window_,
base::TimeDelta());
} else {
+ // If this is the first window that got docked by a move update alignment.
+ if (alignment_ == DOCKED_ALIGNMENT_NONE) {
+ alignment_ = GetAlignmentOfWindow(dragged_window_);
+ DCHECK(action == DOCKED_ACTION_NONE ||
+ alignment_ != DOCKED_ALIGNMENT_NONE);
+ }
// A window is no longer dragged and is a child.
// When a window becomes a child at drag start this is
// the only opportunity we will have to enforce a window
@@ -657,7 +671,7 @@ void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
// change, so the the alignment may not be valid.
if (alignment_ == DOCKED_ALIGNMENT_NONE) {
alignment_ = GetAlignmentOfWindow(child);
- DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE);
+ DCHECK_NE(DOCKED_ALIGNMENT_NONE, alignment_);
}
MaybeMinimizeChildrenExcept(child);
child->AddObserver(this);
@@ -830,7 +844,7 @@ void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
if (dragged_window_ == window) {
FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
DCHECK(!dragged_window_);
- DCHECK (!is_dragged_window_docked_);
+ DCHECK(!is_dragged_window_docked_);
}
if (window == last_active_window_)
last_active_window_ = NULL;
@@ -985,25 +999,9 @@ void DockedWindowLayoutManager::UpdateDockedWidth(int width) {
void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) {
DCHECK(!is_dragged_window_docked_);
is_dragged_window_docked_ = true;
-
- // If there are no other docked windows update alignment when the window is
- // moved.
- if (!IsAnyWindowDocked() &&
- wm::GetWindowState(dragged_window_)->drag_details() &&
- !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
- WindowResizer::kBoundsChange_Resizes)) {
- alignment_ = DOCKED_ALIGNMENT_NONE;
- }
}
void DockedWindowLayoutManager::OnDraggedWindowUndocked() {
- // If this is the first window getting docked by moving it - update alignment.
- if (!IsAnyWindowDocked() &&
- wm::GetWindowState(dragged_window_)->drag_details() &&
- !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
- WindowResizer::kBoundsChange_Resizes)) {
- alignment_ = GetAlignmentOfWindow(dragged_window_);
- }
DCHECK (is_dragged_window_docked_);
is_dragged_window_docked_ = false;
}
diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc
index 3ee18de..f3e4561 100644
--- a/ash/wm/dock/docked_window_resizer.cc
+++ b/ash/wm/dock/docked_window_resizer.cc
@@ -113,7 +113,7 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
void DockedWindowResizer::CompleteDrag() {
// The root window can change when dragging into a different screen.
next_window_resizer_->CompleteDrag();
- FinishedDragging();
+ FinishedDragging(aura::client::MOVE_SUCCESSFUL);
}
void DockedWindowResizer::RevertDrag() {
@@ -126,7 +126,7 @@ void DockedWindowResizer::RevertDrag() {
else
dock_layout_->UndockDraggedWindow();
}
- FinishedDragging();
+ FinishedDragging(aura::client::MOVE_CANCELED);
}
DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer,
@@ -213,7 +213,8 @@ void DockedWindowResizer::StartedDragging() {
dock_layout_->DockDraggedWindow(GetTarget());
}
-void DockedWindowResizer::FinishedDragging() {
+void DockedWindowResizer::FinishedDragging(
+ aura::client::WindowMoveResult move_result) {
if (!did_move_or_resize_)
return;
did_move_or_resize_ = false;
@@ -245,7 +246,7 @@ void DockedWindowResizer::FinishedDragging() {
DockedAction action = MaybeReparentWindowOnDragCompletion(is_resized,
is_attached_panel);
dock_layout_->FinishDragging(
- action,
+ move_result == aura::client::MOVE_CANCELED ? DOCKED_ACTION_NONE : action,
details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH);
diff --git a/ash/wm/dock/docked_window_resizer.h b/ash/wm/dock/docked_window_resizer.h
index 6614e2d..7797424 100644
--- a/ash/wm/dock/docked_window_resizer.h
+++ b/ash/wm/dock/docked_window_resizer.h
@@ -58,8 +58,9 @@ class ASH_EXPORT DockedWindowResizer : public WindowResizer {
void StartedDragging();
// Informs the DockLayoutManager that the drag is complete if it was informed
- // of the drag start.
- void FinishedDragging();
+ // of the drag start. |move_result| specifies if the drag was completed or
+ // reverted.
+ void FinishedDragging(aura::client::WindowMoveResult move_result);
// Reparents dragged window as necessary to the docked container or back to
// workspace at the end of the drag. Calculates and returns action taken that
diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc
index 529efad..1aac42b 100644
--- a/ash/wm/dock/docked_window_resizer_unittest.cc
+++ b/ash/wm/dock/docked_window_resizer_unittest.cc
@@ -624,6 +624,11 @@ TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
if (!SupportsHostWindowResize())
return;
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
+ aura::Window* dock_container = Shell::GetContainer(
+ window->GetRootWindow(),
+ kShellWindowId_DockedContainer);
+ DockedWindowLayoutManager* manager =
+ static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager());
int previous_container_id = window->parent()->id();
// Drag the window out but revert the drag
ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
@@ -631,6 +636,32 @@ TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
DragRevert();
EXPECT_EQ(previous_container_id, window->parent()->id());
+ EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
+
+ // Drag a window to the left so that it overlaps the screen edge.
+ ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
+ window.get(),
+ window->bounds().width()/2 + 10,
+ 0));
+ DragMove(-50 - window->bounds().x(), 50 - window->bounds().y());
+ DragEnd();
+ // The window now overlaps the left screen edge but is not docked.
+ EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
+ EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
+ EXPECT_LT(window->bounds().x(), 0);
+ EXPECT_GT(window->bounds().right(), 0);
+
+ // Drag the window further left and revert the drag.
+ ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
+ window.get(),
+ window->bounds().width()/2 + 10,
+ 0));
+ DragMove(-10, 10);
+ DragRevert();
+ // The window should be in default container and not docked.
+ EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
+ // Docked area alignment should be cleared.
+ EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
}
// Move a docked window to the second display