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

Side by Side Diff: ash/wm/toplevel_window_event_handler.cc

Issue 11434004: ash: Refactor some code that snaps windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/property_util.h" 8 #include "ash/wm/property_util.h"
9 #include "ash/wm/resize_shadow_controller.h" 9 #include "ash/wm/resize_shadow_controller.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if (fabs(event->details().velocity_y()) > 207 if (fabs(event->details().velocity_y()) >
208 kMinVertVelocityForWindowMinimize) { 208 kMinVertVelocityForWindowMinimize) {
209 // Minimize/maximize. 209 // Minimize/maximize.
210 if (event->details().velocity_y() > 0) 210 if (event->details().velocity_y() > 0)
211 wm::MinimizeWindow(target); 211 wm::MinimizeWindow(target);
212 else if (wm::CanMaximizeWindow(target)) 212 else if (wm::CanMaximizeWindow(target))
213 wm::MaximizeWindow(target); 213 wm::MaximizeWindow(target);
214 } else if (fabs(event->details().velocity_x()) > 214 } else if (fabs(event->details().velocity_x()) >
215 kMinHorizVelocityForWindowSwipe) { 215 kMinHorizVelocityForWindowSwipe) {
216 // Snap left/right. 216 // Snap left/right.
217 internal::SnapSizer sizer(target,
218 gfx::Point(),
219 event->details().velocity_x() < 0 ? internal::SnapSizer::LEFT_EDGE :
220 internal::SnapSizer::RIGHT_EDGE,
221 internal::SnapSizer::OTHER_INPUT);
222
223 ui::ScopedLayerAnimationSettings scoped_setter( 217 ui::ScopedLayerAnimationSettings scoped_setter(
224 target->layer()->GetAnimator()); 218 target->layer()->GetAnimator());
225 scoped_setter.SetPreemptionStrategy( 219 scoped_setter.SetPreemptionStrategy(
226 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 220 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
227 target->SetBounds(sizer.target_bounds()); 221 internal::SnapSizer::SnapWindow(target,
222 event->details().velocity_x() < 0 ?
223 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE);
228 } 224 }
229 break; 225 break;
230 } 226 }
231 default: 227 default:
232 return ui::ER_UNHANDLED; 228 return ui::ER_UNHANDLED;
233 } 229 }
234 230
235 return ui::ER_CONSUMED; 231 return ui::ER_CONSUMED;
236 } 232 }
237 233
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 430 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
435 // We explicitly don't invoke RevertDrag() since that may do things to window. 431 // We explicitly don't invoke RevertDrag() since that may do things to window.
436 // Instead we destroy the resizer. 432 // Instead we destroy the resizer.
437 window_resizer_.reset(); 433 window_resizer_.reset();
438 434
439 // End the move loop. This does nothing if we're not in a move loop. 435 // End the move loop. This does nothing if we're not in a move loop.
440 EndMoveLoop(); 436 EndMoveLoop();
441 } 437 }
442 438
443 } // namespace ash 439 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/gestures/two_finger_drag_handler.cc ('k') | ash/wm/toplevel_window_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698