| 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 "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 Loading... |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 default: | 198 default: |
| 199 return 0; | 199 return 0; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { | 203 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { |
| 204 int buttonflags = 0; | 204 int buttonflags = 0; |
| 205 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { | 205 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { |
| 206 if (XIMaskIsSet(xievent->buttons.mask, i)) { | 206 if (XIMaskIsSet(xievent->buttons.mask, i)) { |
| 207 int button = (xievent->sourceid == xievent->deviceid) ? | 207 int button = (xievent->sourceid == xievent->deviceid) ? |
| 208 ui::DeviceDataManager::GetInstance()->GetMappedButton(i) : i; | 208 ui::DeviceDataManagerX11::GetInstance()->GetMappedButton(i) : i; |
| 209 buttonflags |= GetEventFlagsForButton(button); | 209 buttonflags |= GetEventFlagsForButton(button); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 return buttonflags; | 212 return buttonflags; |
| 213 } | 213 } |
| 214 | 214 |
| 215 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) { | 215 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) { |
| 216 XIDeviceEvent* event = | 216 XIDeviceEvent* event = |
| 217 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 217 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 218 #if defined(USE_XI2_MT) | 218 #if defined(USE_XI2_MT) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 242 GetButtonMaskForX2Event(event)) | 242 GetButtonMaskForX2Event(event)) |
| 243 return ui::ET_TOUCH_MOVED; | 243 return ui::ET_TOUCH_MOVED; |
| 244 return ui::ET_UNKNOWN; | 244 return ui::ET_UNKNOWN; |
| 245 default: | 245 default: |
| 246 NOTREACHED(); | 246 NOTREACHED(); |
| 247 } | 247 } |
| 248 return ui::ET_UNKNOWN; | 248 return ui::ET_UNKNOWN; |
| 249 } | 249 } |
| 250 | 250 |
| 251 double GetTouchParamFromXEvent(XEvent* xev, | 251 double GetTouchParamFromXEvent(XEvent* xev, |
| 252 ui::DeviceDataManager::DataType val, | 252 ui::DeviceDataManagerX11::DataType val, |
| 253 double default_value) { | 253 double default_value) { |
| 254 ui::DeviceDataManager::GetInstance()->GetEventData( | 254 ui::DeviceDataManagerX11::GetInstance()->GetEventData( |
| 255 *xev, val, &default_value); | 255 *xev, val, &default_value); |
| 256 return default_value; | 256 return default_value; |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace | 259 } // namespace |
| 260 | 260 |
| 261 namespace ui { | 261 namespace ui { |
| 262 | 262 |
| 263 void UpdateDeviceList() { | 263 void UpdateDeviceList() { |
| 264 XDisplay* display = gfx::GetXDisplay(); | 264 XDisplay* display = gfx::GetXDisplay(); |
| 265 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); | 265 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); |
| 266 TouchFactory::GetInstance()->UpdateDeviceList(display); | 266 TouchFactory::GetInstance()->UpdateDeviceList(display); |
| 267 DeviceDataManager::GetInstance()->UpdateDeviceList(display); | 267 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display); |
| 268 } | 268 } |
| 269 | 269 |
| 270 EventType EventTypeFromNative(const base::NativeEvent& native_event) { | 270 EventType EventTypeFromNative(const base::NativeEvent& native_event) { |
| 271 switch (native_event->type) { | 271 switch (native_event->type) { |
| 272 case KeyPress: | 272 case KeyPress: |
| 273 return ET_KEY_PRESSED; | 273 return ET_KEY_PRESSED; |
| 274 case KeyRelease: | 274 case KeyRelease: |
| 275 return ET_KEY_RELEASED; | 275 return ET_KEY_RELEASED; |
| 276 case ButtonPress: | 276 case ButtonPress: |
| 277 if (static_cast<int>(native_event->xbutton.button) >= kMinWheelButton && | 277 if (static_cast<int>(native_event->xbutton.button) >= kMinWheelButton && |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 int button = EventButtonFromNative(native_event); | 327 int button = EventButtonFromNative(native_event); |
| 328 // Drop wheel events; we should've already scrolled on the press. | 328 // Drop wheel events; we should've already scrolled on the press. |
| 329 if (button >= kMinWheelButton && button <= kMaxWheelButton) | 329 if (button >= kMinWheelButton && button <= kMaxWheelButton) |
| 330 return ET_UNKNOWN; | 330 return ET_UNKNOWN; |
| 331 return ET_MOUSE_RELEASED; | 331 return ET_MOUSE_RELEASED; |
| 332 } | 332 } |
| 333 case XI_Motion: { | 333 case XI_Motion: { |
| 334 bool is_cancel; | 334 bool is_cancel; |
| 335 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) { | 335 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) { |
| 336 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; | 336 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; |
| 337 } else if (DeviceDataManager::GetInstance()->IsScrollEvent( | 337 } else if (DeviceDataManagerX11::GetInstance()->IsScrollEvent( |
| 338 native_event)) { | 338 native_event)) { |
| 339 return IsTouchpadEvent(native_event) ? ET_SCROLL : ET_MOUSEWHEEL; | 339 return IsTouchpadEvent(native_event) ? ET_SCROLL : ET_MOUSEWHEEL; |
| 340 } else if (DeviceDataManager::GetInstance()->IsCMTMetricsEvent( | 340 } else if (DeviceDataManagerX11::GetInstance()->IsCMTMetricsEvent( |
| 341 native_event)) { | 341 native_event)) { |
| 342 return ET_UMA_DATA; | 342 return ET_UMA_DATA; |
| 343 } else if (GetButtonMaskForX2Event(xievent)) { | 343 } else if (GetButtonMaskForX2Event(xievent)) { |
| 344 return ET_MOUSE_DRAGGED; | 344 return ET_MOUSE_DRAGGED; |
| 345 } else { | 345 } else { |
| 346 return ET_MOUSE_MOVED; | 346 return ET_MOUSE_MOVED; |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 } | 350 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 case EnterNotify: | 430 case EnterNotify: |
| 431 case LeaveNotify: | 431 case LeaveNotify: |
| 432 return base::TimeDelta::FromMilliseconds(native_event->xcrossing.time); | 432 return base::TimeDelta::FromMilliseconds(native_event->xcrossing.time); |
| 433 break; | 433 break; |
| 434 case GenericEvent: { | 434 case GenericEvent: { |
| 435 double start, end; | 435 double start, end; |
| 436 double touch_timestamp; | 436 double touch_timestamp; |
| 437 if (GetGestureTimes(native_event, &start, &end)) { | 437 if (GetGestureTimes(native_event, &start, &end)) { |
| 438 // If the driver supports gesture times, use them. | 438 // If the driver supports gesture times, use them. |
| 439 return base::TimeDelta::FromMicroseconds(end * 1000000); | 439 return base::TimeDelta::FromMicroseconds(end * 1000000); |
| 440 } else if (DeviceDataManager::GetInstance()->GetEventData(*native_event, | 440 } else if (DeviceDataManagerX11::GetInstance()->GetEventData( |
| 441 DeviceDataManager::DT_TOUCH_RAW_TIMESTAMP, &touch_timestamp)) { | 441 *native_event, |
| 442 DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP, |
| 443 &touch_timestamp)) { |
| 442 return base::TimeDelta::FromMicroseconds(touch_timestamp * 1000000); | 444 return base::TimeDelta::FromMicroseconds(touch_timestamp * 1000000); |
| 443 } else { | 445 } else { |
| 444 XIDeviceEvent* xide = | 446 XIDeviceEvent* xide = |
| 445 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 447 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 446 return base::TimeDelta::FromMilliseconds(xide->time); | 448 return base::TimeDelta::FromMilliseconds(xide->time); |
| 447 } | 449 } |
| 448 break; | 450 break; |
| 449 } | 451 } |
| 450 } | 452 } |
| 451 NOTREACHED(); | 453 NOTREACHED(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 465 case GenericEvent: { | 467 case GenericEvent: { |
| 466 XIDeviceEvent* xievent = | 468 XIDeviceEvent* xievent = |
| 467 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 469 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 468 float x = xievent->event_x; | 470 float x = xievent->event_x; |
| 469 float y = xievent->event_y; | 471 float y = xievent->event_y; |
| 470 #if defined(OS_CHROMEOS) | 472 #if defined(OS_CHROMEOS) |
| 471 switch (xievent->evtype) { | 473 switch (xievent->evtype) { |
| 472 case XI_TouchBegin: | 474 case XI_TouchBegin: |
| 473 case XI_TouchUpdate: | 475 case XI_TouchUpdate: |
| 474 case XI_TouchEnd: | 476 case XI_TouchEnd: |
| 475 ui::DeviceDataManager::GetInstance()->ApplyTouchTransformer( | 477 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchTransformer( |
| 476 xievent->deviceid, &x, &y); | 478 xievent->deviceid, &x, &y); |
| 477 break; | 479 break; |
| 478 default: | 480 default: |
| 479 break; | 481 break; |
| 480 } | 482 } |
| 481 #endif // defined(OS_CHROMEOS) | 483 #endif // defined(OS_CHROMEOS) |
| 482 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); | 484 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); |
| 483 } | 485 } |
| 484 } | 486 } |
| 485 return gfx::Point(); | 487 return gfx::Point(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 512 return gfx::Point(); | 514 return gfx::Point(); |
| 513 } | 515 } |
| 514 | 516 |
| 515 int EventButtonFromNative(const base::NativeEvent& native_event) { | 517 int EventButtonFromNative(const base::NativeEvent& native_event) { |
| 516 CHECK_EQ(GenericEvent, native_event->type); | 518 CHECK_EQ(GenericEvent, native_event->type); |
| 517 XIDeviceEvent* xievent = | 519 XIDeviceEvent* xievent = |
| 518 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 520 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 519 int button = xievent->detail; | 521 int button = xievent->detail; |
| 520 | 522 |
| 521 return (xievent->sourceid == xievent->deviceid) ? | 523 return (xievent->sourceid == xievent->deviceid) ? |
| 522 DeviceDataManager::GetInstance()->GetMappedButton(button) : button; | 524 DeviceDataManagerX11::GetInstance()->GetMappedButton(button) : button; |
| 523 } | 525 } |
| 524 | 526 |
| 525 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | 527 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { |
| 526 return KeyboardCodeFromXKeyEvent(native_event); | 528 return KeyboardCodeFromXKeyEvent(native_event); |
| 527 } | 529 } |
| 528 | 530 |
| 529 const char* CodeFromNative(const base::NativeEvent& native_event) { | 531 const char* CodeFromNative(const base::NativeEvent& native_event) { |
| 530 return CodeFromXEvent(native_event); | 532 return CodeFromXEvent(native_event); |
| 531 } | 533 } |
| 532 | 534 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 590 |
| 589 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { | 591 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { |
| 590 delete event; | 592 delete event; |
| 591 } | 593 } |
| 592 | 594 |
| 593 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { | 595 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { |
| 594 ui::EventType type = ui::EventTypeFromNative(xev); | 596 ui::EventType type = ui::EventTypeFromNative(xev); |
| 595 if (type == ui::ET_TOUCH_CANCELLED || | 597 if (type == ui::ET_TOUCH_CANCELLED || |
| 596 type == ui::ET_TOUCH_RELEASED) { | 598 type == ui::ET_TOUCH_RELEASED) { |
| 597 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 599 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
| 598 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 600 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
| 599 double tracking_id; | 601 double tracking_id; |
| 600 if (manager->GetEventData( | 602 if (manager->GetEventData( |
| 601 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { | 603 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) { |
| 602 factory->ReleaseSlotForTrackingID(tracking_id); | 604 factory->ReleaseSlotForTrackingID(tracking_id); |
| 603 } | 605 } |
| 604 } | 606 } |
| 605 } | 607 } |
| 606 | 608 |
| 607 int GetTouchId(const base::NativeEvent& xev) { | 609 int GetTouchId(const base::NativeEvent& xev) { |
| 608 double slot = 0; | 610 double slot = 0; |
| 609 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 611 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
| 610 double tracking_id; | 612 double tracking_id; |
| 611 if (!manager->GetEventData( | 613 if (!manager->GetEventData( |
| 612 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { | 614 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) { |
| 613 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; | 615 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; |
| 614 } else { | 616 } else { |
| 615 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 617 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
| 616 slot = factory->GetSlotForTrackingID(tracking_id); | 618 slot = factory->GetSlotForTrackingID(tracking_id); |
| 617 } | 619 } |
| 618 return slot; | 620 return slot; |
| 619 } | 621 } |
| 620 | 622 |
| 621 float GetTouchRadiusX(const base::NativeEvent& native_event) { | 623 float GetTouchRadiusX(const base::NativeEvent& native_event) { |
| 622 return GetTouchParamFromXEvent(native_event, | 624 return GetTouchParamFromXEvent(native_event, |
| 623 ui::DeviceDataManager::DT_TOUCH_MAJOR, 0.0) / 2.0; | 625 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0; |
| 624 } | 626 } |
| 625 | 627 |
| 626 float GetTouchRadiusY(const base::NativeEvent& native_event) { | 628 float GetTouchRadiusY(const base::NativeEvent& native_event) { |
| 627 return GetTouchParamFromXEvent(native_event, | 629 return GetTouchParamFromXEvent(native_event, |
| 628 ui::DeviceDataManager::DT_TOUCH_MINOR, 0.0) / 2.0; | 630 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0; |
| 629 } | 631 } |
| 630 | 632 |
| 631 float GetTouchAngle(const base::NativeEvent& native_event) { | 633 float GetTouchAngle(const base::NativeEvent& native_event) { |
| 632 return GetTouchParamFromXEvent(native_event, | 634 return GetTouchParamFromXEvent(native_event, |
| 633 ui::DeviceDataManager::DT_TOUCH_ORIENTATION, 0.0) / 2.0; | 635 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0; |
| 634 } | 636 } |
| 635 | 637 |
| 636 float GetTouchForce(const base::NativeEvent& native_event) { | 638 float GetTouchForce(const base::NativeEvent& native_event) { |
| 637 double force = 0.0; | 639 double force = 0.0; |
| 638 force = GetTouchParamFromXEvent(native_event, | 640 force = GetTouchParamFromXEvent(native_event, |
| 639 ui::DeviceDataManager::DT_TOUCH_PRESSURE, 0.0); | 641 ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0); |
| 640 unsigned int deviceid = | 642 unsigned int deviceid = |
| 641 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; | 643 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; |
| 642 // Force is normalized to fall into [0, 1] | 644 // Force is normalized to fall into [0, 1] |
| 643 if (!ui::DeviceDataManager::GetInstance()->NormalizeData( | 645 if (!ui::DeviceDataManagerX11::GetInstance()->NormalizeData( |
| 644 deviceid, ui::DeviceDataManager::DT_TOUCH_PRESSURE, &force)) | 646 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force)) |
| 645 force = 0.0; | 647 force = 0.0; |
| 646 return force; | 648 return force; |
| 647 } | 649 } |
| 648 | 650 |
| 649 bool GetScrollOffsets(const base::NativeEvent& native_event, | 651 bool GetScrollOffsets(const base::NativeEvent& native_event, |
| 650 float* x_offset, | 652 float* x_offset, |
| 651 float* y_offset, | 653 float* y_offset, |
| 652 float* x_offset_ordinal, | 654 float* x_offset_ordinal, |
| 653 float* y_offset_ordinal, | 655 float* y_offset_ordinal, |
| 654 int* finger_count) { | 656 int* finger_count) { |
| 655 if (!DeviceDataManager::GetInstance()->IsScrollEvent(native_event)) | 657 if (!DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) |
| 656 return false; | 658 return false; |
| 657 | 659 |
| 658 // Temp values to prevent passing NULLs to DeviceDataManager. | 660 // Temp values to prevent passing NULLs to DeviceDataManager. |
| 659 float x_offset_, y_offset_; | 661 float x_offset_, y_offset_; |
| 660 float x_offset_ordinal_, y_offset_ordinal_; | 662 float x_offset_ordinal_, y_offset_ordinal_; |
| 661 int finger_count_; | 663 int finger_count_; |
| 662 if (!x_offset) | 664 if (!x_offset) |
| 663 x_offset = &x_offset_; | 665 x_offset = &x_offset_; |
| 664 if (!y_offset) | 666 if (!y_offset) |
| 665 y_offset = &y_offset_; | 667 y_offset = &y_offset_; |
| 666 if (!x_offset_ordinal) | 668 if (!x_offset_ordinal) |
| 667 x_offset_ordinal = &x_offset_ordinal_; | 669 x_offset_ordinal = &x_offset_ordinal_; |
| 668 if (!y_offset_ordinal) | 670 if (!y_offset_ordinal) |
| 669 y_offset_ordinal = &y_offset_ordinal_; | 671 y_offset_ordinal = &y_offset_ordinal_; |
| 670 if (!finger_count) | 672 if (!finger_count) |
| 671 finger_count = &finger_count_; | 673 finger_count = &finger_count_; |
| 672 | 674 |
| 673 DeviceDataManager::GetInstance()->GetScrollOffsets( | 675 DeviceDataManagerX11::GetInstance()->GetScrollOffsets( |
| 674 native_event, | 676 native_event, |
| 675 x_offset, y_offset, | 677 x_offset, y_offset, |
| 676 x_offset_ordinal, y_offset_ordinal, | 678 x_offset_ordinal, y_offset_ordinal, |
| 677 finger_count); | 679 finger_count); |
| 678 return true; | 680 return true; |
| 679 } | 681 } |
| 680 | 682 |
| 681 bool GetFlingData(const base::NativeEvent& native_event, | 683 bool GetFlingData(const base::NativeEvent& native_event, |
| 682 float* vx, | 684 float* vx, |
| 683 float* vy, | 685 float* vy, |
| 684 float* vx_ordinal, | 686 float* vx_ordinal, |
| 685 float* vy_ordinal, | 687 float* vy_ordinal, |
| 686 bool* is_cancel) { | 688 bool* is_cancel) { |
| 687 if (!DeviceDataManager::GetInstance()->IsFlingEvent(native_event)) | 689 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event)) |
| 688 return false; | 690 return false; |
| 689 | 691 |
| 690 float vx_, vy_; | 692 float vx_, vy_; |
| 691 float vx_ordinal_, vy_ordinal_; | 693 float vx_ordinal_, vy_ordinal_; |
| 692 bool is_cancel_; | 694 bool is_cancel_; |
| 693 if (!vx) | 695 if (!vx) |
| 694 vx = &vx_; | 696 vx = &vx_; |
| 695 if (!vy) | 697 if (!vy) |
| 696 vy = &vy_; | 698 vy = &vy_; |
| 697 if (!vx_ordinal) | 699 if (!vx_ordinal) |
| 698 vx_ordinal = &vx_ordinal_; | 700 vx_ordinal = &vx_ordinal_; |
| 699 if (!vy_ordinal) | 701 if (!vy_ordinal) |
| 700 vy_ordinal = &vy_ordinal_; | 702 vy_ordinal = &vy_ordinal_; |
| 701 if (!is_cancel) | 703 if (!is_cancel) |
| 702 is_cancel = &is_cancel_; | 704 is_cancel = &is_cancel_; |
| 703 | 705 |
| 704 DeviceDataManager::GetInstance()->GetFlingData( | 706 DeviceDataManagerX11::GetInstance()->GetFlingData( |
| 705 native_event, vx, vy, vx_ordinal, vy_ordinal, is_cancel); | 707 native_event, vx, vy, vx_ordinal, vy_ordinal, is_cancel); |
| 706 return true; | 708 return true; |
| 707 } | 709 } |
| 708 | 710 |
| 709 bool GetGestureTimes(const base::NativeEvent& native_event, | 711 bool GetGestureTimes(const base::NativeEvent& native_event, |
| 710 double* start_time, | 712 double* start_time, |
| 711 double* end_time) { | 713 double* end_time) { |
| 712 if (!DeviceDataManager::GetInstance()->HasGestureTimes(native_event)) | 714 if (!DeviceDataManagerX11::GetInstance()->HasGestureTimes(native_event)) |
| 713 return false; | 715 return false; |
| 714 | 716 |
| 715 double start_time_, end_time_; | 717 double start_time_, end_time_; |
| 716 if (!start_time) | 718 if (!start_time) |
| 717 start_time = &start_time_; | 719 start_time = &start_time_; |
| 718 if (!end_time) | 720 if (!end_time) |
| 719 end_time = &end_time_; | 721 end_time = &end_time_; |
| 720 | 722 |
| 721 DeviceDataManager::GetInstance()->GetGestureTimes( | 723 DeviceDataManagerX11::GetInstance()->GetGestureTimes( |
| 722 native_event, start_time, end_time); | 724 native_event, start_time, end_time); |
| 723 return true; | 725 return true; |
| 724 } | 726 } |
| 725 | 727 |
| 726 bool IsTouchpadEvent(const base::NativeEvent& event) { | 728 bool IsTouchpadEvent(const base::NativeEvent& event) { |
| 727 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); | 729 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); |
| 728 } | 730 } |
| 729 | 731 |
| 730 } // namespace ui | 732 } // namespace ui |
| OLD | NEW |