| 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/workspace/snap_sizer.h" | 5 #include "ash/wm/workspace/snap_sizer.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/screen_ash.h" |
| 9 #include "ash/wm/window_resizer.h" | 10 #include "ash/wm/window_resizer.h" |
| 10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 11 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 12 | 13 |
| 13 namespace ash { | 14 namespace ash { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Percent of the screen (width) to give the window. | 19 // Percent of the screen (width) to give the window. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 std::max(percent_index_ + delta, 0)); | 87 std::max(percent_index_ + delta, 0)); |
| 87 if (index != percent_index_) { | 88 if (index != percent_index_) { |
| 88 percent_index_ = index; | 89 percent_index_ = index; |
| 89 target_bounds_ = GetTargetBounds(); | 90 target_bounds_ = GetTargetBounds(); |
| 90 } | 91 } |
| 91 num_moves_since_adjust_ = 0; | 92 num_moves_since_adjust_ = 0; |
| 92 last_adjust_x_ = x; | 93 last_adjust_x_ = x; |
| 93 } | 94 } |
| 94 | 95 |
| 95 gfx::Rect SnapSizer::GetTargetBounds() const { | 96 gfx::Rect SnapSizer::GetTargetBounds() const { |
| 96 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window_)); | 97 gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBounds(window_)); |
| 97 int y = WindowResizer::AlignToGridRoundUp(work_area.y(), grid_size_); | 98 int y = WindowResizer::AlignToGridRoundUp(work_area.y(), grid_size_); |
| 98 int max_y = | 99 int max_y = |
| 99 WindowResizer::AlignToGridRoundDown(work_area.bottom(), grid_size_); | 100 WindowResizer::AlignToGridRoundDown(work_area.bottom(), grid_size_); |
| 100 int width = static_cast<float>(work_area.width()) * kPercents[percent_index_]; | 101 int width = static_cast<float>(work_area.width()) * kPercents[percent_index_]; |
| 101 if (edge_ == LEFT_EDGE) { | 102 if (edge_ == LEFT_EDGE) { |
| 102 int x = WindowResizer::AlignToGridRoundUp(work_area.x(), grid_size_); | 103 int x = WindowResizer::AlignToGridRoundUp(work_area.x(), grid_size_); |
| 103 int mid_x = WindowResizer::AlignToGridRoundUp( | 104 int mid_x = WindowResizer::AlignToGridRoundUp( |
| 104 work_area.x() + width, grid_size_); | 105 work_area.x() + width, grid_size_); |
| 105 return gfx::Rect(x, y, mid_x - x, max_y - y); | 106 return gfx::Rect(x, y, mid_x - x, max_y - y); |
| 106 } | 107 } |
| 107 int max_x = | 108 int max_x = |
| 108 WindowResizer::AlignToGridRoundDown(work_area.right(), grid_size_); | 109 WindowResizer::AlignToGridRoundDown(work_area.right(), grid_size_); |
| 109 int x = WindowResizer::AlignToGridRoundUp(max_x - width, grid_size_); | 110 int x = WindowResizer::AlignToGridRoundUp(max_x - width, grid_size_); |
| 110 return gfx::Rect(x , y, max_x - x, max_y - y); | 111 return gfx::Rect(x , y, max_x - x, max_y - y); |
| 111 } | 112 } |
| 112 | 113 |
| 113 bool SnapSizer::AlongEdge(int x) const { | 114 bool SnapSizer::AlongEdge(int x) const { |
| 114 // TODO: need to support multi-monitor. | 115 // TODO: need to support multi-monitor. |
| 115 gfx::Rect area(gfx::Screen::GetMonitorAreaNearestWindow(window_)); | 116 gfx::Rect area(gfx::Screen::GetMonitorAreaNearestWindow(window_)); |
| 116 return (x <= area.x()) || (x >= area.right() - 1); | 117 return (x <= area.x()) || (x >= area.right() - 1); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace internal | 120 } // namespace internal |
| 120 } // namespace ash | 121 } // namespace ash |
| OLD | NEW |