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_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/wm/window_properties.h" | 12 #include "ash/wm/window_properties.h" |
13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
14 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
19 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 #include "ui/gfx/size.h" |
21 #include "ui/views/corewm/window_util.h" | 22 #include "ui/views/corewm/window_util.h" |
22 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
24 | 25 |
25 namespace ash { | 26 namespace ash { |
26 namespace wm { | 27 namespace wm { |
27 | 28 |
28 // TODO(beng): replace many of these functions with the corewm versions. | 29 // TODO(beng): replace many of these functions with the corewm versions. |
29 void ActivateWindow(aura::Window* window) { | 30 void ActivateWindow(aura::Window* window) { |
30 views::corewm::ActivateWindow(window); | 31 views::corewm::ActivateWindow(window); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 window_state->SetRestoreBoundsInScreen(center); | 72 window_state->SetRestoreBoundsInScreen(center); |
72 window_state->Restore(); | 73 window_state->Restore(); |
73 } else { | 74 } else { |
74 center = ScreenUtil::ConvertRectFromScreen(window->parent(), | 75 center = ScreenUtil::ConvertRectFromScreen(window->parent(), |
75 center); | 76 center); |
76 center.ClampToCenteredSize(size); | 77 center.ClampToCenteredSize(size); |
77 window->SetBounds(center); | 78 window->SetBounds(center); |
78 } | 79 } |
79 } | 80 } |
80 | 81 |
| 82 void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) { |
| 83 bounds->set_width(std::min(bounds->width(), max_size.width())); |
| 84 bounds->set_height(std::min(bounds->height(), max_size.height())); |
| 85 } |
| 86 |
81 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, | 87 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, |
82 gfx::Rect* bounds) { | 88 gfx::Rect* bounds) { |
83 AdjustBoundsToEnsureWindowVisibility( | 89 AdjustBoundsToEnsureWindowVisibility( |
84 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); | 90 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); |
85 } | 91 } |
86 | 92 |
87 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, | 93 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, |
88 int min_width, | 94 int min_width, |
89 int min_height, | 95 int min_height, |
90 gfx::Rect* bounds) { | 96 gfx::Rect* bounds) { |
91 bounds->set_width(std::min(bounds->width(), visible_area.width())); | 97 AdjustBoundsSmallerThan(visible_area.size(), bounds); |
92 bounds->set_height(std::min(bounds->height(), visible_area.height())); | |
93 | 98 |
94 min_width = std::min(min_width, visible_area.width()); | 99 min_width = std::min(min_width, visible_area.width()); |
95 min_height = std::min(min_height, visible_area.height()); | 100 min_height = std::min(min_height, visible_area.height()); |
96 | 101 |
97 if (bounds->right() < visible_area.x() + min_width) { | 102 if (bounds->right() < visible_area.x() + min_width) { |
98 bounds->set_x(visible_area.x() + min_width - bounds->width()); | 103 bounds->set_x(visible_area.x() + min_width - bounds->width()); |
99 } else if (bounds->x() > visible_area.right() - min_width) { | 104 } else if (bounds->x() > visible_area.right() - min_width) { |
100 bounds->set_x(visible_area.right() - min_width); | 105 bounds->set_x(visible_area.right() - min_width); |
101 } | 106 } |
102 if (bounds->bottom() < visible_area.y() + min_height) { | 107 if (bounds->bottom() < visible_area.y() + min_height) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 ++i) { | 144 ++i) { |
140 ReparentChildWithTransientChildren( | 145 ReparentChildWithTransientChildren( |
141 views::corewm::GetTransientChildren(child)[i], | 146 views::corewm::GetTransientChildren(child)[i], |
142 old_parent, | 147 old_parent, |
143 new_parent); | 148 new_parent); |
144 } | 149 } |
145 } | 150 } |
146 | 151 |
147 } // namespace wm | 152 } // namespace wm |
148 } // namespace ash | 153 } // namespace ash |
OLD | NEW |