Chromium Code Reviews| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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())); |
| 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 min_width = std::min(min_width, work_area.width()); |
| 185 if (work_area.right() < bounds->x()) { | 178 min_height = std::min(min_height, work_area.height()); |
| 186 x_offset = work_area.right() - bounds->x() - min_width; | 179 |
| 187 } else if (bounds->right() < work_area.x()) { | 180 if (bounds->x() + min_width > work_area.right()) { |
| 188 x_offset = work_area.x() - bounds->right() + min_width; | 181 bounds->set_x(work_area.right() - min_width); |
| 189 } | 182 } else if (bounds->right() - min_width < 0) { |
| 190 bounds->Offset(x_offset, y_offset); | 183 bounds->set_x(min_width - bounds->width()); |
|
Mr4D (OOO till 08-26)
2013/08/06 23:28:56
Indenting still looks wrong.
oshima
2013/08/06 23:40:36
Doh! I guess I undone it. Sorry, fixed.
| |
| 184 } | |
| 185 if (bounds->y() + min_height > work_area.bottom()) { | |
| 186 bounds->set_y(work_area.bottom() - min_height); | |
| 187 } else if (bounds->bottom() - min_height < 0) { | |
| 188 bounds->set_y(min_height - bounds->height()); | |
| 191 } | 189 } |
| 192 } | 190 } |
| 193 | 191 |
| 194 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { | 192 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { |
| 195 views::View* target = static_cast<views::View*>(event.target()); | 193 views::View* target = static_cast<views::View*>(event.target()); |
| 196 if (!target) | 194 if (!target) |
| 197 return false; | 195 return false; |
| 198 aura::RootWindow* target_root = | 196 aura::RootWindow* target_root = |
| 199 target->GetWidget()->GetNativeView()->GetRootWindow(); | 197 target->GetWidget()->GetNativeView()->GetRootWindow(); |
| 200 if (!target_root || target_root == window->GetRootWindow()) | 198 if (!target_root || target_root == window->GetRootWindow()) |
| 201 return false; | 199 return false; |
| 202 aura::Window* window_container = | 200 aura::Window* window_container = |
| 203 ash::Shell::GetContainer(target_root, window->parent()->id()); | 201 ash::Shell::GetContainer(target_root, window->parent()->id()); |
| 204 // Move the window to the target launcher. | 202 // Move the window to the target launcher. |
| 205 window_container->AddChild(window); | 203 window_container->AddChild(window); |
| 206 return true; | 204 return true; |
| 207 } | 205 } |
| 208 | 206 |
| 209 } // namespace wm | 207 } // namespace wm |
| 210 } // namespace ash | 208 } // namespace ash |
| OLD | NEW |