Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 141053002: Avoids updating dock alignment when drag is cancelled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoids updating dock alignment when drag is cancelled (test) Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 void DockedWindowLayoutManager::RemoveObserver( 452 void DockedWindowLayoutManager::RemoveObserver(
453 DockedWindowLayoutManagerObserver* observer) { 453 DockedWindowLayoutManagerObserver* observer) {
454 observer_list_.RemoveObserver(observer); 454 observer_list_.RemoveObserver(observer);
455 } 455 }
456 456
457 void DockedWindowLayoutManager::StartDragging(aura::Window* window) { 457 void DockedWindowLayoutManager::StartDragging(aura::Window* window) {
458 DCHECK(!dragged_window_); 458 DCHECK(!dragged_window_);
459 dragged_window_ = window; 459 dragged_window_ = window;
460 DCHECK(!IsPopupOrTransient(window)); 460 DCHECK(!IsPopupOrTransient(window));
461
462 // If there are no other docked windows clear alignment when a docked window
463 // is moved.
464 if (dragged_window_->parent() == dock_container_ &&
465 !IsAnyWindowDocked() &&
466 wm::GetWindowState(dragged_window_)->drag_details() &&
467 !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
468 WindowResizer::kBoundsChange_Resizes)) {
469 alignment_ = DOCKED_ALIGNMENT_NONE;
470 }
461 // Start observing a window unless it is docked container's child in which 471 // Start observing a window unless it is docked container's child in which
462 // case it is already observed. 472 // case it is already observed.
463 wm::WindowState* dragged_state = wm::GetWindowState(dragged_window_); 473 wm::WindowState* dragged_state = wm::GetWindowState(dragged_window_);
464 if (dragged_window_->parent() != dock_container_) { 474 if (dragged_window_->parent() != dock_container_) {
465 dragged_window_->AddObserver(this); 475 dragged_window_->AddObserver(this);
466 dragged_state->AddObserver(this); 476 dragged_state->AddObserver(this);
467 } 477 }
468 is_dragged_from_dock_ = window->parent() == dock_container_; 478 is_dragged_from_dock_ = window->parent() == dock_container_;
469 DCHECK(!is_dragged_window_docked_); 479 DCHECK(!is_dragged_window_docked_);
470 480
(...skipping 29 matching lines...) Expand all
500 is_dragged_from_dock_ = false; 510 is_dragged_from_dock_ = false;
501 } 511 }
502 512
503 void DockedWindowLayoutManager::FinishDragging(DockedAction action, 513 void DockedWindowLayoutManager::FinishDragging(DockedAction action,
504 DockedActionSource source) { 514 DockedActionSource source) {
505 DCHECK(dragged_window_); 515 DCHECK(dragged_window_);
506 DCHECK(!IsPopupOrTransient(dragged_window_)); 516 DCHECK(!IsPopupOrTransient(dragged_window_));
507 if (is_dragged_window_docked_) 517 if (is_dragged_window_docked_)
508 OnDraggedWindowUndocked(); 518 OnDraggedWindowUndocked();
509 DCHECK (!is_dragged_window_docked_); 519 DCHECK (!is_dragged_window_docked_);
520
521 // If this is the first window getting docked by moving it - update alignment.
522 if (dragged_window_->parent() == dock_container_ &&
523 !IsAnyWindowDocked() &&
524 wm::GetWindowState(dragged_window_)->drag_details() &&
525 !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
526 WindowResizer::kBoundsChange_Resizes)) {
pkotwicz 2014/01/16 21:43:27 I wonder whether it is possible to have a new func
varkha 2014/01/16 23:34:14 I will try to use the "closest to edge" logic when
527 alignment_ = GetAlignmentOfWindow(dragged_window_);
528 }
510 // Stop observing a window unless it is docked container's child in which 529 // Stop observing a window unless it is docked container's child in which
511 // case it needs to keep being observed after the drag completes. 530 // case it needs to keep being observed after the drag completes.
512 if (dragged_window_->parent() != dock_container_) { 531 if (dragged_window_->parent() != dock_container_) {
513 dragged_window_->RemoveObserver(this); 532 dragged_window_->RemoveObserver(this);
514 wm::GetWindowState(dragged_window_)->RemoveObserver(this); 533 wm::GetWindowState(dragged_window_)->RemoveObserver(this);
515 if (last_active_window_ == dragged_window_) 534 if (last_active_window_ == dragged_window_)
516 last_active_window_ = NULL; 535 last_active_window_ = NULL;
517 536
518 views::corewm::SetWindowShowAnimationDuration(dragged_window_, 537 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
519 base::TimeDelta()); 538 base::TimeDelta());
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 void DockedWindowLayoutManager::UpdateDockedWidth(int width) { 997 void DockedWindowLayoutManager::UpdateDockedWidth(int width) {
979 if (docked_width_ == width) 998 if (docked_width_ == width)
980 return; 999 return;
981 docked_width_ = width; 1000 docked_width_ = width;
982 UMA_HISTOGRAM_COUNTS_10000("Ash.Dock.Width", docked_width_); 1001 UMA_HISTOGRAM_COUNTS_10000("Ash.Dock.Width", docked_width_);
983 } 1002 }
984 1003
985 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) { 1004 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) {
986 DCHECK(!is_dragged_window_docked_); 1005 DCHECK(!is_dragged_window_docked_);
987 is_dragged_window_docked_ = true; 1006 is_dragged_window_docked_ = true;
988
989 // If there are no other docked windows update alignment when the window is
990 // moved.
991 if (!IsAnyWindowDocked() &&
992 wm::GetWindowState(dragged_window_)->drag_details() &&
993 !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
994 WindowResizer::kBoundsChange_Resizes)) {
995 alignment_ = DOCKED_ALIGNMENT_NONE;
996 }
997 } 1007 }
998 1008
999 void DockedWindowLayoutManager::OnDraggedWindowUndocked() { 1009 void DockedWindowLayoutManager::OnDraggedWindowUndocked() {
1000 // If this is the first window getting docked by moving it - update alignment.
1001 if (!IsAnyWindowDocked() &&
1002 wm::GetWindowState(dragged_window_)->drag_details() &&
1003 !(wm::GetWindowState(dragged_window_)->drag_details()->bounds_change &
1004 WindowResizer::kBoundsChange_Resizes)) {
1005 alignment_ = GetAlignmentOfWindow(dragged_window_);
1006 }
1007 DCHECK (is_dragged_window_docked_); 1010 DCHECK (is_dragged_window_docked_);
1008 is_dragged_window_docked_ = false; 1011 is_dragged_window_docked_ = false;
1009 } 1012 }
1010 1013
1011 bool DockedWindowLayoutManager::IsAnyWindowDocked() { 1014 bool DockedWindowLayoutManager::IsAnyWindowDocked() {
1012 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE; 1015 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE;
1013 } 1016 }
1014 1017
1015 void DockedWindowLayoutManager::Relayout() { 1018 void DockedWindowLayoutManager::Relayout() {
1016 if (in_layout_) 1019 if (in_layout_)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1308 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1306 const gfx::Rect& keyboard_bounds) { 1309 const gfx::Rect& keyboard_bounds) {
1307 // This bounds change will have caused a change to the Shelf which does not 1310 // This bounds change will have caused a change to the Shelf which does not
1308 // propagate automatically to this class, so manually recalculate bounds. 1311 // propagate automatically to this class, so manually recalculate bounds.
1309 Relayout(); 1312 Relayout();
1310 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1313 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1311 } 1314 }
1312 1315
1313 } // namespace internal 1316 } // namespace internal
1314 } // namespace ash 1317 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_resizer.h » ('j') | ash/wm/dock/docked_window_resizer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698