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/pointer.h" | 5 #include "components/exo/pointer.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
10 #include "components/exo/pointer_delegate.h" | 10 #include "components/exo/pointer_delegate.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 break; | 200 break; |
201 } | 201 } |
202 case ui::ET_MOUSEWHEEL: { | 202 case ui::ET_MOUSEWHEEL: { |
203 delegate_->OnPointerScroll( | 203 delegate_->OnPointerScroll( |
204 event->time_stamp(), | 204 event->time_stamp(), |
205 static_cast<ui::MouseWheelEvent*>(event)->offset(), true); | 205 static_cast<ui::MouseWheelEvent*>(event)->offset(), true); |
206 delegate_->OnPointerFrame(); | 206 delegate_->OnPointerFrame(); |
207 break; | 207 break; |
208 } | 208 } |
209 case ui::ET_SCROLL_FLING_START: { | 209 case ui::ET_SCROLL_FLING_START: { |
| 210 // Fling start in chrome signals the lifting of fingers after scrolling. |
| 211 // In wayland terms this signals the end of a scroll sequence. |
210 delegate_->OnPointerScrollStop(event->time_stamp()); | 212 delegate_->OnPointerScrollStop(event->time_stamp()); |
211 delegate_->OnPointerFrame(); | 213 delegate_->OnPointerFrame(); |
212 break; | 214 break; |
213 } | 215 } |
214 case ui::ET_SCROLL_FLING_CANCEL: { | 216 case ui::ET_SCROLL_FLING_CANCEL: { |
215 delegate_->OnPointerScrollCancel(event->time_stamp()); | 217 // Fling cancel is generated very generously at every touch of the |
216 delegate_->OnPointerFrame(); | 218 // touchpad. Since it's not directly supported by the delegate, we do not |
| 219 // want limit this event to only right after a fling start has been |
| 220 // generated to prevent erronous behavior. |
| 221 if (last_event_type_ == ui::ET_SCROLL_FLING_START) { |
| 222 // We emulate fling cancel by starting a new scroll sequence that |
| 223 // scrolls by 0 pixels, effectively stopping any kinetic scroll motion. |
| 224 delegate_->OnPointerScroll(event->time_stamp(), gfx::Vector2dF(), |
| 225 false); |
| 226 delegate_->OnPointerFrame(); |
| 227 delegate_->OnPointerScrollStop(event->time_stamp()); |
| 228 delegate_->OnPointerFrame(); |
| 229 } |
217 break; | 230 break; |
218 } | 231 } |
219 case ui::ET_MOUSE_MOVED: | 232 case ui::ET_MOUSE_MOVED: |
220 case ui::ET_MOUSE_DRAGGED: | 233 case ui::ET_MOUSE_DRAGGED: |
221 case ui::ET_MOUSE_ENTERED: | 234 case ui::ET_MOUSE_ENTERED: |
222 case ui::ET_MOUSE_EXITED: | 235 case ui::ET_MOUSE_EXITED: |
223 case ui::ET_MOUSE_CAPTURE_CHANGED: | 236 case ui::ET_MOUSE_CAPTURE_CHANGED: |
224 break; | 237 break; |
225 default: | 238 default: |
226 NOTREACHED(); | 239 NOTREACHED(); |
227 break; | 240 break; |
228 } | 241 } |
229 | 242 |
| 243 last_event_type_ = event->type(); |
230 UpdateCursorScale(); | 244 UpdateCursorScale(); |
231 } | 245 } |
232 | 246 |
233 void Pointer::OnScrollEvent(ui::ScrollEvent* event) { | 247 void Pointer::OnScrollEvent(ui::ScrollEvent* event) { |
234 OnMouseEvent(event); | 248 OnMouseEvent(event); |
235 } | 249 } |
236 | 250 |
237 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
238 // WMHelper::CursorObserver overrides: | 252 // WMHelper::CursorObserver overrides: |
239 | 253 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (!root_window) | 396 if (!root_window) |
383 return; | 397 return; |
384 | 398 |
385 aura::client::CursorClient* cursor_client = | 399 aura::client::CursorClient* cursor_client = |
386 aura::client::GetCursorClient(root_window); | 400 aura::client::GetCursorClient(root_window); |
387 if (cursor_client) | 401 if (cursor_client) |
388 cursor_client->SetCursor(cursor_); | 402 cursor_client->SetCursor(cursor_); |
389 } | 403 } |
390 | 404 |
391 } // namespace exo | 405 } // namespace exo |
OLD | NEW |