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/gestures/two_finger_drag_handler.h" | 5 #include "ash/wm/gestures/two_finger_drag_handler.h" |
6 | 6 |
7 #include "ash/wm/window_resizer.h" | 7 #include "ash/wm/window_resizer.h" |
8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
9 #include "ash/wm/workspace/snap_sizer.h" | 9 #include "ash/wm/workspace/snap_sizer.h" |
10 #include "ui/aura/client/window_types.h" | 10 #include "ui/aura/client/window_types.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // For a swipe, the window either maximizes, minimizes, or snaps. In this | 135 // For a swipe, the window either maximizes, minimizes, or snaps. In this |
136 // case, cancel the drag, and do the appropriate action. | 136 // case, cancel the drag, and do the appropriate action. |
137 Reset(); | 137 Reset(); |
138 | 138 |
139 if (event.details().swipe_up()) { | 139 if (event.details().swipe_up()) { |
140 if (wm::CanMaximizeWindow(target)) | 140 if (wm::CanMaximizeWindow(target)) |
141 wm::MaximizeWindow(target); | 141 wm::MaximizeWindow(target); |
142 } else if (event.details().swipe_down() && | 142 } else if (event.details().swipe_down() && |
143 wm::CanMinimizeWindow(target)) { | 143 wm::CanMinimizeWindow(target)) { |
144 wm::MinimizeWindow(target); | 144 wm::MinimizeWindow(target); |
145 } else if (wm::CanSnapWindow(target)) { | 145 } else { |
146 ui::ScopedLayerAnimationSettings scoped_setter( | 146 using internal::SnapSizer; |
147 target->layer()->GetAnimator()); | 147 SnapSizer::Edge edge = event.details().swipe_left() ? |
148 scoped_setter.SetPreemptionStrategy( | 148 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; |
149 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 149 if (SnapSizer::CanSnapWindow(target, edge)) { |
150 internal::SnapSizer::SnapWindow(target, | 150 ui::ScopedLayerAnimationSettings scoped_setter( |
151 event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE : | 151 target->layer()->GetAnimator()); |
152 internal::SnapSizer::RIGHT_EDGE); | 152 scoped_setter.SetPreemptionStrategy( |
| 153 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 154 SnapSizer::SnapWindow(target, edge, SnapSizer::STEP_NO); |
| 155 } |
153 } | 156 } |
154 return true; | 157 return true; |
155 } | 158 } |
156 | 159 |
157 case ui::ET_GESTURE_PINCH_UPDATE: | 160 case ui::ET_GESTURE_PINCH_UPDATE: |
158 case ui::ET_GESTURE_SCROLL_UPDATE: | 161 case ui::ET_GESTURE_SCROLL_UPDATE: |
159 window_resizer_->Drag(event.details().bounding_box().CenterPoint(), | 162 window_resizer_->Drag(event.details().bounding_box().CenterPoint(), |
160 event.flags()); | 163 event.flags()); |
161 return true; | 164 return true; |
162 | 165 |
(...skipping 26 matching lines...) Expand all Loading... |
189 bool visible) { | 192 bool visible) { |
190 Reset(); | 193 Reset(); |
191 } | 194 } |
192 | 195 |
193 void TwoFingerDragHandler::OnWindowDestroying(aura::Window* window) { | 196 void TwoFingerDragHandler::OnWindowDestroying(aura::Window* window) { |
194 Reset(); | 197 Reset(); |
195 } | 198 } |
196 | 199 |
197 } // namespace internal | 200 } // namespace internal |
198 } // namespace ash | 201 } // namespace ash |
OLD | NEW |