Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/touch.h" | 5 #include "components/exo/touch.h" |
| 6 | 6 |
| 7 #include "components/exo/surface.h" | 7 #include "components/exo/surface.h" |
| 8 #include "components/exo/touch_delegate.h" | 8 #include "components/exo/touch_delegate.h" |
| 9 #include "components/exo/touch_stylus_delegate.h" | 9 #include "components/exo/touch_stylus_delegate.h" |
| 10 #include "components/exo/wm_helper.h" | 10 #include "components/exo/wm_helper.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 DCHECK(!focus_); | 70 DCHECK(!focus_); |
| 71 focus_ = target; | 71 focus_ = target; |
| 72 focus_->AddSurfaceObserver(this); | 72 focus_->AddSurfaceObserver(this); |
| 73 } | 73 } |
| 74 | 74 |
| 75 DCHECK(!VectorContainsItem(touch_points_, event->touch_id())); | 75 DCHECK(!VectorContainsItem(touch_points_, event->touch_id())); |
| 76 touch_points_.push_back(event->touch_id()); | 76 touch_points_.push_back(event->touch_id()); |
| 77 | 77 |
| 78 // Convert location to focus surface coordinate space. | 78 // Convert location to focus surface coordinate space. |
| 79 DCHECK(focus_); | 79 DCHECK(focus_); |
| 80 gfx::Point location = event->location(); | 80 gfx::PointF location = event->location_f(); |
| 81 aura::Window::ConvertPointToTarget(target->window(), focus_->window(), | 81 aura::Window::ConvertPointToTargetF(target->window(), focus_->window(), |
| 82 &location); | 82 &location); |
|
oshima
2017/01/20 22:11:54
If event system can pass through root_location_f,
sadrul
2017/01/20 22:35:18
|event| should have the correct root-location here
denniskempin
2017/01/20 23:22:19
I am trying that right now, it would be great if t
| |
| 83 | 83 |
| 84 // Generate a touch down event for the focus surface. Note that this can | 84 // Generate a touch down event for the focus surface. Note that this can |
| 85 // be different from the target surface. | 85 // be different from the target surface. |
| 86 delegate_->OnTouchDown(focus_, event->time_stamp(), event->touch_id(), | 86 delegate_->OnTouchDown(focus_, event->time_stamp(), event->touch_id(), |
| 87 location); | 87 location); |
| 88 if (stylus_delegate_ && | 88 if (stylus_delegate_ && |
| 89 event->pointer_details().pointer_type != | 89 event->pointer_details().pointer_type != |
| 90 ui::EventPointerType::POINTER_TYPE_TOUCH) { | 90 ui::EventPointerType::POINTER_TYPE_TOUCH) { |
| 91 stylus_delegate_->OnTouchTool(event->touch_id(), | 91 stylus_delegate_->OnTouchTool(event->touch_id(), |
| 92 event->pointer_details().pointer_type); | 92 event->pointer_details().pointer_type); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 108 | 108 |
| 109 delegate_->OnTouchUp(event->time_stamp(), event->touch_id()); | 109 delegate_->OnTouchUp(event->time_stamp(), event->touch_id()); |
| 110 } break; | 110 } break; |
| 111 case ui::ET_TOUCH_MOVED: { | 111 case ui::ET_TOUCH_MOVED: { |
| 112 auto it = FindVectorItem(touch_points_, event->touch_id()); | 112 auto it = FindVectorItem(touch_points_, event->touch_id()); |
| 113 if (it == touch_points_.end()) | 113 if (it == touch_points_.end()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 DCHECK(focus_); | 116 DCHECK(focus_); |
| 117 // Convert location to focus surface coordinate space. | 117 // Convert location to focus surface coordinate space. |
| 118 gfx::Point location = event->location(); | 118 gfx::PointF location = event->location_f(); |
| 119 aura::Window::ConvertPointToTarget( | 119 aura::Window::ConvertPointToTargetF( |
| 120 static_cast<aura::Window*>(event->target()), focus_->window(), | 120 static_cast<aura::Window*>(event->target()), focus_->window(), |
| 121 &location); | 121 &location); |
| 122 | |
| 123 delegate_->OnTouchMotion(event->time_stamp(), event->touch_id(), | 122 delegate_->OnTouchMotion(event->time_stamp(), event->touch_id(), |
| 124 location); | 123 event->location_f()); |
| 125 send_details = true; | 124 send_details = true; |
| 126 } break; | 125 } break; |
| 127 case ui::ET_TOUCH_CANCELLED: { | 126 case ui::ET_TOUCH_CANCELLED: { |
| 128 auto it = FindVectorItem(touch_points_, event->touch_id()); | 127 auto it = FindVectorItem(touch_points_, event->touch_id()); |
| 129 if (it == touch_points_.end()) | 128 if (it == touch_points_.end()) |
| 130 return; | 129 return; |
| 131 | 130 |
| 132 DCHECK(focus_); | 131 DCHECK(focus_); |
| 133 focus_->RemoveSurfaceObserver(this); | 132 focus_->RemoveSurfaceObserver(this); |
| 134 focus_ = nullptr; | 133 focus_ = nullptr; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const { | 183 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const { |
| 185 Surface* target = | 184 Surface* target = |
| 186 Surface::AsSurface(static_cast<aura::Window*>(event->target())); | 185 Surface::AsSurface(static_cast<aura::Window*>(event->target())); |
| 187 if (!target) | 186 if (!target) |
| 188 return nullptr; | 187 return nullptr; |
| 189 | 188 |
| 190 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr; | 189 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr; |
| 191 } | 190 } |
| 192 | 191 |
| 193 } // namespace exo | 192 } // namespace exo |
| OLD | NEW |