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/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/wm/window_properties.h" | 11 #include "ash/wm/window_properties.h" |
| 12 #include "ash/wm/window_state.h" |
12 #include "ui/aura/client/activation_client.h" | 13 #include "ui/aura/client/activation_client.h" |
13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
14 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/gfx/display.h" | 17 #include "ui/gfx/display.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
19 #include "ui/views/corewm/window_util.h" | 20 #include "ui/views/corewm/window_util.h" |
20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
(...skipping 26 matching lines...) Expand all Loading... |
48 bool CanActivateWindow(aura::Window* window) { | 49 bool CanActivateWindow(aura::Window* window) { |
49 return views::corewm::CanActivateWindow(window); | 50 return views::corewm::CanActivateWindow(window); |
50 } | 51 } |
51 | 52 |
52 bool IsWindowMinimized(aura::Window* window) { | 53 bool IsWindowMinimized(aura::Window* window) { |
53 return window->GetProperty(aura::client::kShowStateKey) == | 54 return window->GetProperty(aura::client::kShowStateKey) == |
54 ui::SHOW_STATE_MINIMIZED; | 55 ui::SHOW_STATE_MINIMIZED; |
55 } | 56 } |
56 | 57 |
57 void CenterWindow(aura::Window* window) { | 58 void CenterWindow(aura::Window* window) { |
| 59 wm::WindowState* window_state = wm::GetWindowState(window); |
| 60 if (!window_state->IsNormalShowState()) |
| 61 return; |
58 const gfx::Display display = | 62 const gfx::Display display = |
59 Shell::GetScreen()->GetDisplayNearestWindow(window); | 63 Shell::GetScreen()->GetDisplayNearestWindow(window); |
60 gfx::Rect center = display.work_area(); | 64 gfx::Rect center = display.work_area(); |
61 center.ClampToCenteredSize(window->bounds().size()); | 65 gfx::Size size = window_state->HasRestoreBounds() ? |
62 window->SetBoundsInScreen(center, display); | 66 window_state->GetRestoreBoundsInScreen().size() : |
| 67 window->bounds().size(); |
| 68 center.ClampToCenteredSize(size); |
| 69 window_state->SetRestoreBoundsInScreen(center); |
| 70 window_state->Restore(); |
63 } | 71 } |
64 | 72 |
65 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, | 73 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, |
66 gfx::Rect* bounds) { | 74 gfx::Rect* bounds) { |
67 AdjustBoundsToEnsureWindowVisibility( | 75 AdjustBoundsToEnsureWindowVisibility( |
68 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); | 76 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); |
69 } | 77 } |
70 | 78 |
71 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, | 79 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, |
72 int min_width, | 80 int min_width, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 122 } |
115 | 123 |
116 void ReparentTransientChildrenOfChild(aura::Window* window, | 124 void ReparentTransientChildrenOfChild(aura::Window* window, |
117 aura::Window* child) { | 125 aura::Window* child) { |
118 for (size_t i = 0; i < child->transient_children().size(); ++i) | 126 for (size_t i = 0; i < child->transient_children().size(); ++i) |
119 ReparentChildWithTransientChildren(window, child->transient_children()[i]); | 127 ReparentChildWithTransientChildren(window, child->transient_children()[i]); |
120 } | 128 } |
121 | 129 |
122 } // namespace wm | 130 } // namespace wm |
123 } // namespace ash | 131 } // namespace ash |
OLD | NEW |