| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/wm/window_positioning_utils.h" | 5 #include "ash/common/wm/window_positioning_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm/wm_event.h" | 10 #include "ash/common/wm/wm_event.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, | 39 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, |
| 40 int min_width, | 40 int min_width, |
| 41 int min_height, | 41 int min_height, |
| 42 gfx::Rect* bounds) { | 42 gfx::Rect* bounds) { |
| 43 AdjustBoundsSmallerThan(visible_area.size(), bounds); | 43 AdjustBoundsSmallerThan(visible_area.size(), bounds); |
| 44 | 44 |
| 45 min_width = std::min(min_width, visible_area.width()); | 45 min_width = std::min(min_width, visible_area.width()); |
| 46 min_height = std::min(min_height, visible_area.height()); | 46 min_height = std::min(min_height, visible_area.height()); |
| 47 | 47 |
| 48 if (bounds->right() < visible_area.x() + min_width) { | 48 if (bounds->right() < visible_area.x() + min_width) { |
| 49 bounds->set_x(visible_area.x() + min_width - bounds->width()); | 49 bounds->set_x(visible_area.x() + std::min(bounds->width(), min_width) - |
| 50 bounds->width()); |
| 50 } else if (bounds->x() > visible_area.right() - min_width) { | 51 } else if (bounds->x() > visible_area.right() - min_width) { |
| 51 bounds->set_x(visible_area.right() - min_width); | 52 bounds->set_x(visible_area.right() - std::min(bounds->width(), min_width)); |
| 52 } | 53 } |
| 53 if (bounds->bottom() < visible_area.y() + min_height) { | 54 if (bounds->bottom() < visible_area.y() + min_height) { |
| 54 bounds->set_y(visible_area.y() + min_height - bounds->height()); | 55 bounds->set_y(visible_area.y() + std::min(bounds->height(), min_height) - |
| 56 bounds->height()); |
| 55 } else if (bounds->y() > visible_area.bottom() - min_height) { | 57 } else if (bounds->y() > visible_area.bottom() - min_height) { |
| 56 bounds->set_y(visible_area.bottom() - min_height); | 58 bounds->set_y(visible_area.bottom() - |
| 59 std::min(bounds->height(), min_height)); |
| 57 } | 60 } |
| 58 if (bounds->y() < visible_area.y()) | 61 if (bounds->y() < visible_area.y()) |
| 59 bounds->set_y(visible_area.y()); | 62 bounds->set_y(visible_area.y()); |
| 60 } | 63 } |
| 61 | 64 |
| 62 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, | 65 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, |
| 63 gfx::Rect* bounds) { | 66 gfx::Rect* bounds) { |
| 64 AdjustBoundsToEnsureWindowVisibility(visible_area, kMinimumOnScreenArea, | 67 AdjustBoundsToEnsureWindowVisibility(visible_area, kMinimumOnScreenArea, |
| 65 kMinimumOnScreenArea, bounds); | 68 kMinimumOnScreenArea, bounds); |
| 66 } | 69 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 width, work_area_in_parent.height()); | 82 width, work_area_in_parent.height()); |
| 80 } | 83 } |
| 81 | 84 |
| 82 void CenterWindow(WmWindow* window) { | 85 void CenterWindow(WmWindow* window) { |
| 83 WMEvent event(WM_EVENT_CENTER); | 86 WMEvent event(WM_EVENT_CENTER); |
| 84 window->GetWindowState()->OnWMEvent(&event); | 87 window->GetWindowState()->OnWMEvent(&event); |
| 85 } | 88 } |
| 86 | 89 |
| 87 } // namespace wm | 90 } // namespace wm |
| 88 } // namespace ash | 91 } // namespace ash |
| OLD | NEW |