| 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_state.h" | 8 #include "ash/wm/window_state.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ash/wm/workspace/snap_sizer.h" | 10 #include "ash/wm/workspace/snap_sizer.h" |
| 11 #include "ui/aura/client/window_types.h" | |
| 12 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_delegate.h" | 12 #include "ui/aura/window_delegate.h" |
| 14 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 15 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
| 16 #include "ui/compositor/scoped_layer_animation_settings.h" | 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 17 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 18 #include "ui/events/event_constants.h" | 17 #include "ui/events/event_constants.h" |
| 18 #include "ui/wm/public/window_types.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 bool IsTopEdge(int component) { | 22 bool IsTopEdge(int component) { |
| 23 return component == HTTOPLEFT || | 23 return component == HTTOPLEFT || |
| 24 component == HTTOP || | 24 component == HTTOP || |
| 25 component == HTTOPRIGHT; | 25 component == HTTOPRIGHT; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool IsBottomEdge(int component) { | 28 bool IsBottomEdge(int component) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 first_finger_hittest_ = | 91 first_finger_hittest_ = |
| 92 target->delegate()->GetNonClientComponent(event.location()); | 92 target->delegate()->GetNonClientComponent(event.location()); |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 | 95 |
| 96 wm::WindowState* window_state = wm::GetWindowState(target); | 96 wm::WindowState* window_state = wm::GetWindowState(target); |
| 97 | 97 |
| 98 if (event.type() == ui::ET_GESTURE_BEGIN && | 98 if (event.type() == ui::ET_GESTURE_BEGIN && |
| 99 event.details().touch_points() == 2) { | 99 event.details().touch_points() == 2) { |
| 100 if (!in_gesture_drag_ && window_state->IsNormalShowState() && | 100 if (!in_gesture_drag_ && window_state->IsNormalShowState() && |
| 101 target->type() == aura::client::WINDOW_TYPE_NORMAL) { | 101 target->type() == ui::wm::WINDOW_TYPE_NORMAL) { |
| 102 if (WindowComponentsAllowMoving(first_finger_hittest_, | 102 if (WindowComponentsAllowMoving(first_finger_hittest_, |
| 103 target->delegate()->GetNonClientComponent(event.location()))) { | 103 target->delegate()->GetNonClientComponent(event.location()))) { |
| 104 in_gesture_drag_ = true; | 104 in_gesture_drag_ = true; |
| 105 target->AddObserver(this); | 105 target->AddObserver(this); |
| 106 // Only create a new WindowResizer if one doesn't already exist | 106 // Only create a new WindowResizer if one doesn't already exist |
| 107 // for the target window. | 107 // for the target window. |
| 108 window_resizer_ = CreateWindowResizer( | 108 window_resizer_ = CreateWindowResizer( |
| 109 target, | 109 target, |
| 110 event.details().bounding_box().CenterPoint(), | 110 event.details().bounding_box().CenterPoint(), |
| 111 HTCAPTION, | 111 HTCAPTION, |
| 112 aura::client::WINDOW_MOVE_SOURCE_TOUCH); | 112 aura::client::WINDOW_MOVE_SOURCE_TOUCH); |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (!in_gesture_drag_) { | 120 if (!in_gesture_drag_) { |
| 121 // Consume all two-finger gestures on a normal window. | 121 // Consume all two-finger gestures on a normal window. |
| 122 return event.details().touch_points() == 2 && | 122 return event.details().touch_points() == 2 && |
| 123 target->type() == aura::client::WINDOW_TYPE_NORMAL && | 123 target->type() == ui::wm::WINDOW_TYPE_NORMAL && |
| 124 window_state->IsNormalShowState(); | 124 window_state->IsNormalShowState(); |
| 125 } | 125 } |
| 126 // Since |in_gesture_drag_| is true a resizer was either created above or | 126 // Since |in_gesture_drag_| is true a resizer was either created above or |
| 127 // it was created elsewhere and can be found in |window_state|. | 127 // it was created elsewhere and can be found in |window_state|. |
| 128 WindowResizer* any_window_resizer = window_resizer_ ? | 128 WindowResizer* any_window_resizer = window_resizer_ ? |
| 129 window_resizer_.get() : window_state->window_resizer(); | 129 window_resizer_.get() : window_state->window_resizer(); |
| 130 DCHECK(any_window_resizer); | 130 DCHECK(any_window_resizer); |
| 131 | 131 |
| 132 if (target != any_window_resizer->GetTarget()) | 132 if (target != any_window_resizer->GetTarget()) |
| 133 return false; | 133 return false; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 bool visible) { | 207 bool visible) { |
| 208 Reset(window); | 208 Reset(window); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void TwoFingerDragHandler::OnWindowDestroying(aura::Window* window) { | 211 void TwoFingerDragHandler::OnWindowDestroying(aura::Window* window) { |
| 212 Reset(window); | 212 Reset(window); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace internal | 215 } // namespace internal |
| 216 } // namespace ash | 216 } // namespace ash |
| OLD | NEW |