| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(aura::Window* window) { | 118 gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(aura::Window* window) { |
| 119 gfx::Rect work_area_in_parent(ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 119 gfx::Rect work_area_in_parent(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
| 120 window)); | 120 window)); |
| 121 int width = GetDefaultSnappedWindowWidth(window); | 121 int width = GetDefaultSnappedWindowWidth(window); |
| 122 return gfx::Rect(work_area_in_parent.right() - width, | 122 return gfx::Rect(work_area_in_parent.right() - width, |
| 123 work_area_in_parent.y(), | 123 work_area_in_parent.y(), |
| 124 width, | 124 width, |
| 125 work_area_in_parent.height()); | 125 work_area_in_parent.height()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) { | |
| 129 bounds->set_width(std::min(bounds->width(), max_size.width())); | |
| 130 bounds->set_height(std::min(bounds->height(), max_size.height())); | |
| 131 } | |
| 132 | |
| 133 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, | |
| 134 gfx::Rect* bounds) { | |
| 135 AdjustBoundsToEnsureWindowVisibility( | |
| 136 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); | |
| 137 } | |
| 138 | |
| 139 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, | |
| 140 int min_width, | |
| 141 int min_height, | |
| 142 gfx::Rect* bounds) { | |
| 143 AdjustBoundsSmallerThan(visible_area.size(), bounds); | |
| 144 | |
| 145 min_width = std::min(min_width, visible_area.width()); | |
| 146 min_height = std::min(min_height, visible_area.height()); | |
| 147 | |
| 148 if (bounds->right() < visible_area.x() + min_width) { | |
| 149 bounds->set_x(visible_area.x() + min_width - bounds->width()); | |
| 150 } else if (bounds->x() > visible_area.right() - min_width) { | |
| 151 bounds->set_x(visible_area.right() - min_width); | |
| 152 } | |
| 153 if (bounds->bottom() < visible_area.y() + min_height) { | |
| 154 bounds->set_y(visible_area.y() + min_height - bounds->height()); | |
| 155 } else if (bounds->y() > visible_area.bottom() - min_height) { | |
| 156 bounds->set_y(visible_area.bottom() - min_height); | |
| 157 } | |
| 158 if (bounds->y() < visible_area.y()) | |
| 159 bounds->set_y(visible_area.y()); | |
| 160 } | |
| 161 | |
| 162 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { | 128 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { |
| 163 views::View* target = static_cast<views::View*>(event.target()); | 129 views::View* target = static_cast<views::View*>(event.target()); |
| 164 if (!target) | 130 if (!target) |
| 165 return false; | 131 return false; |
| 166 aura::Window* target_root = | 132 aura::Window* target_root = |
| 167 target->GetWidget()->GetNativeView()->GetRootWindow(); | 133 target->GetWidget()->GetNativeView()->GetRootWindow(); |
| 168 if (!target_root || target_root == window->GetRootWindow()) | 134 if (!target_root || target_root == window->GetRootWindow()) |
| 169 return false; | 135 return false; |
| 170 aura::Window* window_container = | 136 aura::Window* window_container = |
| 171 ash::Shell::GetContainer(target_root, window->parent()->id()); | 137 ash::Shell::GetContainer(target_root, window->parent()->id()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (!container->layout_manager()) | 191 if (!container->layout_manager()) |
| 226 container->SetLayoutManager(new SnapToPixelLayoutManager(container)); | 192 container->SetLayoutManager(new SnapToPixelLayoutManager(container)); |
| 227 } else { | 193 } else { |
| 228 InstallSnapLayoutManagerToContainers(container); | 194 InstallSnapLayoutManagerToContainers(container); |
| 229 } | 195 } |
| 230 } | 196 } |
| 231 } | 197 } |
| 232 | 198 |
| 233 } // namespace wm | 199 } // namespace wm |
| 234 } // namespace ash | 200 } // namespace ash |
| OLD | NEW |