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> |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return gfx::Vector2d(0, -kWheelScrollAmount); | 527 return gfx::Vector2d(0, -kWheelScrollAmount); |
528 case 6: | 528 case 6: |
529 return gfx::Vector2d(kWheelScrollAmount, 0); | 529 return gfx::Vector2d(kWheelScrollAmount, 0); |
530 case 7: | 530 case 7: |
531 return gfx::Vector2d(-kWheelScrollAmount, 0); | 531 return gfx::Vector2d(-kWheelScrollAmount, 0); |
532 default: | 532 default: |
533 return gfx::Vector2d(); | 533 return gfx::Vector2d(); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
| 537 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { |
| 538 if (!event || event->type == GenericEvent) |
| 539 return NULL; |
| 540 XEvent* copy = new XEvent; |
| 541 *copy = *event; |
| 542 return copy; |
| 543 } |
| 544 |
| 545 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { delete event; } |
| 546 |
537 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { | 547 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { |
538 ui::EventType type = ui::EventTypeFromNative(xev); | 548 ui::EventType type = ui::EventTypeFromNative(xev); |
539 if (type == ui::ET_TOUCH_CANCELLED || | 549 if (type == ui::ET_TOUCH_CANCELLED || |
540 type == ui::ET_TOUCH_RELEASED) { | 550 type == ui::ET_TOUCH_RELEASED) { |
541 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 551 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
542 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 552 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); |
543 double tracking_id; | 553 double tracking_id; |
544 if (manager->GetEventData( | 554 if (manager->GetEventData( |
545 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { | 555 *xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) { |
546 factory->ReleaseSlotForTrackingID(tracking_id); | 556 factory->ReleaseSlotForTrackingID(tracking_id); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 683 |
674 bool IsNaturalScrollEnabled() { | 684 bool IsNaturalScrollEnabled() { |
675 return DeviceDataManager::GetInstance()->natural_scroll_enabled(); | 685 return DeviceDataManager::GetInstance()->natural_scroll_enabled(); |
676 } | 686 } |
677 | 687 |
678 bool IsTouchpadEvent(const base::NativeEvent& event) { | 688 bool IsTouchpadEvent(const base::NativeEvent& event) { |
679 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); | 689 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); |
680 } | 690 } |
681 | 691 |
682 } // namespace ui | 692 } // namespace ui |
OLD | NEW |