Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: ui/base/touch/touch_factory.h

Issue 9773024: This patch implements Chromium's Aura gesture recognizer in terms of utouch-grail and utouch-frame … (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_UTOUCH)
+#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,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 +86,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 +103,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,7 +130,24 @@
// Releases the slot ID mapping to tracking ID.
void ReleaseSlotForTrackingID(uint32 tracking_id);
+
+#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
+
+#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 {
sadrul 2012/04/03 19:52:01 This belongs in ui/aura/, either in root_window or
+ return native_root_window_aura_;
+ }
#endif
+#endif
// Is the slot ID currently used?
bool IsSlotUsed(int slot) const;
@@ -150,6 +207,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 +249,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_;
sadrul 2012/04/03 19:52:01 Update the comment to explain the change for USE_X
// 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 +268,15 @@
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
+
+#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.

Powered by Google App Engine
This is Rietveld 408576698