| 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_DEVICES_X11_TOUCH_FACTORY_X11_H_ | 5 #ifndef UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ |
| 6 #define UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ | 6 #define UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ |
| 7 | 7 |
| 8 #include <bitset> | 8 #include <bitset> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Checks whether an XI2 event should be processed or not (i.e. if the event | 42 // Checks whether an XI2 event should be processed or not (i.e. if the event |
| 43 // originated from a device we are interested in). | 43 // originated from a device we are interested in). |
| 44 bool ShouldProcessXI2Event(XEvent* xevent); | 44 bool ShouldProcessXI2Event(XEvent* xevent); |
| 45 | 45 |
| 46 // Setup an X Window for XInput2 events. | 46 // Setup an X Window for XInput2 events. |
| 47 void SetupXI2ForXWindow(::Window xid); | 47 void SetupXI2ForXWindow(::Window xid); |
| 48 | 48 |
| 49 // Keeps a list of touch devices so that it is possible to determine if a | 49 // Keeps a list of touch devices so that it is possible to determine if a |
| 50 // pointer event is a touch-event or a mouse-event. The list is reset each | 50 // pointer event is a touch-event or a mouse-event. The list is reset each |
| 51 // time this is called. | 51 // time this is called. |
| 52 void SetTouchDeviceList(const std::vector<unsigned int>& devices); | 52 void SetTouchDeviceList(const std::vector<int>& devices); |
| 53 | 53 |
| 54 // Is the device a touch-device? | 54 // Is the device a touch-device? |
| 55 bool IsTouchDevice(unsigned int deviceid) const; | 55 bool IsTouchDevice(int deviceid) const; |
| 56 | 56 |
| 57 // Is the device a real multi-touch-device? (see doc. for |touch_device_list_| | 57 // Is the device a real multi-touch-device? (see doc. for |touch_device_list_| |
| 58 // below for more explanation.) | 58 // below for more explanation.) |
| 59 bool IsMultiTouchDevice(unsigned int deviceid) const; | 59 bool IsMultiTouchDevice(int deviceid) const; |
| 60 | 60 |
| 61 // Tries to find an existing slot ID mapping to tracking ID. Returns true | 61 // Tries to find an existing slot ID mapping to tracking ID. Returns true |
| 62 // if the slot is found and it is saved in |slot|, false if no such slot | 62 // if the slot is found and it is saved in |slot|, false if no such slot |
| 63 // can be found. | 63 // can be found. |
| 64 bool QuerySlotForTrackingID(uint32 tracking_id, int* slot); | 64 bool QuerySlotForTrackingID(uint32 tracking_id, int* slot); |
| 65 | 65 |
| 66 // 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 |
| 67 // 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. |
| 68 int GetSlotForTrackingID(uint32 tracking_id); | 68 int GetSlotForTrackingID(uint32 tracking_id); |
| 69 | 69 |
| 70 // Releases the slot ID mapping to tracking ID. | 70 // Releases the slot ID mapping to tracking ID. |
| 71 void ReleaseSlotForTrackingID(uint32 tracking_id); | 71 void ReleaseSlotForTrackingID(uint32 tracking_id); |
| 72 | 72 |
| 73 // Whether any touch device is currently present and enabled. | 73 // Whether any touch device is currently present and enabled. |
| 74 bool IsTouchDevicePresent(); | 74 bool IsTouchDevicePresent(); |
| 75 | 75 |
| 76 // Pairs of <vendor id, product id> of external touch screens. | 76 // Pairs of <vendor id, product id> of external touch screens. |
| 77 const std::set<std::pair<int, int> >& GetTouchscreenIds() const { | 77 const std::set<std::pair<int, int> >& GetTouchscreenIds() const { |
| 78 return touchscreen_ids_; | 78 return touchscreen_ids_; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Resets the TouchFactory singleton. | 81 // Resets the TouchFactory singleton. |
| 82 void ResetForTest(); | 82 void ResetForTest(); |
| 83 | 83 |
| 84 // Sets up the device id in the list |devices| as multi-touch capable | 84 // Sets up the device id in the list |devices| as multi-touch capable |
| 85 // devices and enables touch events processing. This function is only | 85 // devices and enables touch events processing. This function is only |
| 86 // for test purpose, and it does not query from X server. | 86 // for test purpose, and it does not query from X server. |
| 87 void SetTouchDeviceForTest(const std::vector<unsigned int>& devices); | 87 void SetTouchDeviceForTest(const std::vector<int>& devices); |
| 88 | 88 |
| 89 // Sets up the device id in the list |devices| as pointer devices. | 89 // 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 | 90 // This function is only for test purpose, and it does not query from |
| 91 // X server. | 91 // X server. |
| 92 void SetPointerDeviceForTest(const std::vector<unsigned int>& devices); | 92 void SetPointerDeviceForTest(const std::vector<int>& devices); |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 // Requirement for Singleton | 95 // Requirement for Singleton |
| 96 friend struct DefaultSingletonTraits<TouchFactory>; | 96 friend struct DefaultSingletonTraits<TouchFactory>; |
| 97 | 97 |
| 98 void CacheTouchscreenIds(Display* display, int id); | 98 void CacheTouchscreenIds(Display* display, int id); |
| 99 | 99 |
| 100 // NOTE: To keep track of touch devices, we currently maintain a lookup table | 100 // 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 | 101 // 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, | 102 // list of the touch devices. Ideally, there will be only one touch device, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 130 int virtual_core_keyboard_device_; | 130 int virtual_core_keyboard_device_; |
| 131 | 131 |
| 132 SequentialIDGenerator id_generator_; | 132 SequentialIDGenerator id_generator_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(TouchFactory); | 134 DISALLOW_COPY_AND_ASSIGN(TouchFactory); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace ui | 137 } // namespace ui |
| 138 | 138 |
| 139 #endif // UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ | 139 #endif // UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ |
| OLD | NEW |