OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/title_drag_controller.h" | 5 #include "athena/wm/title_drag_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/aura/window_delegate.h" | 9 #include "ui/aura/window_delegate.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 complete))); | 53 complete))); |
54 gfx::Transform transform; | 54 gfx::Transform transform; |
55 transform.Translate(0, complete ? window->bounds().height() : 0); | 55 transform.Translate(0, complete ? window->bounds().height() : 0); |
56 window->SetTransform(transform); | 56 window->SetTransform(transform); |
57 } | 57 } |
58 | 58 |
59 void TitleDragController::OnTransitionEnd(aura::Window* window, bool complete) { | 59 void TitleDragController::OnTransitionEnd(aura::Window* window, bool complete) { |
60 weak_ptr_.InvalidateWeakPtrs(); | 60 weak_ptr_.InvalidateWeakPtrs(); |
61 if (!tracker_.Contains(window)) | 61 if (!tracker_.Contains(window)) |
62 window = NULL; | 62 window = NULL; |
63 if (complete && window && wm::IsActiveWindow(window)) | |
64 delegate_->OnTitleDragCompleted(window); | |
65 else | |
66 delegate_->OnTitleDragCanceled(window); | |
67 shadow_.reset(); | 63 shadow_.reset(); |
68 if (window) { | 64 if (window) { |
69 window->SetTransform(gfx::Transform()); | 65 window->SetTransform(gfx::Transform()); |
70 tracker_.Remove(window); | 66 tracker_.Remove(window); |
71 } | 67 } |
| 68 if (complete && window && wm::IsActiveWindow(window)) |
| 69 delegate_->OnTitleDragCompleted(window); |
| 70 else |
| 71 delegate_->OnTitleDragCanceled(window); |
72 } | 72 } |
73 | 73 |
74 void TitleDragController::OnGestureEvent(ui::GestureEvent* gesture) { | 74 void TitleDragController::OnGestureEvent(ui::GestureEvent* gesture) { |
75 // Do not process any gesture events if an animation is still in progress from | 75 // Do not process any gesture events if an animation is still in progress from |
76 // a previous drag. | 76 // a previous drag. |
77 if (weak_ptr_.HasWeakPtrs()) | 77 if (weak_ptr_.HasWeakPtrs()) |
78 return; | 78 return; |
79 | 79 |
80 if (gesture->type() == ui::ET_GESTURE_TAP_DOWN) { | 80 if (gesture->type() == ui::ET_GESTURE_TAP_DOWN) { |
81 // It is possible to start a gesture sequence on a second window while a | 81 // It is possible to start a gesture sequence on a second window while a |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 EndTransition( | 135 EndTransition( |
136 window, | 136 window, |
137 swipe_downwards && | 137 swipe_downwards && |
138 (distance.y() >= kMinDragDistanceForSwitch || | 138 (distance.y() >= kMinDragDistanceForSwitch || |
139 gesture->details().velocity_y() >= kMinDragVelocityForSwitch)); | 139 gesture->details().velocity_y() >= kMinDragVelocityForSwitch)); |
140 gesture->SetHandled(); | 140 gesture->SetHandled(); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 } // namespace athena | 144 } // namespace athena |
OLD | NEW |