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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 SnapSizer::~SnapSizer() { | 160 SnapSizer::~SnapSizer() { |
161 } | 161 } |
162 | 162 |
163 void SnapSizer::SnapWindow(wm::WindowState* window_state, | 163 void SnapSizer::SnapWindow(wm::WindowState* window_state, |
164 SnapSizer::Edge edge) { | 164 SnapSizer::Edge edge) { |
165 if (!window_state->CanSnap()) | 165 if (!window_state->CanSnap()) |
166 return; | 166 return; |
167 internal::SnapSizer sizer(window_state, gfx::Point(), edge, | 167 internal::SnapSizer sizer(window_state, gfx::Point(), edge, |
168 internal::SnapSizer::OTHER_INPUT); | 168 internal::SnapSizer::OTHER_INPUT); |
| 169 window_state->SetWindowShowType(edge == LEFT_EDGE ? |
| 170 wm::SHOW_TYPE_LEFT_SNAPPED : wm::SHOW_TYPE_RIGHT_SNAPPED); |
169 SnapWindowToBounds(window_state, edge, | 171 SnapWindowToBounds(window_state, edge, |
170 sizer.GetSnapBounds(window_state->window()->bounds())); | 172 sizer.GetSnapBounds(window_state->window()->bounds())); |
171 } | 173 } |
172 | 174 |
173 void SnapSizer::SnapWindowToTargetBounds() { | 175 void SnapSizer::SnapWindowToTargetBounds() { |
| 176 window_state_->SetWindowShowType(edge_ == LEFT_EDGE ? |
| 177 wm::SHOW_TYPE_LEFT_SNAPPED : wm::SHOW_TYPE_RIGHT_SNAPPED); |
| 178 target_bounds_ = GetTargetBounds(); |
174 SnapWindowToBounds(window_state_, edge_, target_bounds()); | 179 SnapWindowToBounds(window_state_, edge_, target_bounds()); |
175 } | 180 } |
176 | 181 |
177 void SnapSizer::Update(const gfx::Point& location) { | 182 void SnapSizer::Update(const gfx::Point& location) { |
178 // See description above for details on this behavior. | 183 // See description above for details on this behavior. |
179 num_moves_since_adjust_++; | 184 num_moves_since_adjust_++; |
180 if ((base::TimeTicks::Now() - time_last_update_).InMilliseconds() > | 185 if ((base::TimeTicks::Now() - time_last_update_).InMilliseconds() > |
181 kDelayBeforeIncreaseMS) { | 186 kDelayBeforeIncreaseMS) { |
182 ChangeBounds(location.x(), | 187 ChangeBounds(location.x(), |
183 CalculateIncrement(location.x(), last_update_x_)); | 188 CalculateIncrement(location.x(), last_update_x_)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 291 } |
287 | 292 |
288 bool SnapSizer::AlongEdge(int x) const { | 293 bool SnapSizer::AlongEdge(int x) const { |
289 gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 294 gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
290 window_state_->window())); | 295 window_state_->window())); |
291 return (x <= area.x()) || (x >= area.right() - 1); | 296 return (x <= area.x()) || (x >= area.right() - 1); |
292 } | 297 } |
293 | 298 |
294 } // namespace internal | 299 } // namespace internal |
295 } // namespace ash | 300 } // namespace ash |
OLD | NEW |