| Index: ui/events/devices/x11/device_data_manager_x11.h
|
| diff --git a/ui/events/platform/x11/device_data_manager_x11.h b/ui/events/devices/x11/device_data_manager_x11.h
|
| similarity index 89%
|
| rename from ui/events/platform/x11/device_data_manager_x11.h
|
| rename to ui/events/devices/x11/device_data_manager_x11.h
|
| index 801b1c59f95036e5a44cd44367062987d0b5ba25..c8e29f54600a34a84ad48bdeefedf092b475fbc5 100644
|
| --- a/ui/events/platform/x11/device_data_manager_x11.h
|
| +++ b/ui/events/devices/x11/device_data_manager_x11.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef UI_EVENTS_PLATFORM_X11_DEVICE_DATA_MANAGER_X11_H_
|
| -#define UI_EVENTS_PLATFORM_X11_DEVICE_DATA_MANAGER_X11_H_
|
| +#ifndef UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_
|
| +#define UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_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,
|
| @@ -15,6 +15,7 @@
|
| #include <X11/extensions/XInput2.h>
|
|
|
| #include <bitset>
|
| +#include <functional>
|
| #include <map>
|
| #include <set>
|
| #include <vector>
|
| @@ -22,9 +23,9 @@
|
| #include "base/basictypes.h"
|
| #include "base/event_types.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "ui/events/device_data_manager.h"
|
| +#include "ui/events/devices/device_data_manager.h"
|
| +#include "ui/events/devices/events_devices_export.h"
|
| #include "ui/events/event_constants.h"
|
| -#include "ui/events/events_base_export.h"
|
| #include "ui/events/keycodes/keyboard_codes.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| #include "ui/gfx/x/x11_atom_cache.h"
|
| @@ -41,7 +42,7 @@ enum GestureMetricsType {
|
|
|
| // A class that extracts and tracks the input events data. It currently handles
|
| // mouse, touchpad and touchscreen devices.
|
| -class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| +class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public 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,
|
| @@ -62,7 +63,7 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| DT_CMT_FLING_X, // Fling amount on the X (horizontal) direction.
|
| DT_CMT_FLING_Y, // Fling amount on the Y (vertical) direction.
|
| DT_CMT_FLING_STATE, // The state of fling gesture (whether the user just
|
| - // start flinging or that he/she taps down).
|
| + // started flinging or they tapped down).
|
| DT_CMT_METRICS_TYPE, // Metrics type of the metrics gesture, which are
|
| // used to wrap interesting patterns that we would
|
| // like to track via the UMA system.
|
| @@ -124,6 +125,9 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| // no slot can be found.
|
| bool GetSlotNumber(const XIDeviceEvent* xiev, int* slot);
|
|
|
| + // Check if an XI event contains data of the specified type.
|
| + bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const;
|
| +
|
| // Get all event data in one pass. We extract only data types that we know
|
| // about (defined in enum DataType). The data is not processed (e.g. not
|
| // filled in by cached values) as in GetEventData.
|
| @@ -203,11 +207,13 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| // *value = (*value - min_value_of_tp) / (max_value_of_tp - min_value_of_tp)
|
| // Returns true and sets the normalized value in|value| if normalization is
|
| // successful. Returns false and |value| is unchanged otherwise.
|
| - bool NormalizeData(unsigned int deviceid, const DataType type, double* value);
|
| + bool NormalizeData(int deviceid,
|
| + const DataType type,
|
| + double* value);
|
|
|
| // Extract the range of the data type. Return true if the range is available
|
| // and written into min & max, false if the range is not available.
|
| - bool GetDataRange(unsigned int deviceid,
|
| + bool GetDataRange(int deviceid,
|
| const DataType type,
|
| double* min,
|
| double* max);
|
| @@ -216,8 +222,9 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| // 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>& touchscreen,
|
| - const std::vector<unsigned int>& cmt_devices);
|
| + void SetDeviceListForTest(const std::vector<int>& touchscreen,
|
| + const std::vector<int>& cmt_devices,
|
| + const std::vector<int>& other_devices);
|
|
|
| void SetValuatorDataForTest(XIDeviceEvent* xievent,
|
| DataType type,
|
| @@ -227,15 +234,24 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
|
|
| // Sets the keys which are still allowed on a disabled keyboard device.
|
| void SetDisabledKeyboardAllowedKeys(
|
| - scoped_ptr<std::set<KeyboardCode>> excepted_keys);
|
| + scoped_ptr<std::set<KeyboardCode> > excepted_keys);
|
|
|
| // Disables and enables events from devices by device id.
|
| - void DisableDevice(unsigned int deviceid);
|
| - void EnableDevice(unsigned int deviceid);
|
| + void DisableDevice(int deviceid);
|
| + void EnableDevice(int deviceid);
|
|
|
| // Returns true if |native_event| should be blocked.
|
| bool IsEventBlocked(const base::NativeEvent& native_event);
|
|
|
| + const std::vector<int>& master_pointers() const {
|
| + return master_pointers_;
|
| + }
|
| +
|
| + protected:
|
| + // DeviceHotplugEventObserver:
|
| + void OnKeyboardDevicesUpdated(
|
| + const std::vector<KeyboardDevice>& devices) override;
|
| +
|
| private:
|
| DeviceDataManagerX11();
|
| ~DeviceDataManagerX11() override;
|
| @@ -243,9 +259,6 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| // Initialize the XInput related system information.
|
| bool InitializeXInputInternal();
|
|
|
| - // 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,
|
| @@ -266,12 +279,15 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| std::bitset<kMaxDeviceNum> cmt_devices_;
|
| std::bitset<kMaxDeviceNum> touchpads_;
|
|
|
| + // List of the master pointer devices.
|
| + std::vector<int> master_pointers_;
|
| +
|
| // A quick lookup table for determining if events from the XI device
|
| // should be blocked.
|
| std::bitset<kMaxDeviceNum> blocked_devices_;
|
|
|
| // The set of keys allowed while the keyboard is blocked.
|
| - scoped_ptr<std::set<KeyboardCode>> blocked_keyboard_allowed_keys_;
|
| + scoped_ptr<std::set<KeyboardCode> > blocked_keyboard_allowed_keys_;
|
|
|
| // Number of valuators on the specific device.
|
| int valuator_count_[kMaxDeviceNum];
|
| @@ -298,6 +314,10 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
| // use this only on touchscreen devices.
|
| std::vector<double> last_seen_valuator_[kMaxDeviceNum][kMaxSlotNum];
|
|
|
| + // Map that stores meta-data for blocked keyboards. This is needed to restore
|
| + // devices when they are re-enabled.
|
| + std::map<int, ui::KeyboardDevice> blocked_keyboards_;
|
| +
|
| // X11 atoms cache.
|
| X11AtomCache atom_cache_;
|
|
|
| @@ -309,4 +329,4 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
|
|
|
| } // namespace ui
|
|
|
| -#endif // UI_EVENTS_PLATFORM_X11_DEVICE_DATA_MANAGER_X11_H_
|
| +#endif // UI_EVENTS_DEVICES_X11_DEVICE_DATA_MANAGER_X11_H_
|
|
|