| Index: ui/base/touch/touch_factory.h
|
| ===================================================================
|
| --- ui/base/touch/touch_factory.h (revision 126124)
|
| +++ ui/base/touch/touch_factory.h (working copy)
|
| @@ -10,9 +10,18 @@
|
| #include <map>
|
| #include <vector>
|
|
|
| +#include "base/hash_tables.h"
|
| #include "base/memory/singleton.h"
|
| -#include "base/hash_tables.h"
|
| +#include "base/observer_list_threadsafe.h"
|
| +#include "base/synchronization/lock.h"
|
| #include "base/timer.h"
|
| +#if defined(USE_XI2_MT)
|
| +#if defined(USE_UTOUCH)
|
| +#include "third_party/utouch-frame/include/utouch/frame.h"
|
| +#include "third_party/utouch-frame/include/utouch/frame_x11.h"
|
| +#endif // USE_UTOUCH
|
| +#include "ui/base/touch/multi_touch_device.h"
|
| +#endif // USE_XI2_MT
|
| #include "ui/base/ui_export.h"
|
|
|
| typedef unsigned long Cursor;
|
| @@ -25,6 +34,21 @@
|
| // Functions related to determining touch devices.
|
| class UI_EXPORT TouchFactory {
|
| public:
|
| +#if !defined(USE_XI2_MT)
|
| + typedef std::map<int, bool> TouchDeviceList;
|
| +#else
|
| + typedef std::map<int, MultiTouchDevice> TouchDeviceList;
|
| +#endif
|
| +
|
| + // Allow components interested in multi-touch hierarch events
|
| + // to be notified if a device has been added or removed.
|
| + struct DeviceObserver {
|
| + virtual ~DeviceObserver() {}
|
| +
|
| + // Called when the list of known devices changes.
|
| + virtual void OnDevicesUpdated(TouchDeviceList deviceList) = 0;
|
| + };
|
| +
|
| // Define the touch params following the Multi-touch Protocol.
|
| enum TouchParam {
|
| TP_TOUCH_MAJOR = 0, // Length of the touch area.
|
| @@ -61,6 +85,16 @@
|
| // Returns the TouchFactory singleton.
|
| static TouchFactory* GetInstance();
|
|
|
| + // Add a new observer.
|
| + // Can be called from any thread.
|
| + // Must not be called from within a notification callback.
|
| + void AddDeviceObserver(DeviceObserver * observer);
|
| +
|
| + // Remove an existing observer.
|
| + // Can be called from any thread.
|
| + // Must not be called from within a notification callback.
|
| + void RemoveDeviceObserver(DeviceObserver * observer);
|
| +
|
| // Updates the list of devices.
|
| void UpdateDeviceList(Display* display);
|
|
|
| @@ -68,6 +102,11 @@
|
| // originated from a device we are interested in).
|
| bool ShouldProcessXI2Event(XEvent* xevent);
|
|
|
| +#if defined(USE_UTOUCH)
|
| + // Preprocesses an XI2 event and feeds it to utouch frame.
|
| + void ProcessXI2Event(XEvent* event);
|
| +#endif // USE_UTOUCH
|
| +
|
| // Setup an X Window for XInput2 events.
|
| void SetupXI2ForXWindow(::Window xid);
|
|
|
| @@ -90,8 +129,17 @@
|
|
|
| // Releases the slot ID mapping to tracking ID.
|
| void ReleaseSlotForTrackingID(uint32 tracking_id);
|
| -#endif
|
|
|
| +#if defined(USE_UTOUCH)
|
| + // Provides raw access to the utouch-frame instance.
|
| + // TODO(tvoss): Come up with a more secure and clean
|
| + // pattern to provide access to the frame instance.
|
| + UFHandle handle() const {
|
| + return utouch_frame_handle_;
|
| + }
|
| +#endif // USE_UTOUCH
|
| +#endif // USE_XI2_MT
|
| +
|
| // Is the slot ID currently used?
|
| bool IsSlotUsed(int slot) const;
|
|
|
| @@ -150,6 +198,9 @@
|
| // Requirement for Signleton
|
| friend struct DefaultSingletonTraits<TouchFactory>;
|
|
|
| + // Observer management
|
| + ObserverListThreadSafe<DeviceObserver>* device_observer_list_;
|
| +
|
| // The default cursor is hidden after startup, and when the mouse pointer is
|
| // idle for a while. Once there is some event from a mouse device, the cursor
|
| // is immediately displayed.
|
| @@ -188,8 +239,10 @@
|
| // device (mouse or touch screen without sufficient X/driver support for MT)
|
| // can sometimes be treated as a touch device. The key in the map represents
|
| // the device id, and the value represents if the device is multi-touch
|
| - // capable.
|
| - std::map<int, bool> touch_device_list_;
|
| + // capable. If USE_XI2_MT is defined, the list contains not only boolean
|
| + // values indicating multi-touch capabilites of the respective device but an
|
| + // instance of class ui::MultiTouchDevice.
|
| + TouchDeviceList touch_device_list_;
|
|
|
| // Index table to find the valuator for the TouchParam on the specific device
|
| // by valuator_lookup_[device_id][touch_params]. Use 2-D array to get fast
|
| @@ -207,6 +260,10 @@
|
| static const int kMaxTouchPoints = 32;
|
|
|
| #if defined(USE_XI2_MT)
|
| +#if defined(USE_UTOUCH)
|
| + UFHandle utouch_frame_handle_;
|
| +#endif // USE_UTOUCH
|
| +
|
| // Stores the minimum available slot ID which helps get slot ID from
|
| // tracking ID. When it equals to kMaxTouchPoints, there is no available
|
| // slot.
|
| @@ -215,7 +272,7 @@
|
| // A hash table to map tracking ID to slot.
|
| typedef base::hash_map<uint32, int> TrackingIdMap;
|
| TrackingIdMap tracking_id_map_;
|
| -#endif
|
| +#endif // USE_XI2_MT
|
|
|
| // A lookup table for slots in use for a touch event.
|
| std::bitset<kMaxTouchPoints> slots_used_;
|
|
|