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/screen_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Returns the maximized/full screen and/or centered bounds of a window. | 80 // Returns the maximized/full screen and/or centered bounds of a window. |
81 gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { | 81 gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { |
82 if (state_object->IsFullscreen() || state_object->IsPinned()) | 82 if (state_object->IsFullscreen() || state_object->IsPinned()) |
83 return ScreenUtil::GetDisplayBoundsInParent(state_object->window()); | 83 return ScreenUtil::GetDisplayBoundsInParent(state_object->window()); |
84 | 84 |
85 if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) { | 85 if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) { |
86 DCHECK(CanSnap(state_object)); | 86 DCHECK(CanSnap(state_object)); |
87 return Shell::Get() | 87 return Shell::Get() |
88 ->split_view_controller() | 88 ->split_view_controller() |
89 ->GetSnappedWindowBoundsInParent(state_object->window(), | 89 ->GetSnappedWindowBoundsInParent(state_object->window(), |
90 SplitViewController::LEFT_SNAPPED); | 90 SplitViewController::LEFT); |
91 } | 91 } |
92 | 92 |
93 if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) { | 93 if (state_object->GetStateType() == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) { |
94 DCHECK(CanSnap(state_object)); | 94 DCHECK(CanSnap(state_object)); |
95 return Shell::Get() | 95 return Shell::Get() |
96 ->split_view_controller() | 96 ->split_view_controller() |
97 ->GetSnappedWindowBoundsInParent(state_object->window(), | 97 ->GetSnappedWindowBoundsInParent(state_object->window(), |
98 SplitViewController::RIGHT_SNAPPED); | 98 SplitViewController::RIGHT); |
99 } | 99 } |
100 | 100 |
101 gfx::Rect bounds_in_parent; | 101 gfx::Rect bounds_in_parent; |
102 // Make the window as big as possible. | 102 // Make the window as big as possible. |
103 if (state_object->CanMaximize() || state_object->CanResize()) { | 103 if (state_object->CanMaximize() || state_object->CanResize()) { |
104 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object)); | 104 bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object)); |
105 } else { | 105 } else { |
106 // We prefer the user given window dimensions over the current windows | 106 // We prefer the user given window dimensions over the current windows |
107 // dimensions since they are likely to be the result from some other state | 107 // dimensions since they are likely to be the result from some other state |
108 // object logic. | 108 // object logic. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { | 332 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { |
333 ::wm::SetWindowVisibilityAnimationType( | 333 ::wm::SetWindowVisibilityAnimationType( |
334 window_state->window(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | 334 window_state->window(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
335 window_state->window()->Hide(); | 335 window_state->window()->Hide(); |
336 if (window_state->IsActive()) | 336 if (window_state->IsActive()) |
337 window_state->Deactivate(); | 337 window_state->Deactivate(); |
338 } else if (target_state == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) { | 338 } else if (target_state == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED) { |
339 window_state->SetBoundsDirectAnimated( | 339 window_state->SetBoundsDirectAnimated( |
340 Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent( | 340 Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent( |
341 window_state->window(), SplitViewController::LEFT_SNAPPED)); | 341 window_state->window(), SplitViewController::LEFT)); |
342 } else if (target_state == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) { | 342 } else if (target_state == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) { |
343 window_state->SetBoundsDirectAnimated( | 343 window_state->SetBoundsDirectAnimated( |
344 Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent( | 344 Shell::Get()->split_view_controller()->GetSnappedWindowBoundsInParent( |
345 window_state->window(), SplitViewController::RIGHT_SNAPPED)); | 345 window_state->window(), SplitViewController::RIGHT)); |
346 } else { | 346 } else { |
347 UpdateBounds(window_state, animated); | 347 UpdateBounds(window_state, animated); |
348 } | 348 } |
349 | 349 |
350 window_state->NotifyPostStateTypeChange(old_state_type); | 350 window_state->NotifyPostStateTypeChange(old_state_type); |
351 | 351 |
352 if (old_state_type == wm::WINDOW_STATE_TYPE_PINNED || | 352 if (old_state_type == wm::WINDOW_STATE_TYPE_PINNED || |
353 target_state == wm::WINDOW_STATE_TYPE_PINNED || | 353 target_state == wm::WINDOW_STATE_TYPE_PINNED || |
354 old_state_type == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED || | 354 old_state_type == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED || |
355 target_state == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) { | 355 target_state == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // avoid flashing. | 398 // avoid flashing. |
399 if (window_state->IsMaximized()) | 399 if (window_state->IsMaximized()) |
400 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 400 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
401 else | 401 else |
402 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 402 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 } // namespace ash | 407 } // namespace ash |
OLD | NEW |