| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 !wm::GetWindowState(window)->IsMinimized() && | 94 !wm::GetWindowState(window)->IsMinimized() && |
| 95 !IsPopupOrTransient(window)); | 95 !IsPopupOrTransient(window)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void UndockWindow(aura::Window* window) { | 98 void UndockWindow(aura::Window* window) { |
| 99 gfx::Rect previous_bounds = window->bounds(); | 99 gfx::Rect previous_bounds = window->bounds(); |
| 100 aura::Window* previous_parent = window->parent(); | 100 aura::Window* previous_parent = window->parent(); |
| 101 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); | 101 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); |
| 102 if (window->parent() != previous_parent) | 102 if (window->parent() != previous_parent) |
| 103 wm::ReparentTransientChildrenOfChild(window->parent(), window); | 103 wm::ReparentTransientChildrenOfChild(window->parent(), window); |
| 104 wm::WindowState* window_state = wm::GetWindowState(window); |
| 105 if (window_state->window_show_type() == wm::SHOW_TYPE_LEFT_SNAPPED || |
| 106 window_state->window_show_type() == wm::SHOW_TYPE_RIGHT_SNAPPED) { |
| 107 // Windows that are right- or left-snapped out of the dock are have their |
| 108 // bounds already set and the animation started when the undocking happens. |
| 109 // There is no need to reset the layer bounds since correct original bounds |
| 110 // were used for animation. |
| 111 return; |
| 112 } |
| 104 // Start maximize or fullscreen (affecting packaged apps) animation from | 113 // Start maximize or fullscreen (affecting packaged apps) animation from |
| 105 // previous window bounds. | 114 // previous window bounds. |
| 106 window->layer()->SetBounds(previous_bounds); | 115 window->layer()->SetBounds(previous_bounds); |
| 107 } | 116 } |
| 108 | 117 |
| 109 // Returns width that is as close as possible to |target_width| while being | 118 // Returns width that is as close as possible to |target_width| while being |
| 110 // consistent with docked min and max restrictions and respects the |window|'s | 119 // consistent with docked min and max restrictions and respects the |window|'s |
| 111 // minimum and maximum size. | 120 // minimum and maximum size. |
| 112 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) { | 121 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) { |
| 113 if (!wm::GetWindowState(window)->CanResize()) { | 122 if (!wm::GetWindowState(window)->CanResize()) { |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 wm::WindowShowType old_type) { | 567 wm::WindowShowType old_type) { |
| 559 aura::Window* window = window_state->window(); | 568 aura::Window* window = window_state->window(); |
| 560 if (IsPopupOrTransient(window)) | 569 if (IsPopupOrTransient(window)) |
| 561 return; | 570 return; |
| 562 // The window property will still be set, but no actual change will occur | 571 // The window property will still be set, but no actual change will occur |
| 563 // until OnFullscreenStateChange is called when exiting fullscreen. | 572 // until OnFullscreenStateChange is called when exiting fullscreen. |
| 564 if (in_fullscreen_) | 573 if (in_fullscreen_) |
| 565 return; | 574 return; |
| 566 if (window_state->IsMinimized()) { | 575 if (window_state->IsMinimized()) { |
| 567 MinimizeDockedWindow(window_state); | 576 MinimizeDockedWindow(window_state); |
| 568 } else if (window_state->IsMaximizedOrFullscreen()) { | 577 } else if (window_state->IsMaximizedOrFullscreen() || |
| 569 // Reparenting changes the source bounds for the animation if a window is | 578 window_state->window_show_type() == wm::SHOW_TYPE_LEFT_SNAPPED || |
| 570 // visible so hide it here and show later when it is already in the desktop. | 579 window_state->window_show_type() == wm::SHOW_TYPE_RIGHT_SNAPPED) { |
| 571 UndockWindow(window); | 580 if (window != dragged_window_) { |
| 572 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 581 UndockWindow(window); |
| 582 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 583 } |
| 573 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { | 584 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { |
| 574 RestoreDockedWindow(window_state); | 585 RestoreDockedWindow(window_state); |
| 575 } | 586 } |
| 576 } | 587 } |
| 577 | 588 |
| 578 ///////////////////////////////////////////////////////////////////////////// | 589 ///////////////////////////////////////////////////////////////////////////// |
| 579 // DockLayoutManager, WindowObserver implementation: | 590 // DockLayoutManager, WindowObserver implementation: |
| 580 | 591 |
| 581 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 592 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
| 582 aura::Window* window, | 593 aura::Window* window, |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1073 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1063 const gfx::Rect& keyboard_bounds) { | 1074 const gfx::Rect& keyboard_bounds) { |
| 1064 // This bounds change will have caused a change to the Shelf which does not | 1075 // This bounds change will have caused a change to the Shelf which does not |
| 1065 // propagate automatically to this class, so manually recalculate bounds. | 1076 // propagate automatically to this class, so manually recalculate bounds. |
| 1066 Relayout(); | 1077 Relayout(); |
| 1067 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1078 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1068 } | 1079 } |
| 1069 | 1080 |
| 1070 } // namespace internal | 1081 } // namespace internal |
| 1071 } // namespace ash | 1082 } // namespace ash |
| OLD | NEW |