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/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& work_area, | 164 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& work_area, |
165 gfx::Rect* bounds) { | 165 gfx::Rect* bounds) { |
166 AdjustBoundsToEnsureWindowVisibility( | 166 AdjustBoundsToEnsureWindowVisibility( |
167 work_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); | 167 work_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); |
168 } | 168 } |
169 | 169 |
170 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& work_area, | 170 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& work_area, |
171 int min_width, | 171 int min_width, |
172 int min_height, | 172 int min_height, |
173 gfx::Rect* bounds) { | 173 gfx::Rect* bounds) { |
174 bounds->set_width(std::min(bounds->width(), work_area.width())); | 174 bounds->set_width(std::min(bounds->width(), work_area.width())); |
Mr4D (OOO till 08-26)
2013/08/06 20:22:51
I assume this is not really a problem - but what i
oshima
2013/08/06 23:13:20
min_width/min_height shouldn't be bigger than wrok
| |
175 bounds->set_height(std::min(bounds->height(), work_area.height())); | 175 bounds->set_height(std::min(bounds->height(), work_area.height())); |
176 if (!work_area.Intersects(*bounds)) { | |
177 int y_offset = 0; | |
178 if (work_area.bottom() < bounds->y()) { | |
179 y_offset = work_area.bottom() - bounds->y() - min_height; | |
180 } else if (bounds->bottom() < work_area.y()) { | |
181 y_offset = work_area.y() - bounds->bottom() + min_height; | |
182 } | |
183 | 176 |
184 int x_offset = 0; | 177 if (bounds->x() + min_width > work_area.right()) { |
185 if (work_area.right() < bounds->x()) { | 178 bounds->set_x(work_area.right() - min_width); |
186 x_offset = work_area.right() - bounds->x() - min_width; | 179 } else if (bounds->right() - min_width < 0) { |
187 } else if (bounds->right() < work_area.x()) { | 180 bounds->set_x(min_width - bounds->width()); |
Mr4D (OOO till 08-26)
2013/08/06 20:22:51
Indenting incorrect.
oshima
2013/08/06 23:13:20
Done.
| |
188 x_offset = work_area.x() - bounds->right() + min_width; | 181 } |
189 } | 182 if (bounds->y() + min_height > work_area.height()) { |
Mr4D (OOO till 08-26)
2013/08/06 20:22:51
work_Area.height is probably not correct. Shouldn'
oshima
2013/08/06 23:13:20
You're right. fixed.
| |
190 bounds->Offset(x_offset, y_offset); | 183 bounds->set_y(work_area.bottom() - min_height); |
184 } else if (bounds->bottom() - min_height < 0) { | |
185 bounds->set_y(min_height - bounds->height()); | |
191 } | 186 } |
192 } | 187 } |
193 | 188 |
194 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { | 189 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { |
195 views::View* target = static_cast<views::View*>(event.target()); | 190 views::View* target = static_cast<views::View*>(event.target()); |
196 if (!target) | 191 if (!target) |
197 return false; | 192 return false; |
198 aura::RootWindow* target_root = | 193 aura::RootWindow* target_root = |
199 target->GetWidget()->GetNativeView()->GetRootWindow(); | 194 target->GetWidget()->GetNativeView()->GetRootWindow(); |
200 if (!target_root || target_root == window->GetRootWindow()) | 195 if (!target_root || target_root == window->GetRootWindow()) |
201 return false; | 196 return false; |
202 aura::Window* window_container = | 197 aura::Window* window_container = |
203 ash::Shell::GetContainer(target_root, window->parent()->id()); | 198 ash::Shell::GetContainer(target_root, window->parent()->id()); |
204 // Move the window to the target launcher. | 199 // Move the window to the target launcher. |
205 window_container->AddChild(window); | 200 window_container->AddChild(window); |
206 return true; | 201 return true; |
207 } | 202 } |
208 | 203 |
209 } // namespace wm | 204 } // namespace wm |
210 } // namespace ash | 205 } // namespace ash |
OLD | NEW |