| Index: ash/wm/common/window_positioning_utils.cc
|
| diff --git a/ash/wm/common/window_positioning_utils.cc b/ash/wm/common/window_positioning_utils.cc
|
| index 7ba629babc2eadcc9004da5bf1fd6c96bde662ad..a1105ea4df1dc0db54dd6c1c775d783ebe6c6fd1 100644
|
| --- a/ash/wm/common/window_positioning_utils.cc
|
| +++ b/ash/wm/common/window_positioning_utils.cc
|
| @@ -6,12 +6,29 @@
|
|
|
| #include <algorithm>
|
|
|
| +#include "ash/wm/common/wm_screen_util.h"
|
| +#include "ash/wm/common/wm_window.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| #include "ui/gfx/geometry/size.h"
|
|
|
| namespace ash {
|
| namespace wm {
|
|
|
| +namespace {
|
| +
|
| +// Returns the default width of a snapped window.
|
| +int GetDefaultSnappedWindowWidth(WmWindow* window) {
|
| + const float kSnappedWidthWorkspaceRatio = 0.5f;
|
| +
|
| + int work_area_width = GetDisplayWorkAreaBoundsInParent(window).width();
|
| + int min_width = window->GetMinimumSize().width();
|
| + int ideal_width =
|
| + static_cast<int>(work_area_width * kSnappedWidthWorkspaceRatio);
|
| + return std::min(work_area_width, std::max(ideal_width, min_width));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
|
| bounds->set_width(std::min(bounds->width(), max_size.width()));
|
| bounds->set_height(std::min(bounds->height(), max_size.height()));
|
| @@ -46,5 +63,19 @@ void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
|
| kMinimumOnScreenArea, bounds);
|
| }
|
|
|
| +gfx::Rect GetDefaultLeftSnappedWindowBoundsInParent(wm::WmWindow* window) {
|
| + gfx::Rect work_area_in_parent(GetDisplayWorkAreaBoundsInParent(window));
|
| + return gfx::Rect(work_area_in_parent.x(), work_area_in_parent.y(),
|
| + GetDefaultSnappedWindowWidth(window),
|
| + work_area_in_parent.height());
|
| +}
|
| +
|
| +gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(wm::WmWindow* window) {
|
| + gfx::Rect work_area_in_parent(GetDisplayWorkAreaBoundsInParent(window));
|
| + int width = GetDefaultSnappedWindowWidth(window);
|
| + return gfx::Rect(work_area_in_parent.right() - width, work_area_in_parent.y(),
|
| + width, work_area_in_parent.height());
|
| +}
|
| +
|
| } // namespace wm
|
| } // namespace ash
|
|
|