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

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 (comments) 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
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_resizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Start observing a window unless it is docked container's child in which 461 // Start observing a window unless it is docked container's child in which
462 // case it is already observed. 462 // case it is already observed.
463 wm::WindowState* dragged_state = wm::GetWindowState(dragged_window_); 463 wm::WindowState* dragged_state = wm::GetWindowState(dragged_window_);
464 if (dragged_window_->parent() != dock_container_) { 464 if (dragged_window_->parent() != dock_container_) {
465 dragged_window_->AddObserver(this); 465 dragged_window_->AddObserver(this);
466 dragged_state->AddObserver(this); 466 dragged_state->AddObserver(this);
467 } else if (!IsAnyWindowDocked() &&
pkotwicz 2014/01/17 00:12:18 The reason that we check |DragDetails::bounds_chan
varkha 2014/01/17 01:05:28 Done.
468 dragged_state->drag_details() &&
469 !(dragged_state->drag_details()->bounds_change &
470 WindowResizer::kBoundsChange_Resizes)) {
471 // If there are no other docked windows clear alignment when a docked window
472 // is moved.
473 alignment_ = DOCKED_ALIGNMENT_NONE;
467 } 474 }
468 is_dragged_from_dock_ = window->parent() == dock_container_; 475 is_dragged_from_dock_ = window->parent() == dock_container_;
469 DCHECK(!is_dragged_window_docked_); 476 DCHECK(!is_dragged_window_docked_);
470 477
471 // Resize all windows that are flush with the dock edge together if one of 478 // Resize all windows that are flush with the dock edge together if one of
472 // them gets resized. 479 // them gets resized.
473 if (dragged_window_->bounds().width() == docked_width_ && 480 if (dragged_window_->bounds().width() == docked_width_ &&
474 (dragged_state->drag_details()->bounds_change & 481 (dragged_state->drag_details()->bounds_change &
475 WindowResizer::kBoundsChange_Resizes) && 482 WindowResizer::kBoundsChange_Resizes) &&
476 (dragged_state->drag_details()->size_change_direction & 483 (dragged_state->drag_details()->size_change_direction &
(...skipping 25 matching lines...) Expand all
502 509
503 void DockedWindowLayoutManager::FinishDragging(DockedAction action, 510 void DockedWindowLayoutManager::FinishDragging(DockedAction action,
504 DockedActionSource source) { 511 DockedActionSource source) {
505 DCHECK(dragged_window_); 512 DCHECK(dragged_window_);
506 DCHECK(!IsPopupOrTransient(dragged_window_)); 513 DCHECK(!IsPopupOrTransient(dragged_window_));
507 if (is_dragged_window_docked_) 514 if (is_dragged_window_docked_)
508 OnDraggedWindowUndocked(); 515 OnDraggedWindowUndocked();
509 DCHECK (!is_dragged_window_docked_); 516 DCHECK (!is_dragged_window_docked_);
510 // Stop observing a window unless it is docked container's child in which 517 // 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. 518 // case it needs to keep being observed after the drag completes.
519 wm::WindowState* dragged_state = wm::GetWindowState(dragged_window_);
pkotwicz 2014/01/17 00:12:18 Nit: Move initialization of |dragged_state| to lin
varkha 2014/01/17 01:05:28 Done. No need to change this since it is only used
512 if (dragged_window_->parent() != dock_container_) { 520 if (dragged_window_->parent() != dock_container_) {
513 dragged_window_->RemoveObserver(this); 521 dragged_window_->RemoveObserver(this);
514 wm::GetWindowState(dragged_window_)->RemoveObserver(this); 522 dragged_state->RemoveObserver(this);
515 if (last_active_window_ == dragged_window_) 523 if (last_active_window_ == dragged_window_)
516 last_active_window_ = NULL; 524 last_active_window_ = NULL;
517 525
518 views::corewm::SetWindowShowAnimationDuration(dragged_window_, 526 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
519 base::TimeDelta()); 527 base::TimeDelta());
520 } else { 528 } else {
529 // If this is the first window that got docked by a move - update alignment.
pkotwicz 2014/01/17 00:12:18 Nit: No hyphen
varkha 2014/01/17 01:05:28 Done.
530 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
531 alignment_ = GetAlignmentOfWindow(dragged_window_);
532 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE);
pkotwicz 2014/01/17 00:12:18 Nit: DCHECK_NE
pkotwicz 2014/01/17 00:50:45 The DCHECK() can fail when FinishDragging() is cal
varkha 2014/01/17 01:05:28 Done. When window is destroyed while it is being d
533 }
521 // A window is no longer dragged and is a child. 534 // A window is no longer dragged and is a child.
522 // When a window becomes a child at drag start this is 535 // When a window becomes a child at drag start this is
523 // the only opportunity we will have to enforce a window 536 // the only opportunity we will have to enforce a window
524 // count limit so do it here. 537 // count limit so do it here.
525 MaybeMinimizeChildrenExcept(dragged_window_); 538 MaybeMinimizeChildrenExcept(dragged_window_);
526 539
527 views::corewm::SetWindowShowAnimationDuration(dragged_window_, 540 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
528 base::TimeDelta::FromMilliseconds(kFadeDurationMs)); 541 base::TimeDelta::FromMilliseconds(kFadeDurationMs));
529 } 542 }
530 dragged_window_ = NULL; 543 dragged_window_ = NULL;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 void DockedWindowLayoutManager::UpdateDockedWidth(int width) { 991 void DockedWindowLayoutManager::UpdateDockedWidth(int width) {
979 if (docked_width_ == width) 992 if (docked_width_ == width)
980 return; 993 return;
981 docked_width_ = width; 994 docked_width_ = width;
982 UMA_HISTOGRAM_COUNTS_10000("Ash.Dock.Width", docked_width_); 995 UMA_HISTOGRAM_COUNTS_10000("Ash.Dock.Width", docked_width_);
983 } 996 }
984 997
985 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) { 998 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) {
986 DCHECK(!is_dragged_window_docked_); 999 DCHECK(!is_dragged_window_docked_);
987 is_dragged_window_docked_ = true; 1000 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 } 1001 }
998 1002
999 void DockedWindowLayoutManager::OnDraggedWindowUndocked() { 1003 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_); 1004 DCHECK (is_dragged_window_docked_);
1008 is_dragged_window_docked_ = false; 1005 is_dragged_window_docked_ = false;
1009 } 1006 }
1010 1007
1011 bool DockedWindowLayoutManager::IsAnyWindowDocked() { 1008 bool DockedWindowLayoutManager::IsAnyWindowDocked() {
1012 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE; 1009 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE;
1013 } 1010 }
1014 1011
1015 void DockedWindowLayoutManager::Relayout() { 1012 void DockedWindowLayoutManager::Relayout() {
1016 if (in_layout_) 1013 if (in_layout_)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1302 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1306 const gfx::Rect& keyboard_bounds) { 1303 const gfx::Rect& keyboard_bounds) {
1307 // This bounds change will have caused a change to the Shelf which does not 1304 // This bounds change will have caused a change to the Shelf which does not
1308 // propagate automatically to this class, so manually recalculate bounds. 1305 // propagate automatically to this class, so manually recalculate bounds.
1309 Relayout(); 1306 Relayout();
1310 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1307 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1311 } 1308 }
1312 1309
1313 } // namespace internal 1310 } // namespace internal
1314 } // namespace ash 1311 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698