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

Side by Side Diff: ui/events/x/events_x.cc

Issue 289283015: Extract touchscreen device management into a generic manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/x/device_list_cache_x.cc ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/events/event_constants.h" 5 #include "ui/events/event_constants.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string.h> 8 #include <string.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
11 #include <X11/Xlib.h> 11 #include <X11/Xlib.h>
12 #include <X11/Xutil.h> 12 #include <X11/Xutil.h>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "ui/events/event_utils.h" 16 #include "ui/events/event_utils.h"
17 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 17 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
18 #include "ui/events/x/device_data_manager.h" 18 #include "ui/events/x/device_data_manager_x11.h"
19 #include "ui/events/x/device_list_cache_x.h" 19 #include "ui/events/x/device_list_cache_x.h"
20 #include "ui/events/x/touch_factory_x11.h" 20 #include "ui/events/x/touch_factory_x11.h"
21 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
22 #include "ui/gfx/point.h" 22 #include "ui/gfx/point.h"
23 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/gfx/x/x11_atom_cache.h" 25 #include "ui/gfx/x/x11_atom_cache.h"
26 #include "ui/gfx/x/x11_types.h" 26 #include "ui/gfx/x/x11_types.h"
27 27
28 namespace { 28 namespace {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (ui::GetTouchForce(native_event) < 1.0f) 111 if (ui::GetTouchForce(native_event) < 1.0f)
112 return false; 112 return false;
113 113
114 if (ui::EventLocationFromNative(native_event) != gfx::Point()) 114 if (ui::EventLocationFromNative(native_event) != gfx::Point())
115 return false; 115 return false;
116 116
117 // Radius is in pixels, and the valuator is the diameter in pixels. 117 // Radius is in pixels, and the valuator is the diameter in pixels.
118 double radius = ui::GetTouchRadiusX(native_event), min, max; 118 double radius = ui::GetTouchRadiusX(native_event), min, max;
119 unsigned int deviceid = 119 unsigned int deviceid =
120 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; 120 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid;
121 if (!ui::DeviceDataManager::GetInstance()->GetDataRange( 121 if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange(
122 deviceid, ui::DeviceDataManager::DT_TOUCH_MAJOR, &min, &max)) { 122 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, &min, &max)) {
123 return false; 123 return false;
124 } 124 }
125 125
126 return radius * 2 == max; 126 return radius * 2 == max;
127 } 127 }
128 #endif 128 #endif
129 129
130 int GetEventFlagsFromXState(unsigned int state) { 130 int GetEventFlagsFromXState(unsigned int state) {
131 int flags = 0; 131 int flags = 0;
132 if (state & ControlMask) 132 if (state & ControlMask)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 default: 201 default:
202 return 0; 202 return 0;
203 } 203 }
204 } 204 }
205 205
206 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { 206 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
207 int buttonflags = 0; 207 int buttonflags = 0;
208 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { 208 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
209 if (XIMaskIsSet(xievent->buttons.mask, i)) { 209 if (XIMaskIsSet(xievent->buttons.mask, i)) {
210 int button = (xievent->sourceid == xievent->deviceid) ? 210 int button = (xievent->sourceid == xievent->deviceid) ?
211 ui::DeviceDataManager::GetInstance()->GetMappedButton(i) : i; 211 ui::DeviceDataManagerX11::GetInstance()->GetMappedButton(i) : i;
212 buttonflags |= GetEventFlagsForButton(button); 212 buttonflags |= GetEventFlagsForButton(button);
213 } 213 }
214 } 214 }
215 return buttonflags; 215 return buttonflags;
216 } 216 }
217 217
218 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) { 218 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) {
219 XIDeviceEvent* event = 219 XIDeviceEvent* event =
220 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 220 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
221 #if defined(USE_XI2_MT) 221 #if defined(USE_XI2_MT)
(...skipping 23 matching lines...) Expand all
245 GetButtonMaskForX2Event(event)) 245 GetButtonMaskForX2Event(event))
246 return ui::ET_TOUCH_MOVED; 246 return ui::ET_TOUCH_MOVED;
247 return ui::ET_UNKNOWN; 247 return ui::ET_UNKNOWN;
248 default: 248 default:
249 NOTREACHED(); 249 NOTREACHED();
250 } 250 }
251 return ui::ET_UNKNOWN; 251 return ui::ET_UNKNOWN;
252 } 252 }
253 253
254 double GetTouchParamFromXEvent(XEvent* xev, 254 double GetTouchParamFromXEvent(XEvent* xev,
255 ui::DeviceDataManager::DataType val, 255 ui::DeviceDataManagerX11::DataType val,
256 double default_value) { 256 double default_value) {
257 ui::DeviceDataManager::GetInstance()->GetEventData( 257 ui::DeviceDataManagerX11::GetInstance()->GetEventData(
258 *xev, val, &default_value); 258 *xev, val, &default_value);
259 return default_value; 259 return default_value;
260 } 260 }
261 261
262 } // namespace 262 } // namespace
263 263
264 namespace ui { 264 namespace ui {
265 265
266 void UpdateDeviceList() { 266 void UpdateDeviceList() {
267 XDisplay* display = gfx::GetXDisplay(); 267 XDisplay* display = gfx::GetXDisplay();
268 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); 268 DeviceListCacheX::GetInstance()->UpdateDeviceList(display);
269 TouchFactory::GetInstance()->UpdateDeviceList(display); 269 TouchFactory::GetInstance()->UpdateDeviceList(display);
270 DeviceDataManager::GetInstance()->UpdateDeviceList(display); 270 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display);
271 } 271 }
272 272
273 EventType EventTypeFromNative(const base::NativeEvent& native_event) { 273 EventType EventTypeFromNative(const base::NativeEvent& native_event) {
274 switch (native_event->type) { 274 switch (native_event->type) {
275 case KeyPress: 275 case KeyPress:
276 return ET_KEY_PRESSED; 276 return ET_KEY_PRESSED;
277 case KeyRelease: 277 case KeyRelease:
278 return ET_KEY_RELEASED; 278 return ET_KEY_RELEASED;
279 case ButtonPress: 279 case ButtonPress:
280 if (static_cast<int>(native_event->xbutton.button) >= kMinWheelButton && 280 if (static_cast<int>(native_event->xbutton.button) >= kMinWheelButton &&
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 int button = EventButtonFromNative(native_event); 330 int button = EventButtonFromNative(native_event);
331 // Drop wheel events; we should've already scrolled on the press. 331 // Drop wheel events; we should've already scrolled on the press.
332 if (button >= kMinWheelButton && button <= kMaxWheelButton) 332 if (button >= kMinWheelButton && button <= kMaxWheelButton)
333 return ET_UNKNOWN; 333 return ET_UNKNOWN;
334 return ET_MOUSE_RELEASED; 334 return ET_MOUSE_RELEASED;
335 } 335 }
336 case XI_Motion: { 336 case XI_Motion: {
337 bool is_cancel; 337 bool is_cancel;
338 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) { 338 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) {
339 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; 339 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START;
340 } else if (DeviceDataManager::GetInstance()->IsScrollEvent( 340 } else if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(
341 native_event)) { 341 native_event)) {
342 return IsTouchpadEvent(native_event) ? ET_SCROLL : ET_MOUSEWHEEL; 342 return IsTouchpadEvent(native_event) ? ET_SCROLL : ET_MOUSEWHEEL;
343 } else if (DeviceDataManager::GetInstance()->IsCMTMetricsEvent( 343 } else if (DeviceDataManagerX11::GetInstance()->IsCMTMetricsEvent(
344 native_event)) { 344 native_event)) {
345 return ET_UMA_DATA; 345 return ET_UMA_DATA;
346 } else if (GetButtonMaskForX2Event(xievent)) { 346 } else if (GetButtonMaskForX2Event(xievent)) {
347 return ET_MOUSE_DRAGGED; 347 return ET_MOUSE_DRAGGED;
348 } else { 348 } else {
349 return ET_MOUSE_MOVED; 349 return ET_MOUSE_MOVED;
350 } 350 }
351 } 351 }
352 } 352 }
353 } 353 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 case EnterNotify: 433 case EnterNotify:
434 case LeaveNotify: 434 case LeaveNotify:
435 return base::TimeDelta::FromMilliseconds(native_event->xcrossing.time); 435 return base::TimeDelta::FromMilliseconds(native_event->xcrossing.time);
436 break; 436 break;
437 case GenericEvent: { 437 case GenericEvent: {
438 double start, end; 438 double start, end;
439 double touch_timestamp; 439 double touch_timestamp;
440 if (GetGestureTimes(native_event, &start, &end)) { 440 if (GetGestureTimes(native_event, &start, &end)) {
441 // If the driver supports gesture times, use them. 441 // If the driver supports gesture times, use them.
442 return base::TimeDelta::FromMicroseconds(end * 1000000); 442 return base::TimeDelta::FromMicroseconds(end * 1000000);
443 } else if (DeviceDataManager::GetInstance()->GetEventData(*native_event, 443 } else if (DeviceDataManagerX11::GetInstance()->GetEventData(
444 DeviceDataManager::DT_TOUCH_RAW_TIMESTAMP, &touch_timestamp)) { 444 *native_event,
445 DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP,
446 &touch_timestamp)) {
445 return base::TimeDelta::FromMicroseconds(touch_timestamp * 1000000); 447 return base::TimeDelta::FromMicroseconds(touch_timestamp * 1000000);
446 } else { 448 } else {
447 XIDeviceEvent* xide = 449 XIDeviceEvent* xide =
448 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 450 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
449 return base::TimeDelta::FromMilliseconds(xide->time); 451 return base::TimeDelta::FromMilliseconds(xide->time);
450 } 452 }
451 break; 453 break;
452 } 454 }
453 } 455 }
454 NOTREACHED(); 456 NOTREACHED();
(...skipping 13 matching lines...) Expand all
468 case GenericEvent: { 470 case GenericEvent: {
469 XIDeviceEvent* xievent = 471 XIDeviceEvent* xievent =
470 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 472 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
471 float x = xievent->event_x; 473 float x = xievent->event_x;
472 float y = xievent->event_y; 474 float y = xievent->event_y;
473 #if defined(OS_CHROMEOS) 475 #if defined(OS_CHROMEOS)
474 switch (xievent->evtype) { 476 switch (xievent->evtype) {
475 case XI_TouchBegin: 477 case XI_TouchBegin:
476 case XI_TouchUpdate: 478 case XI_TouchUpdate:
477 case XI_TouchEnd: 479 case XI_TouchEnd:
478 ui::DeviceDataManager::GetInstance()->ApplyTouchTransformer( 480 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchTransformer(
479 xievent->deviceid, &x, &y); 481 xievent->deviceid, &x, &y);
480 break; 482 break;
481 default: 483 default:
482 break; 484 break;
483 } 485 }
484 #endif // defined(OS_CHROMEOS) 486 #endif // defined(OS_CHROMEOS)
485 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); 487 return gfx::Point(static_cast<int>(x), static_cast<int>(y));
486 } 488 }
487 } 489 }
488 return gfx::Point(); 490 return gfx::Point();
(...skipping 26 matching lines...) Expand all
515 return gfx::Point(); 517 return gfx::Point();
516 } 518 }
517 519
518 int EventButtonFromNative(const base::NativeEvent& native_event) { 520 int EventButtonFromNative(const base::NativeEvent& native_event) {
519 CHECK_EQ(GenericEvent, native_event->type); 521 CHECK_EQ(GenericEvent, native_event->type);
520 XIDeviceEvent* xievent = 522 XIDeviceEvent* xievent =
521 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 523 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
522 int button = xievent->detail; 524 int button = xievent->detail;
523 525
524 return (xievent->sourceid == xievent->deviceid) ? 526 return (xievent->sourceid == xievent->deviceid) ?
525 DeviceDataManager::GetInstance()->GetMappedButton(button) : button; 527 DeviceDataManagerX11::GetInstance()->GetMappedButton(button) : button;
526 } 528 }
527 529
528 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { 530 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
529 return KeyboardCodeFromXKeyEvent(native_event); 531 return KeyboardCodeFromXKeyEvent(native_event);
530 } 532 }
531 533
532 const char* CodeFromNative(const base::NativeEvent& native_event) { 534 const char* CodeFromNative(const base::NativeEvent& native_event) {
533 return CodeFromXEvent(native_event); 535 return CodeFromXEvent(native_event);
534 } 536 }
535 537
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 599
598 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { 600 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) {
599 delete event; 601 delete event;
600 } 602 }
601 603
602 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { 604 void ClearTouchIdIfReleased(const base::NativeEvent& xev) {
603 ui::EventType type = ui::EventTypeFromNative(xev); 605 ui::EventType type = ui::EventTypeFromNative(xev);
604 if (type == ui::ET_TOUCH_CANCELLED || 606 if (type == ui::ET_TOUCH_CANCELLED ||
605 type == ui::ET_TOUCH_RELEASED) { 607 type == ui::ET_TOUCH_RELEASED) {
606 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 608 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
607 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 609 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
608 double tracking_id; 610 double tracking_id;
609 if (manager->GetEventData( 611 if (manager->GetEventData(
610 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { 612 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
611 factory->ReleaseSlotForTrackingID(tracking_id); 613 factory->ReleaseSlotForTrackingID(tracking_id);
612 } 614 }
613 } 615 }
614 } 616 }
615 617
616 int GetTouchId(const base::NativeEvent& xev) { 618 int GetTouchId(const base::NativeEvent& xev) {
617 double slot = 0; 619 double slot = 0;
618 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 620 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
619 double tracking_id; 621 double tracking_id;
620 if (!manager->GetEventData( 622 if (!manager->GetEventData(
621 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { 623 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
622 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; 624 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0.";
623 } else { 625 } else {
624 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 626 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
625 slot = factory->GetSlotForTrackingID(tracking_id); 627 slot = factory->GetSlotForTrackingID(tracking_id);
626 } 628 }
627 return slot; 629 return slot;
628 } 630 }
629 631
630 float GetTouchRadiusX(const base::NativeEvent& native_event) { 632 float GetTouchRadiusX(const base::NativeEvent& native_event) {
631 return GetTouchParamFromXEvent(native_event, 633 return GetTouchParamFromXEvent(native_event,
632 ui::DeviceDataManager::DT_TOUCH_MAJOR, 0.0) / 2.0; 634 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0;
633 } 635 }
634 636
635 float GetTouchRadiusY(const base::NativeEvent& native_event) { 637 float GetTouchRadiusY(const base::NativeEvent& native_event) {
636 return GetTouchParamFromXEvent(native_event, 638 return GetTouchParamFromXEvent(native_event,
637 ui::DeviceDataManager::DT_TOUCH_MINOR, 0.0) / 2.0; 639 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0;
638 } 640 }
639 641
640 float GetTouchAngle(const base::NativeEvent& native_event) { 642 float GetTouchAngle(const base::NativeEvent& native_event) {
641 return GetTouchParamFromXEvent(native_event, 643 return GetTouchParamFromXEvent(native_event,
642 ui::DeviceDataManager::DT_TOUCH_ORIENTATION, 0.0) / 2.0; 644 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0;
643 } 645 }
644 646
645 float GetTouchForce(const base::NativeEvent& native_event) { 647 float GetTouchForce(const base::NativeEvent& native_event) {
646 double force = 0.0; 648 double force = 0.0;
647 force = GetTouchParamFromXEvent(native_event, 649 force = GetTouchParamFromXEvent(native_event,
648 ui::DeviceDataManager::DT_TOUCH_PRESSURE, 0.0); 650 ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0);
649 unsigned int deviceid = 651 unsigned int deviceid =
650 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; 652 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid;
651 // Force is normalized to fall into [0, 1] 653 // Force is normalized to fall into [0, 1]
652 if (!ui::DeviceDataManager::GetInstance()->NormalizeData( 654 if (!ui::DeviceDataManagerX11::GetInstance()->NormalizeData(
653 deviceid, ui::DeviceDataManager::DT_TOUCH_PRESSURE, &force)) 655 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force))
654 force = 0.0; 656 force = 0.0;
655 return force; 657 return force;
656 } 658 }
657 659
658 bool GetScrollOffsets(const base::NativeEvent& native_event, 660 bool GetScrollOffsets(const base::NativeEvent& native_event,
659 float* x_offset, 661 float* x_offset,
660 float* y_offset, 662 float* y_offset,
661 float* x_offset_ordinal, 663 float* x_offset_ordinal,
662 float* y_offset_ordinal, 664 float* y_offset_ordinal,
663 int* finger_count) { 665 int* finger_count) {
664 if (!DeviceDataManager::GetInstance()->IsScrollEvent(native_event)) 666 if (!DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event))
665 return false; 667 return false;
666 668
667 // Temp values to prevent passing NULLs to DeviceDataManager. 669 // Temp values to prevent passing NULLs to DeviceDataManager.
668 float x_offset_, y_offset_; 670 float x_offset_, y_offset_;
669 float x_offset_ordinal_, y_offset_ordinal_; 671 float x_offset_ordinal_, y_offset_ordinal_;
670 int finger_count_; 672 int finger_count_;
671 if (!x_offset) 673 if (!x_offset)
672 x_offset = &x_offset_; 674 x_offset = &x_offset_;
673 if (!y_offset) 675 if (!y_offset)
674 y_offset = &y_offset_; 676 y_offset = &y_offset_;
675 if (!x_offset_ordinal) 677 if (!x_offset_ordinal)
676 x_offset_ordinal = &x_offset_ordinal_; 678 x_offset_ordinal = &x_offset_ordinal_;
677 if (!y_offset_ordinal) 679 if (!y_offset_ordinal)
678 y_offset_ordinal = &y_offset_ordinal_; 680 y_offset_ordinal = &y_offset_ordinal_;
679 if (!finger_count) 681 if (!finger_count)
680 finger_count = &finger_count_; 682 finger_count = &finger_count_;
681 683
682 DeviceDataManager::GetInstance()->GetScrollOffsets( 684 DeviceDataManagerX11::GetInstance()->GetScrollOffsets(
683 native_event, 685 native_event,
684 x_offset, y_offset, 686 x_offset, y_offset,
685 x_offset_ordinal, y_offset_ordinal, 687 x_offset_ordinal, y_offset_ordinal,
686 finger_count); 688 finger_count);
687 return true; 689 return true;
688 } 690 }
689 691
690 bool GetFlingData(const base::NativeEvent& native_event, 692 bool GetFlingData(const base::NativeEvent& native_event,
691 float* vx, 693 float* vx,
692 float* vy, 694 float* vy,
693 float* vx_ordinal, 695 float* vx_ordinal,
694 float* vy_ordinal, 696 float* vy_ordinal,
695 bool* is_cancel) { 697 bool* is_cancel) {
696 if (!DeviceDataManager::GetInstance()->IsFlingEvent(native_event)) 698 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event))
697 return false; 699 return false;
698 700
699 float vx_, vy_; 701 float vx_, vy_;
700 float vx_ordinal_, vy_ordinal_; 702 float vx_ordinal_, vy_ordinal_;
701 bool is_cancel_; 703 bool is_cancel_;
702 if (!vx) 704 if (!vx)
703 vx = &vx_; 705 vx = &vx_;
704 if (!vy) 706 if (!vy)
705 vy = &vy_; 707 vy = &vy_;
706 if (!vx_ordinal) 708 if (!vx_ordinal)
707 vx_ordinal = &vx_ordinal_; 709 vx_ordinal = &vx_ordinal_;
708 if (!vy_ordinal) 710 if (!vy_ordinal)
709 vy_ordinal = &vy_ordinal_; 711 vy_ordinal = &vy_ordinal_;
710 if (!is_cancel) 712 if (!is_cancel)
711 is_cancel = &is_cancel_; 713 is_cancel = &is_cancel_;
712 714
713 DeviceDataManager::GetInstance()->GetFlingData( 715 DeviceDataManagerX11::GetInstance()->GetFlingData(
714 native_event, vx, vy, vx_ordinal, vy_ordinal, is_cancel); 716 native_event, vx, vy, vx_ordinal, vy_ordinal, is_cancel);
715 return true; 717 return true;
716 } 718 }
717 719
718 bool GetGestureTimes(const base::NativeEvent& native_event, 720 bool GetGestureTimes(const base::NativeEvent& native_event,
719 double* start_time, 721 double* start_time,
720 double* end_time) { 722 double* end_time) {
721 if (!DeviceDataManager::GetInstance()->HasGestureTimes(native_event)) 723 if (!DeviceDataManagerX11::GetInstance()->HasGestureTimes(native_event))
722 return false; 724 return false;
723 725
724 double start_time_, end_time_; 726 double start_time_, end_time_;
725 if (!start_time) 727 if (!start_time)
726 start_time = &start_time_; 728 start_time = &start_time_;
727 if (!end_time) 729 if (!end_time)
728 end_time = &end_time_; 730 end_time = &end_time_;
729 731
730 DeviceDataManager::GetInstance()->GetGestureTimes( 732 DeviceDataManagerX11::GetInstance()->GetGestureTimes(
731 native_event, start_time, end_time); 733 native_event, start_time, end_time);
732 return true; 734 return true;
733 } 735 }
734 736
735 bool IsTouchpadEvent(const base::NativeEvent& event) { 737 bool IsTouchpadEvent(const base::NativeEvent& event) {
736 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); 738 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event);
737 } 739 }
738 740
739 } // namespace ui 741 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/device_list_cache_x.cc ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698