Index: ui/base/touch/touch_factory.h |
=================================================================== |
--- ui/base/touch/touch_factory.h (revision 126124) |
+++ ui/base/touch/touch_factory.h (working copy) |
@@ -6,13 +6,23 @@ |
#define UI_BASE_TOUCH_TOUCH_FACTORY_H_ |
#pragma once |
+#if defined(USE_XI2_MT) |
+#include <utouch/frame.h> |
+#include <utouch/frame_x11.h> |
+#endif |
+ |
#include <bitset> |
#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) |
+#include "ui/base/touch/multi_touch_device.h" |
+#endif |
#include "ui/base/ui_export.h" |
typedef unsigned long Cursor; |
@@ -25,6 +35,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 +83,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 +100,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 +125,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 +200,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 +242,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 +261,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. |