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

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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if (fabs(event->details().velocity_y()) > 204 if (fabs(event->details().velocity_y()) >
205 kMinVertVelocityForWindowMinimize) { 205 kMinVertVelocityForWindowMinimize) {
206 // Minimize/maximize. 206 // Minimize/maximize.
207 if (event->details().velocity_y() > 0) 207 if (event->details().velocity_y() > 0)
208 wm::MinimizeWindow(target); 208 wm::MinimizeWindow(target);
209 else if (wm::CanMaximizeWindow(target)) 209 else if (wm::CanMaximizeWindow(target))
210 wm::MaximizeWindow(target); 210 wm::MaximizeWindow(target);
211 } else if (fabs(event->details().velocity_x()) > 211 } else if (fabs(event->details().velocity_x()) >
212 kMinHorizVelocityForWindowSwipe) { 212 kMinHorizVelocityForWindowSwipe) {
213 // Snap left/right. 213 // Snap left/right.
214 internal::SnapSizer sizer(target,
215 gfx::Point(),
216 event->details().velocity_x() < 0 ? internal::SnapSizer::LEFT_EDGE :
217 internal::SnapSizer::RIGHT_EDGE,
218 internal::SnapSizer::OTHER_INPUT);
219
220 ui::ScopedLayerAnimationSettings scoped_setter( 214 ui::ScopedLayerAnimationSettings scoped_setter(
221 target->layer()->GetAnimator()); 215 target->layer()->GetAnimator());
222 scoped_setter.SetPreemptionStrategy( 216 scoped_setter.SetPreemptionStrategy(
223 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 217 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
224 target->SetBounds(sizer.target_bounds()); 218 wm::SnapWindow(target, event->details().velocity_x() < 0 ?
219 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE);
225 } 220 }
226 break; 221 break;
227 } 222 }
228 default: 223 default:
229 return ui::ER_UNHANDLED; 224 return ui::ER_UNHANDLED;
230 } 225 }
231 226
232 return ui::ER_CONSUMED; 227 return ui::ER_CONSUMED;
233 } 228 }
234 229
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 426 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
432 // We explicitly don't invoke RevertDrag() since that may do things to window. 427 // We explicitly don't invoke RevertDrag() since that may do things to window.
433 // Instead we destroy the resizer. 428 // Instead we destroy the resizer.
434 window_resizer_.reset(); 429 window_resizer_.reset();
435 430
436 // End the move loop. This does nothing if we're not in a move loop. 431 // End the move loop. This does nothing if we're not in a move loop.
437 EndMoveLoop(); 432 EndMoveLoop();
438 } 433 }
439 434
440 } // namespace ash 435 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698