| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/maximize_mode/maximize_mode_window_state.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_window_state.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/screen_util.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 12 #include "ash/wm/screen_pinning_controller.h" | 13 #include "ash/wm/screen_pinning_controller.h" |
| 13 #include "ash/wm/window_animation_types.h" | 14 #include "ash/wm/window_animation_types.h" |
| 14 #include "ash/wm/window_state_util.h" | 15 #include "ash/wm/window_state_util.h" |
| 15 #include "ash/wm/wm_event.h" | 16 #include "ash/wm/wm_event.h" |
| 16 #include "ash/wm/wm_screen_util.h" | |
| 17 #include "ash/wm_window.h" | 17 #include "ash/wm_window.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Returns the biggest possible size for a window which is about to be | 24 // Returns the biggest possible size for a window which is about to be |
| 25 // maximized. | 25 // maximized. |
| 26 gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) { | 26 gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) { |
| 27 DCHECK(window_state->CanMaximize() || window_state->CanResize()); | 27 DCHECK(window_state->CanMaximize() || window_state->CanResize()); |
| 28 | 28 |
| 29 gfx::Size workspace_size = | 29 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( |
| 30 wm::GetMaximizedWindowBoundsInParent(window_state->window()).size(); | 30 window_state->window()->aura_window()) |
| 31 .size(); |
| 31 | 32 |
| 32 gfx::Size size = window_state->window()->GetMaximumSize(); | 33 gfx::Size size = window_state->window()->GetMaximumSize(); |
| 33 if (size.IsEmpty()) | 34 if (size.IsEmpty()) |
| 34 return workspace_size; | 35 return workspace_size; |
| 35 | 36 |
| 36 size.SetToMin(workspace_size); | 37 size.SetToMin(workspace_size); |
| 37 return size; | 38 return size; |
| 38 } | 39 } |
| 39 | 40 |
| 40 // Returns the centered bounds of the given bounds in the work area. | 41 // Returns the centered bounds of the given bounds in the work area. |
| 41 gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent, | 42 gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent, |
| 42 wm::WindowState* state_object) { | 43 wm::WindowState* state_object) { |
| 43 gfx::Rect work_area_in_parent = | 44 gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 44 wm::GetDisplayWorkAreaBoundsInParent(state_object->window()); | 45 state_object->window()->aura_window()); |
| 45 work_area_in_parent.ClampToCenteredSize(bounds_in_parent.size()); | 46 work_area_in_parent.ClampToCenteredSize(bounds_in_parent.size()); |
| 46 return work_area_in_parent; | 47 return work_area_in_parent; |
| 47 } | 48 } |
| 48 | 49 |
| 49 // Returns the maximized/full screen and/or centered bounds of a window. | 50 // Returns the maximized/full screen and/or centered bounds of a window. |
| 50 gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { | 51 gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { |
| 51 if (state_object->IsFullscreen() || state_object->IsPinned()) | 52 if (state_object->IsFullscreen() || state_object->IsPinned()) |
| 52 return wm::GetDisplayBoundsInParent(state_object->window()); | 53 return ScreenUtil::GetDisplayBoundsInParent( |
| 54 state_object->window()->aura_window()); |
| 53 | 55 |
| 54 gfx::Rect bounds_in_parent; | 56 gfx::Rect bounds_in_parent; |
| 55 // Make the window as big as possible. | 57 // Make the window as big as possible. |
| 56 if (state_object->CanMaximize() || state_object->CanResize()) { | 58 if (state_object->CanMaximize() || state_object->CanResize()) { |
| 57 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object)); | 59 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object)); |
| 58 } else { | 60 } else { |
| 59 // We prefer the user given window dimensions over the current windows | 61 // We prefer the user given window dimensions over the current windows |
| 60 // dimensions since they are likely to be the result from some other state | 62 // dimensions since they are likely to be the result from some other state |
| 61 // object logic. | 63 // object logic. |
| 62 if (state_object->HasRestoreBounds()) | 64 if (state_object->HasRestoreBounds()) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // avoid flashing. | 322 // avoid flashing. |
| 321 if (window_state->IsMaximized()) | 323 if (window_state->IsMaximized()) |
| 322 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 324 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
| 323 else | 325 else |
| 324 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 326 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
| 325 } | 327 } |
| 326 } | 328 } |
| 327 } | 329 } |
| 328 | 330 |
| 329 } // namespace ash | 331 } // namespace ash |
| OLD | NEW |