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