| Index: ui/base/touch/touch_factory.h
|
| ===================================================================
|
| --- ui/base/touch/touch_factory.h (revision 126124)
|
| +++ ui/base/touch/touch_factory.h (working copy)
|
| @@ -10,8 +10,17 @@
|
| #include <map>
|
| #include <vector>
|
|
|
| +#if defined(USE_XI2_MT)
|
| +#include "ui/base/touch/multi_touch_device.h"
|
| +
|
| +#include <utouch/frame.h>
|
| +#include <utouch/frame_x11.h>
|
| +#endif
|
| +
|
| #include "base/memory/singleton.h"
|
| #include "base/hash_tables.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "base/observer_list_threadsafe.h"
|
| #include "base/timer.h"
|
| #include "ui/base/ui_export.h"
|
|
|
| @@ -25,6 +34,18 @@
|
| // 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
|
| +
|
| + struct DeviceObserver {
|
| + virtual ~DeviceObserver() {}
|
| +
|
| + 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 +82,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 +99,9 @@
|
| // originated from a device we are interested in).
|
| bool ShouldProcessXI2Event(XEvent* xevent);
|
|
|
| + // Preprocesses an XI2 event and feeds it to utouch frame.
|
| + void ProcessXI2Event(XEvent* event);
|
| +
|
| // Setup an X Window for XInput2 events.
|
| void SetupXI2ForXWindow(::Window xid);
|
|
|
| @@ -90,7 +124,22 @@
|
|
|
| // Releases the slot ID mapping to tracking ID.
|
| void ReleaseSlotForTrackingID(uint32 tracking_id);
|
| +
|
| + // 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_;
|
| + }
|
| +
|
| +#if defined(USE_AURA)
|
| + // Provides raw access to the X handle of the Aura
|
| + // root window. Defaults to ui::GetX11RootWindow()
|
| + ::Window native_root_window_aura() const {
|
| + return native_root_window_aura_;
|
| + }
|
| #endif
|
| +#endif
|
|
|
| // Is the slot ID currently used?
|
| bool IsSlotUsed(int slot) const;
|
| @@ -150,6 +199,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.
|
| @@ -189,7 +241,8 @@
|
| // 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_;
|
| + base::Lock touch_device_list_lock_;
|
| + 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,13 @@
|
| static const int kMaxTouchPoints = 32;
|
|
|
| #if defined(USE_XI2_MT)
|
| +#if defined(USE_AURA)
|
| + // The X handle of the aura root window
|
| + ::Window native_root_window_aura_;
|
| +#endif
|
| +
|
| + UFHandle utouch_frame_handle_;
|
| +
|
| // Stores the minimum available slot ID which helps get slot ID from
|
| // tracking ID. When it equals to kMaxTouchPoints, there is no available
|
| // slot.
|
|
|