#include <bitset>
#include <map>
+#include <set>
+#include <utility>
#include <vector>
#include "base/timer/timer.h"
-#include "ui/events/events_export.h"
+#include "ui/events/events_base_export.h"
#include "ui/gfx/sequential_id_generator.h"
template <typename T> struct DefaultSingletonTraits;
namespace ui {
// Functions related to determining touch devices.
-class EVENTS_EXPORT TouchFactory {
+class EVENTS_BASE_EXPORT TouchFactory {
private:
TouchFactory();
~TouchFactory();
// below for more explanation.)
bool IsMultiTouchDevice(unsigned int deviceid) const;
-#if defined(USE_XI2_MT)
// Tries to find an existing slot ID mapping to tracking ID. Returns true
// if the slot is found and it is saved in |slot|, false if no such slot
// can be found.
// isn't one already, allocates a new slot ID and sets up the mapping.
int GetSlotForTrackingID(uint32 tracking_id);
+ // Increases the number of times |ReleaseSlotForTrackingID| needs to be called
+ // on a given tracking id before it will actually be released.
+ void AcquireSlotForTrackingID(uint32 tracking_id);
+
// Releases the slot ID mapping to tracking ID.
void ReleaseSlotForTrackingID(uint32 tracking_id);
-#endif
-
- // Is the slot ID currently used?
- bool IsSlotUsed(int slot) const;
-
- // Marks a slot as being used/unused.
- void SetSlotUsed(int slot, bool used);
// Whether any touch device is currently present and enabled.
bool IsTouchDevicePresent();
+ // Pairs of <vendor id, product id> of external touch screens.
+ const std::set<std::pair<int, int> >& GetTouchscreenIds() const {
+ return touchscreen_ids_;
+ }
+
+ // Return maximum simultaneous touch points supported by device.
+ int GetMaxTouchPoints() const;
+
+ // Resets the TouchFactory singleton.
+ void ResetForTest();
+
// Sets up the device id in the list |devices| as multi-touch capable
// devices and enables touch events processing. This function is only
// for test purpose, and it does not query from X server.
void SetTouchDeviceForTest(const std::vector<unsigned int>& devices);
+ // Sets up the device id in the list |devices| as pointer devices.
+ // This function is only for test purpose, and it does not query from
+ // X server.
+ void SetPointerDeviceForTest(const std::vector<unsigned int>& devices);
+
private:
// Requirement for Singleton
friend struct DefaultSingletonTraits<TouchFactory>;
+ void CacheTouchscreenIds(Display* display, int id);
+
// NOTE: To keep track of touch devices, we currently maintain a lookup table
// to quickly decide if a device is a touch device or not. We also maintain a
// list of the touch devices. Ideally, there will be only one touch device,
// capable.
std::map<int, bool> touch_device_list_;
- // Maximum simultaneous touch points.
- static const int kMaxTouchPoints = 32;
+ // Touch screen <vid, pid>s.
+ std::set<std::pair<int, int> > touchscreen_ids_;
-#if defined(USE_XI2_MT)
- SequentialIDGenerator id_generator_;
-#endif
+ // Maps from a tracking id to the number of times |ReleaseSlotForTrackingID|
+ // must be called before the tracking id is released.
+ std::map<uint32, int> tracking_id_refcounts_;
- // A lookup table for slots in use for a touch event.
- std::bitset<kMaxTouchPoints> slots_used_;
+ // Maximum simultaneous touch points supported by device. In the case of
+ // devices with multiple digitizers (e.g. multiple touchscreens), the value
+ // is the maximum of the set of maximum supported contacts by each individual
+ // digitizer.
+ int max_touch_points_;
+
+ // Device ID of the virtual core keyboard.
+ int virtual_core_keyboard_device_;
+
+ SequentialIDGenerator id_generator_;
DISALLOW_COPY_AND_ASSIGN(TouchFactory);
};