Chromium Code Reviews| 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 #ifndef UI_EVENTS_X_TOUCH_FACTORY_X11_H_ | 5 #ifndef UI_EVENTS_X_TOUCH_FACTORY_X11_H_ |
| 6 #define UI_EVENTS_X_TOUCH_FACTORY_X11_H_ | 6 #define UI_EVENTS_X_TOUCH_FACTORY_X11_H_ |
| 7 | 7 |
| 8 #include <bitset> | 8 #include <bitset> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 13 #include "ui/events/events_base_export.h" | 14 #include "ui/events/events_base_export.h" |
| 14 #include "ui/gfx/sequential_id_generator.h" | 15 #include "ui/gfx/sequential_id_generator.h" |
| 15 | 16 |
| 16 template <typename T> struct DefaultSingletonTraits; | 17 template <typename T> struct DefaultSingletonTraits; |
| 17 | 18 |
| 18 typedef unsigned long Cursor; | 19 typedef unsigned long Cursor; |
| 19 typedef unsigned long Window; | 20 typedef unsigned long Window; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // Tries to find an existing slot ID mapping to tracking ID. If there | 66 // Tries to find an existing slot ID mapping to tracking ID. If there |
| 66 // isn't one already, allocates a new slot ID and sets up the mapping. | 67 // isn't one already, allocates a new slot ID and sets up the mapping. |
| 67 int GetSlotForTrackingID(uint32 tracking_id); | 68 int GetSlotForTrackingID(uint32 tracking_id); |
| 68 | 69 |
| 69 // Releases the slot ID mapping to tracking ID. | 70 // Releases the slot ID mapping to tracking ID. |
| 70 void ReleaseSlotForTrackingID(uint32 tracking_id); | 71 void ReleaseSlotForTrackingID(uint32 tracking_id); |
| 71 | 72 |
| 72 // Whether any touch device is currently present and enabled. | 73 // Whether any touch device is currently present and enabled. |
| 73 bool IsTouchDevicePresent(); | 74 bool IsTouchDevicePresent(); |
| 74 | 75 |
| 76 const std::set<std::pair<int, int> > GetTouchscreenIds() const { | |
|
sadrul
2013/12/12 19:28:59
&
tdresser
2013/12/12 21:24:22
Done.
| |
| 77 return touchscreen_ids_; | |
| 78 } | |
| 79 | |
| 75 // Return maximum simultaneous touch points supported by device. | 80 // Return maximum simultaneous touch points supported by device. |
| 76 int GetMaxTouchPoints() const; | 81 int GetMaxTouchPoints() const; |
| 77 | 82 |
| 78 // Sets up the device id in the list |devices| as multi-touch capable | 83 // Sets up the device id in the list |devices| as multi-touch capable |
| 79 // devices and enables touch events processing. This function is only | 84 // devices and enables touch events processing. This function is only |
| 80 // for test purpose, and it does not query from X server. | 85 // for test purpose, and it does not query from X server. |
| 81 void SetTouchDeviceForTest(const std::vector<unsigned int>& devices); | 86 void SetTouchDeviceForTest(const std::vector<unsigned int>& devices); |
| 82 | 87 |
| 83 // Sets up the device id in the list |devices| as pointer devices. | 88 // Sets up the device id in the list |devices| as pointer devices. |
| 84 // This function is only for test purpose, and it does not query from | 89 // This function is only for test purpose, and it does not query from |
| 85 // X server. | 90 // X server. |
| 86 void SetPointerDeviceForTest(const std::vector<unsigned int>& devices); | 91 void SetPointerDeviceForTest(const std::vector<unsigned int>& devices); |
| 87 | 92 |
| 88 private: | 93 private: |
| 89 // Requirement for Singleton | 94 // Requirement for Singleton |
| 90 friend struct DefaultSingletonTraits<TouchFactory>; | 95 friend struct DefaultSingletonTraits<TouchFactory>; |
| 91 | 96 |
| 97 void CacheTouchscreenIds(Display* display, int id); | |
| 98 | |
| 92 // NOTE: To keep track of touch devices, we currently maintain a lookup table | 99 // NOTE: To keep track of touch devices, we currently maintain a lookup table |
| 93 // to quickly decide if a device is a touch device or not. We also maintain a | 100 // to quickly decide if a device is a touch device or not. We also maintain a |
| 94 // list of the touch devices. Ideally, there will be only one touch device, | 101 // list of the touch devices. Ideally, there will be only one touch device, |
| 95 // and instead of having the lookup table and the list, there will be a single | 102 // and instead of having the lookup table and the list, there will be a single |
| 96 // identifier for the touch device. This can be completed after enough testing | 103 // identifier for the touch device. This can be completed after enough testing |
| 97 // on real touch devices. | 104 // on real touch devices. |
| 98 | 105 |
| 99 static const int kMaxDeviceNum = 128; | 106 static const int kMaxDeviceNum = 128; |
| 107 static const char* kDeviceProductIdString; | |
| 100 | 108 |
| 101 // A quick lookup table for determining if events from the pointer device | 109 // A quick lookup table for determining if events from the pointer device |
| 102 // should be processed. | 110 // should be processed. |
| 103 std::bitset<kMaxDeviceNum> pointer_device_lookup_; | 111 std::bitset<kMaxDeviceNum> pointer_device_lookup_; |
| 104 | 112 |
| 105 // A quick lookup table for determining if a device is a touch device. | 113 // A quick lookup table for determining if a device is a touch device. |
| 106 std::bitset<kMaxDeviceNum> touch_device_lookup_; | 114 std::bitset<kMaxDeviceNum> touch_device_lookup_; |
| 107 | 115 |
| 108 // Indicates whether a touch device is currently available or not. | 116 // Indicates whether a touch device is currently available or not. |
| 109 bool touch_device_available_; | 117 bool touch_device_available_; |
| 110 | 118 |
| 111 // Indicates whether touch events are explicitly disabled. | 119 // Indicates whether touch events are explicitly disabled. |
| 112 bool touch_events_disabled_; | 120 bool touch_events_disabled_; |
| 113 | 121 |
| 114 // The list of touch devices. For testing/debugging purposes, a single-pointer | 122 // The list of touch devices. For testing/debugging purposes, a single-pointer |
| 115 // device (mouse or touch screen without sufficient X/driver support for MT) | 123 // device (mouse or touch screen without sufficient X/driver support for MT) |
| 116 // can sometimes be treated as a touch device. The key in the map represents | 124 // can sometimes be treated as a touch device. The key in the map represents |
| 117 // the device id, and the value represents if the device is multi-touch | 125 // the device id, and the value represents if the device is multi-touch |
| 118 // capable. | 126 // capable. |
| 119 std::map<int, bool> touch_device_list_; | 127 std::map<int, bool> touch_device_list_; |
| 120 | 128 |
| 129 // Touch screen <vid, pid>s. | |
| 130 std::set<std::pair<int, int> > touchscreen_ids_; | |
| 131 | |
| 121 // Maximum simultaneous touch points supported by device. In the case of | 132 // Maximum simultaneous touch points supported by device. In the case of |
| 122 // devices with multiple digitizers (e.g. multiple touchscreens), the value | 133 // devices with multiple digitizers (e.g. multiple touchscreens), the value |
| 123 // is the maximum of the set of maximum supported contacts by each individual | 134 // is the maximum of the set of maximum supported contacts by each individual |
| 124 // digitizer. | 135 // digitizer. |
| 125 int max_touch_points_; | 136 int max_touch_points_; |
| 126 | 137 |
| 127 SequentialIDGenerator id_generator_; | 138 SequentialIDGenerator id_generator_; |
| 128 | 139 |
| 129 DISALLOW_COPY_AND_ASSIGN(TouchFactory); | 140 DISALLOW_COPY_AND_ASSIGN(TouchFactory); |
| 130 }; | 141 }; |
| 131 | 142 |
| 132 } // namespace ui | 143 } // namespace ui |
| 133 | 144 |
| 134 #endif // UI_EVENTS_X_TOUCH_FACTORY_X11_H_ | 145 #endif // UI_EVENTS_X_TOUCH_FACTORY_X11_H_ |
| OLD | NEW |