| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/window_util.h" | 5 #include "ash/wm/window_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/screen_ash.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/wm/window_properties.h" | 12 #include "ash/wm/window_properties.h" |
| 12 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 13 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 17 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
| 18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 return views::corewm::CanActivateWindow(window); | 51 return views::corewm::CanActivateWindow(window); |
| 51 } | 52 } |
| 52 | 53 |
| 53 bool IsWindowMinimized(aura::Window* window) { | 54 bool IsWindowMinimized(aura::Window* window) { |
| 54 return window->GetProperty(aura::client::kShowStateKey) == | 55 return window->GetProperty(aura::client::kShowStateKey) == |
| 55 ui::SHOW_STATE_MINIMIZED; | 56 ui::SHOW_STATE_MINIMIZED; |
| 56 } | 57 } |
| 57 | 58 |
| 58 void CenterWindow(aura::Window* window) { | 59 void CenterWindow(aura::Window* window) { |
| 59 wm::WindowState* window_state = wm::GetWindowState(window); | 60 wm::WindowState* window_state = wm::GetWindowState(window); |
| 60 if (!window_state->IsNormalShowState()) | 61 if (window_state->IsMaximizedOrFullscreen()) |
| 61 return; | 62 return; |
| 62 const gfx::Display display = | 63 const gfx::Display display = |
| 63 Shell::GetScreen()->GetDisplayNearestWindow(window); | 64 Shell::GetScreen()->GetDisplayNearestWindow(window); |
| 64 gfx::Rect center = display.work_area(); | 65 gfx::Rect center = display.work_area(); |
| 65 gfx::Size size = window_state->HasRestoreBounds() ? | 66 gfx::Size size = window->bounds().size(); |
| 66 window_state->GetRestoreBoundsInScreen().size() : | 67 if (window_state->IsSnapped()) { |
| 67 window->bounds().size(); | 68 if (window_state->HasRestoreBounds()) |
| 68 center.ClampToCenteredSize(size); | 69 size = window_state->GetRestoreBoundsInScreen().size(); |
| 69 window_state->SetRestoreBoundsInScreen(center); | 70 center.ClampToCenteredSize(size); |
| 70 window_state->Restore(); | 71 window_state->SetRestoreBoundsInScreen(center); |
| 72 window_state->Restore(); |
| 73 } else { |
| 74 center = ScreenAsh::ConvertRectFromScreen(window->parent(), |
| 75 center); |
| 76 center.ClampToCenteredSize(size); |
| 77 window->SetBounds(center); |
| 78 } |
| 71 } | 79 } |
| 72 | 80 |
| 73 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, | 81 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, |
| 74 gfx::Rect* bounds) { | 82 gfx::Rect* bounds) { |
| 75 AdjustBoundsToEnsureWindowVisibility( | 83 AdjustBoundsToEnsureWindowVisibility( |
| 76 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); | 84 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); |
| 77 } | 85 } |
| 78 | 86 |
| 79 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, | 87 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, |
| 80 int min_width, | 88 int min_width, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 130 } |
| 123 | 131 |
| 124 void ReparentTransientChildrenOfChild(aura::Window* window, | 132 void ReparentTransientChildrenOfChild(aura::Window* window, |
| 125 aura::Window* child) { | 133 aura::Window* child) { |
| 126 for (size_t i = 0; i < child->transient_children().size(); ++i) | 134 for (size_t i = 0; i < child->transient_children().size(); ++i) |
| 127 ReparentChildWithTransientChildren(window, child->transient_children()[i]); | 135 ReparentChildWithTransientChildren(window, child->transient_children()[i]); |
| 128 } | 136 } |
| 129 | 137 |
| 130 } // namespace wm | 138 } // namespace wm |
| 131 } // namespace ash | 139 } // namespace ash |
| OLD | NEW |