Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: ash/wm/workspace/snap_sizer.cc

Issue 9956056: ash: Add accelerator for snapping windows left/right. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/snap_sizer.cc
diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc
index 158fa3a599a02ec7b860686a3d3d03c326850368..0816ff00acdbc40b6e6537745a97af9d6d5e9a86 100644
--- a/ash/wm/workspace/snap_sizer.cc
+++ b/ash/wm/workspace/snap_sizer.cc
@@ -66,6 +66,18 @@ void SnapSizer::Update(const gfx::Point& location) {
time_last_update_ = base::TimeTicks::Now();
}
+gfx::Rect SnapSizer::GetSnapBounds(const gfx::Rect& bounds) {
+ size_t current;
+ for (current = 0; current < arraysize(kPercents); ++current) {
+ gfx::Rect target = GetTargetBoundsForPercent(current);
+ if (target == bounds) {
+ ++current;
+ break;
+ }
+ }
+ return GetTargetBoundsForPercent(current % arraysize(kPercents));
+}
+
int SnapSizer::CalculateIncrement(int x, int reference_x) const {
if (AlongEdge(x))
return 1;
@@ -94,12 +106,16 @@ void SnapSizer::ChangeBounds(int x, int delta) {
}
gfx::Rect SnapSizer::GetTargetBounds() const {
+ return GetTargetBoundsForPercent(percent_index_);
+}
+
+gfx::Rect SnapSizer::GetTargetBoundsForPercent(int percent_index) const {
gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBounds(window_));
int y = WindowResizer::AlignToGridRoundUp(work_area.y(), grid_size_);
// We don't align to the bottom of the grid as the launcher may not
// necessarily align to the grid (happens when auto-hidden).
int max_y = work_area.bottom();
- int width = static_cast<float>(work_area.width()) * kPercents[percent_index_];
+ int width = static_cast<float>(work_area.width()) * kPercents[percent_index];
if (edge_ == LEFT_EDGE) {
int x = WindowResizer::AlignToGridRoundUp(work_area.x(), grid_size_);
int mid_x = WindowResizer::AlignToGridRoundUp(
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698