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

Side by Side Diff: components/exo/touch.cc

Issue 2655303004: Add id properties to PointerEvent (Closed)
Patch Set: pointer id Created 3 years, 10 months 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
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return; 76 return;
77 77
78 // If this is the first touch point then target becomes the focus surface 78 // If this is the first touch point then target becomes the focus surface
79 // until all touch points have been released. 79 // until all touch points have been released.
80 if (touch_points_.empty()) { 80 if (touch_points_.empty()) {
81 DCHECK(!focus_); 81 DCHECK(!focus_);
82 focus_ = target; 82 focus_ = target;
83 focus_->AddSurfaceObserver(this); 83 focus_->AddSurfaceObserver(this);
84 } 84 }
85 85
86 DCHECK(!VectorContainsItem(touch_points_, event->touch_id())); 86 DCHECK(!VectorContainsItem(touch_points_, event->pointer_details().id));
87 touch_points_.push_back(event->touch_id()); 87 touch_points_.push_back(event->pointer_details().id);
88 88
89 // Convert location to focus surface coordinate space. 89 // Convert location to focus surface coordinate space.
90 DCHECK(focus_); 90 DCHECK(focus_);
91 gfx::PointF location = EventLocationInWindow(event, focus_->window()); 91 gfx::PointF location = EventLocationInWindow(event, focus_->window());
92 92
93 // Generate a touch down event for the focus surface. Note that this can 93 // Generate a touch down event for the focus surface. Note that this can
94 // be different from the target surface. 94 // be different from the target surface.
95 delegate_->OnTouchDown(focus_, event->time_stamp(), event->touch_id(), 95 delegate_->OnTouchDown(focus_, event->time_stamp(),
96 location); 96 event->pointer_details().id, location);
97 if (stylus_delegate_ && 97 if (stylus_delegate_ &&
98 event->pointer_details().pointer_type != 98 event->pointer_details().pointer_type !=
99 ui::EventPointerType::POINTER_TYPE_TOUCH) { 99 ui::EventPointerType::POINTER_TYPE_TOUCH) {
100 stylus_delegate_->OnTouchTool(event->touch_id(), 100 stylus_delegate_->OnTouchTool(event->pointer_details().id,
101 event->pointer_details().pointer_type); 101 event->pointer_details().pointer_type);
102 } 102 }
103 send_details = true; 103 send_details = true;
104 } break; 104 } break;
105 case ui::ET_TOUCH_RELEASED: { 105 case ui::ET_TOUCH_RELEASED: {
106 auto it = FindVectorItem(touch_points_, event->touch_id()); 106 auto it = FindVectorItem(touch_points_, event->pointer_details().id);
107 if (it == touch_points_.end()) 107 if (it == touch_points_.end())
108 return; 108 return;
109 touch_points_.erase(it); 109 touch_points_.erase(it);
110 110
111 // Reset focus surface if this is the last touch point. 111 // Reset focus surface if this is the last touch point.
112 if (touch_points_.empty()) { 112 if (touch_points_.empty()) {
113 DCHECK(focus_); 113 DCHECK(focus_);
114 focus_->RemoveSurfaceObserver(this); 114 focus_->RemoveSurfaceObserver(this);
115 focus_ = nullptr; 115 focus_ = nullptr;
116 } 116 }
117 117
118 delegate_->OnTouchUp(event->time_stamp(), event->touch_id()); 118 delegate_->OnTouchUp(event->time_stamp(), event->pointer_details().id);
119 } break; 119 } break;
120 case ui::ET_TOUCH_MOVED: { 120 case ui::ET_TOUCH_MOVED: {
121 auto it = FindVectorItem(touch_points_, event->touch_id()); 121 auto it = FindVectorItem(touch_points_, event->pointer_details().id);
122 if (it == touch_points_.end()) 122 if (it == touch_points_.end())
123 return; 123 return;
124 124
125 DCHECK(focus_); 125 DCHECK(focus_);
126 // Convert location to focus surface coordinate space. 126 // Convert location to focus surface coordinate space.
127 gfx::PointF location = EventLocationInWindow(event, focus_->window()); 127 gfx::PointF location = EventLocationInWindow(event, focus_->window());
128 delegate_->OnTouchMotion(event->time_stamp(), event->touch_id(), 128 delegate_->OnTouchMotion(event->time_stamp(), event->pointer_details().id,
129 location); 129 location);
130 send_details = true; 130 send_details = true;
131 } break; 131 } break;
132 case ui::ET_TOUCH_CANCELLED: { 132 case ui::ET_TOUCH_CANCELLED: {
133 auto it = FindVectorItem(touch_points_, event->touch_id()); 133 auto it = FindVectorItem(touch_points_, event->pointer_details().id);
134 if (it == touch_points_.end()) 134 if (it == touch_points_.end())
135 return; 135 return;
136 136
137 DCHECK(focus_); 137 DCHECK(focus_);
138 focus_->RemoveSurfaceObserver(this); 138 focus_->RemoveSurfaceObserver(this);
139 focus_ = nullptr; 139 focus_ = nullptr;
140 140
141 // Cancel the full set of touch sequences as soon as one is canceled. 141 // Cancel the full set of touch sequences as soon as one is canceled.
142 touch_points_.clear(); 142 touch_points_.clear();
143 delegate_->OnTouchCancel(); 143 delegate_->OnTouchCancel();
144 } break; 144 } break;
145 default: 145 default:
146 NOTREACHED(); 146 NOTREACHED();
147 return; 147 return;
148 } 148 }
149 if (send_details) { 149 if (send_details) {
150 delegate_->OnTouchShape(event->touch_id(), 150 delegate_->OnTouchShape(event->pointer_details().id,
151 event->pointer_details().radius_x, 151 event->pointer_details().radius_x,
152 event->pointer_details().radius_y); 152 event->pointer_details().radius_y);
153 153
154 if (stylus_delegate_ && 154 if (stylus_delegate_ &&
155 event->pointer_details().pointer_type != 155 event->pointer_details().pointer_type !=
156 ui::EventPointerType::POINTER_TYPE_TOUCH) { 156 ui::EventPointerType::POINTER_TYPE_TOUCH) {
157 if (!std::isnan(event->pointer_details().force)) { 157 if (!std::isnan(event->pointer_details().force)) {
158 stylus_delegate_->OnTouchForce(event->time_stamp(), event->touch_id(), 158 stylus_delegate_->OnTouchForce(event->time_stamp(),
159 event->pointer_details().id,
159 event->pointer_details().force); 160 event->pointer_details().force);
160 } 161 }
161 stylus_delegate_->OnTouchTilt( 162 stylus_delegate_->OnTouchTilt(
162 event->time_stamp(), event->touch_id(), 163 event->time_stamp(), event->pointer_details().id,
163 gfx::Vector2dF(event->pointer_details().tilt_x, 164 gfx::Vector2dF(event->pointer_details().tilt_x,
164 event->pointer_details().tilt_y)); 165 event->pointer_details().tilt_y));
165 } 166 }
166 } 167 }
167 // TODO(denniskempin): Extend ui::TouchEvent to signal end of sequence of 168 // TODO(denniskempin): Extend ui::TouchEvent to signal end of sequence of
168 // touch events to send TouchFrame once after all touches have been updated. 169 // touch events to send TouchFrame once after all touches have been updated.
169 delegate_->OnTouchFrame(); 170 delegate_->OnTouchFrame();
170 } 171 }
171 172
172 //////////////////////////////////////////////////////////////////////////////// 173 ////////////////////////////////////////////////////////////////////////////////
(...skipping 16 matching lines...) Expand all
189 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const { 190 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const {
190 Surface* target = 191 Surface* target =
191 Surface::AsSurface(static_cast<aura::Window*>(event->target())); 192 Surface::AsSurface(static_cast<aura::Window*>(event->target()));
192 if (!target) 193 if (!target)
193 return nullptr; 194 return nullptr;
194 195
195 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr; 196 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr;
196 } 197 }
197 198
198 } // namespace exo 199 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698