Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 in_layout_(false), | 409 in_layout_(false), |
| 410 dragged_window_(NULL), | 410 dragged_window_(NULL), |
| 411 is_dragged_window_docked_(false), | 411 is_dragged_window_docked_(false), |
| 412 is_dragged_from_dock_(false), | 412 is_dragged_from_dock_(false), |
| 413 shelf_(NULL), | 413 shelf_(NULL), |
| 414 workspace_controller_(workspace_controller), | 414 workspace_controller_(workspace_controller), |
| 415 in_fullscreen_(workspace_controller_->GetWindowState() == | 415 in_fullscreen_(workspace_controller_->GetWindowState() == |
| 416 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 416 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
| 417 docked_width_(0), | 417 docked_width_(0), |
| 418 alignment_(DOCKED_ALIGNMENT_NONE), | 418 alignment_(DOCKED_ALIGNMENT_NONE), |
| 419 preferred_alignment_(DOCKED_ALIGNMENT_NONE), | |
| 419 last_active_window_(NULL), | 420 last_active_window_(NULL), |
| 420 last_action_time_(base::Time::Now()), | 421 last_action_time_(base::Time::Now()), |
| 421 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 422 background_widget_(new DockedBackgroundWidget(dock_container_)) { |
| 422 DCHECK(dock_container); | 423 DCHECK(dock_container); |
| 423 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 424 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 424 AddObserver(this); | 425 AddObserver(this); |
| 425 Shell::GetInstance()->AddShellObserver(this); | 426 Shell::GetInstance()->AddShellObserver(this); |
| 426 } | 427 } |
| 427 | 428 |
| 428 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 429 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 589 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
| 589 aura::Window* window(dock_container_->children()[i]); | 590 aura::Window* window(dock_container_->children()[i]); |
| 590 if (window != query_window && !IsPopupOrTransient(window)) | 591 if (window != query_window && !IsPopupOrTransient(window)) |
| 591 return alignment_; | 592 return alignment_; |
| 592 } | 593 } |
| 593 // No docked windows remain other than possibly the window being queried. | 594 // No docked windows remain other than possibly the window being queried. |
| 594 // Return |NONE| to indicate that windows may get docked on either side. | 595 // Return |NONE| to indicate that windows may get docked on either side. |
| 595 return DOCKED_ALIGNMENT_NONE; | 596 return DOCKED_ALIGNMENT_NONE; |
| 596 } | 597 } |
| 597 | 598 |
| 599 void DockedWindowLayoutManager::SetPreferredAlignment( | |
| 600 DockedAlignment preferred_alignment) { | |
| 601 preferred_alignment_ = preferred_alignment; | |
|
varkha
2014/09/29 21:04:34
This is simple enough to qualify for a header inli
dtapuska
2014/09/30 14:40:49
Done.
| |
| 602 } | |
| 603 | |
| 598 bool DockedWindowLayoutManager::CanDockWindow( | 604 bool DockedWindowLayoutManager::CanDockWindow( |
| 599 aura::Window* window, | 605 aura::Window* window, |
| 600 DockedAlignment desired_alignment) { | 606 DockedAlignment desired_alignment) { |
| 601 // Don't allow interactive docking of windows with transient parents such as | 607 // Don't allow interactive docking of windows with transient parents such as |
| 602 // modal browser dialogs. Prevent docking of panels attached to shelf during | 608 // modal browser dialogs. Prevent docking of panels attached to shelf during |
| 603 // the drag. | 609 // the drag. |
| 604 wm::WindowState* window_state = wm::GetWindowState(window); | 610 wm::WindowState* window_state = wm::GetWindowState(window); |
| 605 bool should_attach_to_shelf = window_state->drag_details() && | 611 bool should_attach_to_shelf = window_state->drag_details() && |
| 606 window_state->drag_details()->should_attach_to_shelf; | 612 window_state->drag_details()->should_attach_to_shelf; |
| 607 if (IsPopupOrTransient(window) || should_attach_to_shelf) | 613 if (IsPopupOrTransient(window) || should_attach_to_shelf) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 if (IsPopupOrTransient(child)) | 691 if (IsPopupOrTransient(child)) |
| 686 return; | 692 return; |
| 687 // Dragged windows are already observed by StartDragging and do not change | 693 // Dragged windows are already observed by StartDragging and do not change |
| 688 // docked alignment during the drag. | 694 // docked alignment during the drag. |
| 689 if (child == dragged_window_) | 695 if (child == dragged_window_) |
| 690 return; | 696 return; |
| 691 // If this is the first window getting docked - update alignment. | 697 // If this is the first window getting docked - update alignment. |
| 692 // A window can be added without proper bounds when window is moved to another | 698 // A window can be added without proper bounds when window is moved to another |
| 693 // display via API or due to display configuration change, so the alignment | 699 // display via API or due to display configuration change, so the alignment |
| 694 // is set based on which edge is closer in the new display. | 700 // is set based on which edge is closer in the new display. |
| 695 if (alignment_ == DOCKED_ALIGNMENT_NONE) | 701 if (alignment_ == DOCKED_ALIGNMENT_NONE) { |
| 696 alignment_ = GetEdgeNearestWindow(child); | 702 alignment_ = preferred_alignment_ != DOCKED_ALIGNMENT_NONE ? |
| 703 preferred_alignment_ : GetEdgeNearestWindow(child); | |
| 704 } | |
| 697 MaybeMinimizeChildrenExcept(child); | 705 MaybeMinimizeChildrenExcept(child); |
| 698 child->AddObserver(this); | 706 child->AddObserver(this); |
| 699 wm::GetWindowState(child)->AddObserver(this); | 707 wm::GetWindowState(child)->AddObserver(this); |
| 700 Relayout(); | 708 Relayout(); |
| 701 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 709 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 702 } | 710 } |
| 703 | 711 |
| 704 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 712 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
| 705 if (IsPopupOrTransient(child)) | 713 if (IsPopupOrTransient(child)) |
| 706 return; | 714 return; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 if (!window_state->IsDocked()) { | 855 if (!window_state->IsDocked()) { |
| 848 if (window != dragged_window_) { | 856 if (window != dragged_window_) { |
| 849 UndockWindow(window); | 857 UndockWindow(window); |
| 850 if (window_state->IsMaximizedOrFullscreen()) | 858 if (window_state->IsMaximizedOrFullscreen()) |
| 851 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 859 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 852 } | 860 } |
| 853 } else if (window_state->IsMinimized()) { | 861 } else if (window_state->IsMinimized()) { |
| 854 MinimizeDockedWindow(window_state); | 862 MinimizeDockedWindow(window_state); |
| 855 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { | 863 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { |
| 856 RestoreDockedWindow(window_state); | 864 RestoreDockedWindow(window_state); |
| 865 } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) { | |
| 866 NOTREACHED() << "Minimized window in docked layout manager"; | |
| 857 } | 867 } |
| 858 } | 868 } |
| 859 | 869 |
| 860 ///////////////////////////////////////////////////////////////////////////// | 870 ///////////////////////////////////////////////////////////////////////////// |
| 861 // DockedWindowLayoutManager, WindowObserver implementation: | 871 // DockedWindowLayoutManager, WindowObserver implementation: |
| 862 | 872 |
| 863 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 873 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
| 864 aura::Window* window, | 874 aura::Window* window, |
| 865 const gfx::Rect& old_bounds, | 875 const gfx::Rect& old_bounds, |
| 866 const gfx::Rect& new_bounds) { | 876 const gfx::Rect& new_bounds) { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1349 | 1359 |
| 1350 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1360 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1351 const gfx::Rect& keyboard_bounds) { | 1361 const gfx::Rect& keyboard_bounds) { |
| 1352 // This bounds change will have caused a change to the Shelf which does not | 1362 // This bounds change will have caused a change to the Shelf which does not |
| 1353 // propagate automatically to this class, so manually recalculate bounds. | 1363 // propagate automatically to this class, so manually recalculate bounds. |
| 1354 Relayout(); | 1364 Relayout(); |
| 1355 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1365 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1356 } | 1366 } |
| 1357 | 1367 |
| 1358 } // namespace ash | 1368 } // namespace ash |
| OLD | NEW |