| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 if (IsPopupOrTransient(child)) | 687 if (IsPopupOrTransient(child)) |
| 687 return; | 688 return; |
| 688 // Dragged windows are already observed by StartDragging and do not change | 689 // Dragged windows are already observed by StartDragging and do not change |
| 689 // docked alignment during the drag. | 690 // docked alignment during the drag. |
| 690 if (child == dragged_window_) | 691 if (child == dragged_window_) |
| 691 return; | 692 return; |
| 692 // If this is the first window getting docked - update alignment. | 693 // If this is the first window getting docked - update alignment. |
| 693 // A window can be added without proper bounds when window is moved to another | 694 // A window can be added without proper bounds when window is moved to another |
| 694 // display via API or due to display configuration change, so the alignment | 695 // display via API or due to display configuration change, so the alignment |
| 695 // is set based on which edge is closer in the new display. | 696 // is set based on which edge is closer in the new display. |
| 696 if (alignment_ == DOCKED_ALIGNMENT_NONE) | 697 if (alignment_ == DOCKED_ALIGNMENT_NONE) { |
| 697 alignment_ = GetEdgeNearestWindow(child); | 698 alignment_ = preferred_alignment_ != DOCKED_ALIGNMENT_NONE ? |
| 699 preferred_alignment_ : GetEdgeNearestWindow(child); |
| 700 } |
| 698 MaybeMinimizeChildrenExcept(child); | 701 MaybeMinimizeChildrenExcept(child); |
| 699 child->AddObserver(this); | 702 child->AddObserver(this); |
| 700 wm::GetWindowState(child)->AddObserver(this); | 703 wm::GetWindowState(child)->AddObserver(this); |
| 701 Relayout(); | 704 Relayout(); |
| 702 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 705 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 703 } | 706 } |
| 704 | 707 |
| 705 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 708 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
| 706 if (IsPopupOrTransient(child)) | 709 if (IsPopupOrTransient(child)) |
| 707 return; | 710 return; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 if (!window_state->IsDocked()) { | 851 if (!window_state->IsDocked()) { |
| 849 if (window != dragged_window_) { | 852 if (window != dragged_window_) { |
| 850 UndockWindow(window); | 853 UndockWindow(window); |
| 851 if (window_state->IsMaximizedOrFullscreen()) | 854 if (window_state->IsMaximizedOrFullscreen()) |
| 852 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 855 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 853 } | 856 } |
| 854 } else if (window_state->IsMinimized()) { | 857 } else if (window_state->IsMinimized()) { |
| 855 MinimizeDockedWindow(window_state); | 858 MinimizeDockedWindow(window_state); |
| 856 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { | 859 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { |
| 857 RestoreDockedWindow(window_state); | 860 RestoreDockedWindow(window_state); |
| 861 } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) { |
| 862 NOTREACHED() << "Minimized window in docked layout manager"; |
| 858 } | 863 } |
| 859 } | 864 } |
| 860 | 865 |
| 861 ///////////////////////////////////////////////////////////////////////////// | 866 ///////////////////////////////////////////////////////////////////////////// |
| 862 // DockedWindowLayoutManager, WindowObserver implementation: | 867 // DockedWindowLayoutManager, WindowObserver implementation: |
| 863 | 868 |
| 864 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 869 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
| 865 aura::Window* window, | 870 aura::Window* window, |
| 866 const gfx::Rect& old_bounds, | 871 const gfx::Rect& old_bounds, |
| 867 const gfx::Rect& new_bounds) { | 872 const gfx::Rect& new_bounds) { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 | 1355 |
| 1351 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1356 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1352 const gfx::Rect& keyboard_bounds) { | 1357 const gfx::Rect& keyboard_bounds) { |
| 1353 // This bounds change will have caused a change to the Shelf which does not | 1358 // This bounds change will have caused a change to the Shelf which does not |
| 1354 // propagate automatically to this class, so manually recalculate bounds. | 1359 // propagate automatically to this class, so manually recalculate bounds. |
| 1355 Relayout(); | 1360 Relayout(); |
| 1356 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1361 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1357 } | 1362 } |
| 1358 | 1363 |
| 1359 } // namespace ash | 1364 } // namespace ash |
| OLD | NEW |