Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / events / x / device_data_manager.h
index 1d78b14..ce009a0 100644 (file)
@@ -5,6 +5,13 @@
 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
 
+// Generically-named #defines from Xlib is conflicting with symbols in GTest.
+// So many tests .cc file #undef Bool before including device_data_manager.h,
+// which makes Bool unrecognized in XInput2.h.
+#ifndef Bool
+#define Bool int
+#endif
+
 #include <X11/extensions/XInput2.h>
 
 #include <bitset>
@@ -14,7 +21,7 @@
 #include "base/basictypes.h"
 #include "base/event_types.h"
 #include "ui/events/event_constants.h"
-#include "ui/events/events_export.h"
+#include "ui/events/events_base_export.h"
 #include "ui/gfx/x/x11_atom_cache.h"
 
 template <typename T> struct DefaultSingletonTraits;
@@ -31,7 +38,7 @@ enum GestureMetricsType {
 
 // A class that extracts and tracks the input events data. It currently handles
 // mouse, touchpad and touchscreen devices.
-class EVENTS_EXPORT DeviceDataManager {
+class EVENTS_BASE_EXPORT DeviceDataManager {
  public:
   // Enumerate additional data that one might be interested on an input event,
   // which are usually wrapped in X valuators. If you modify any of this,
@@ -73,22 +80,6 @@ class EVENTS_EXPORT DeviceDataManager {
                           // touch area.
     DT_TOUCH_PRESSURE,    // Pressure of the touch contact.
 
-    // NOTE: A touch event can have multiple touch points. So when we receive a
-    // touch event, we need to determine which point triggered the event.
-    // A touch point can have both a 'Slot ID' and a 'Tracking ID', and they can
-    // be (in fact, usually are) different. The 'Slot ID' ranges between 0 and
-    // (X - 1), where X is the maximum touch points supported by the device. The
-    // 'Tracking ID' can be any 16-bit value. With XInput 2.0, an XI_Motion
-    // event that comes from a currently-unused 'Slot ID' indicates the creation
-    // of a new touch point, and any event that comes with a 0 value for
-    // 'Tracking ID' marks the removal of a touch point. During the lifetime of
-    // a touchpoint, we use the 'Slot ID' as its identifier. The XI_ButtonPress
-    // and XI_ButtonRelease events are ignored.
-#if !defined(USE_XI2_MT)
-    DT_TOUCH_SLOT_ID,     // ID of the finger that triggered a touch event
-                          // (useful when tracking multiple simultaneous
-                          // touches).
-#endif
     // NOTE for XInput MT: 'Tracking ID' is provided in every touch event to
     // track individual touch. 'Tracking ID' is an unsigned 32-bit value and
     // is increased for each new touch. It will wrap back to 0 when reaching
@@ -113,14 +104,8 @@ class EVENTS_EXPORT DeviceDataManager {
   // Returns the DeviceDataManager singleton.
   static DeviceDataManager* GetInstance();
 
-  // Natural scroll setter/getter.
-  bool natural_scroll_enabled() const { return natural_scroll_enabled_; }
-  void set_natural_scroll_enabled(bool enabled) {
-    natural_scroll_enabled_ = enabled;
-  }
-
-  // Get the natural scroll direction multiplier (1.0f or -1.0f).
-  float GetNaturalScrollFactor(int sourceid) const;
+  // Returns if XInput2 is available on the system.
+  bool IsXInput2Available() const;
 
   // Updates the list of devices.
   void UpdateDeviceList(Display* display);
@@ -221,20 +206,17 @@ class EVENTS_EXPORT DeviceDataManager {
                     double* min,
                     double* max);
 
-  // Setups relevant valuator informations for device ids in the list |devices|.
+  // Sets up relevant valuator informations for device ids in the device lists.
   // This function is only for test purpose. It does not query the X server for
   // the actual device info, but rather inits the relevant valuator structures
   // to have safe default values for testing.
-  void SetDeviceListForTest(const std::vector<unsigned int>& devices);
-
-  // Setups device with |deviceid| to have valuator with type |data_type|,
-  // at index |val_index|, and with |min|/|max| values. This is only for test
-  // purpose.
-  void SetDeviceValuatorForTest(int deviceid,
-                                int val_index,
-                                DataType data_type,
-                                double min,
-                                double max);
+  void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen,
+                            const std::vector<unsigned int>& cmt_devices);
+
+  void SetValuatorDataForTest(XIDeviceEvent* xievent,
+                              DataType type,
+                              double value);
+
  private:
   // Requirement for Singleton.
   friend struct DefaultSingletonTraits<DeviceDataManager>;
@@ -248,10 +230,15 @@ class EVENTS_EXPORT DeviceDataManager {
   // Check if an XI event contains data of the specified type.
   bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const;
 
+  void InitializeValuatorsForTest(int deviceid,
+                                  int start_valuator,
+                                  int end_valuator,
+                                  double min_value,
+                                  double max_value);
+
   static const int kMaxDeviceNum = 128;
   static const int kMaxXIEventType = XI_LASTEVENT + 1;
   static const int kMaxSlotNum = 10;
-  bool natural_scroll_enabled_;
 
   // Major opcode for the XInput extension. Used to identify XInput events.
   int xi_opcode_;