| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ |
| 6 #define UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 16 #include "ui/events/ozone/device/device_event_observer.h" | 16 #include "ui/events/ozone/device/device_event_observer.h" |
| 17 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 17 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 18 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
| 18 #include "ui/events/ozone/evdev/event_device_info.h" | 19 #include "ui/events/ozone/evdev/event_device_info.h" |
| 19 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 20 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
| 20 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 21 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 21 #include "ui/events/ozone/evdev/input_controller_evdev.h" | 22 #include "ui/events/ozone/evdev/input_controller_evdev.h" |
| 22 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 23 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 23 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" | 24 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" |
| 24 #include "ui/events/platform/platform_event_source.h" | 25 #include "ui/events/platform/platform_event_source.h" |
| 25 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
| 26 #include "ui/ozone/public/system_input_injector.h" | 27 #include "ui/ozone/public/system_input_injector.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 #if !defined(USE_EVDEV) | 40 #if !defined(USE_EVDEV) |
| 40 #error Missing dependency on ui/events/ozone:events_ozone_evdev | 41 #error Missing dependency on ui/events/ozone:events_ozone_evdev |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 #if defined(USE_EVDEV_GESTURES) | 44 #if defined(USE_EVDEV_GESTURES) |
| 44 class GesturePropertyProvider; | 45 class GesturePropertyProvider; |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 // Ozone events implementation for the Linux input subsystem ("evdev"). | 48 // Ozone events implementation for the Linux input subsystem ("evdev"). |
| 48 class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver, | 49 class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev |
| 49 public PlatformEventSource { | 50 : public DeviceEventObserver, |
| 51 public PlatformEventSource, |
| 52 public DeviceEventDispatcherEvdev { |
| 50 public: | 53 public: |
| 51 EventFactoryEvdev(CursorDelegateEvdev* cursor, | 54 EventFactoryEvdev(CursorDelegateEvdev* cursor, |
| 52 DeviceManager* device_manager, | 55 DeviceManager* device_manager, |
| 53 KeyboardLayoutEngine* keyboard_layout_engine); | 56 KeyboardLayoutEngine* keyboard_layout_engine); |
| 54 ~EventFactoryEvdev() override; | 57 ~EventFactoryEvdev() override; |
| 55 | 58 |
| 59 // Initialize. Must be called with a valid message loop. |
| 60 void Init(); |
| 61 |
| 56 // Get a list of device ids that matches a device type. Return true if the | 62 // Get a list of device ids that matches a device type. Return true if the |
| 57 // list is not empty. |device_ids| can be NULL. | 63 // list is not empty. |device_ids| can be NULL. |
| 58 bool GetDeviceIdsByType(const EventDeviceType type, | 64 bool GetDeviceIdsByType(const EventDeviceType type, |
| 59 std::vector<int>* device_ids); | 65 std::vector<int>* device_ids); |
| 60 | 66 |
| 61 void WarpCursorTo(gfx::AcceleratedWidget widget, | 67 void WarpCursorTo(gfx::AcceleratedWidget widget, |
| 62 const gfx::PointF& location); | 68 const gfx::PointF& location); |
| 63 | 69 |
| 64 // Disables the internal touchpad. | 70 // Disables the internal touchpad. |
| 65 void DisableInternalTouchpad(); | 71 void DisableInternalTouchpad(); |
| 66 | 72 |
| 67 // Enables the internal touchpad. | 73 // Enables the internal touchpad. |
| 68 void EnableInternalTouchpad(); | 74 void EnableInternalTouchpad(); |
| 69 | 75 |
| 70 // Disables all keys on the internal keyboard except |excepted_keys|. | 76 // Disables all keys on the internal keyboard except |excepted_keys|. |
| 71 void DisableInternalKeyboardExceptKeys( | 77 void DisableInternalKeyboardExceptKeys( |
| 72 scoped_ptr<std::set<DomCode>> excepted_keys); | 78 scoped_ptr<std::set<DomCode>> excepted_keys); |
| 73 | 79 |
| 74 // Enables all keys on the internal keyboard. | 80 // Enables all keys on the internal keyboard. |
| 75 void EnableInternalKeyboard(); | 81 void EnableInternalKeyboard(); |
| 76 | 82 |
| 77 scoped_ptr<SystemInputInjector> CreateSystemInputInjector(); | 83 scoped_ptr<SystemInputInjector> CreateSystemInputInjector(); |
| 78 | 84 |
| 79 InputController* input_controller() { return &input_controller_; } | 85 InputController* input_controller() { return &input_controller_; } |
| 80 | 86 |
| 81 // Post events to UI. | 87 // DeviceEventDispatchEvdev: |
| 82 void PostKeyEvent(int device_id, unsigned int code, bool down); | 88 void DispatchKeyEvent(int device_id, unsigned int code, bool down) override; |
| 83 void PostMouseMoveEvent(int device_id, const gfx::PointF& location); | 89 void DispatchMouseMoveEvent(int device_id, |
| 84 void PostMouseButtonEvent(int device_id, | 90 const gfx::PointF& location) override; |
| 85 const gfx::PointF& location, | 91 void DispatchMouseButtonEvent(int device_id, |
| 86 unsigned int button, | 92 const gfx::PointF& location, |
| 87 bool down, | 93 unsigned int button, |
| 88 bool allow_remap); | 94 bool down, |
| 89 void PostMouseWheelEvent(int device_id, | 95 bool allow_remap) override; |
| 90 const gfx::PointF& location, | 96 void DispatchMouseWheelEvent(int device_id, |
| 91 const gfx::Vector2d& delta); | 97 const gfx::PointF& location, |
| 92 void PostScrollEvent(const ScrollEventParams& params); | 98 const gfx::Vector2d& delta) override; |
| 93 void PostTouchEvent(const TouchEventParams& params); | 99 void DispatchScrollEvent(const ScrollEventParams& params) override; |
| 100 void DispatchTouchEvent(const TouchEventParams& params) override; |
| 94 | 101 |
| 95 protected: | 102 protected: |
| 96 // DeviceEventObserver overrides: | 103 // DeviceEventObserver overrides: |
| 97 // | 104 // |
| 98 // Callback for device add (on UI thread). | 105 // Callback for device add (on UI thread). |
| 99 void OnDeviceEvent(const DeviceEvent& event) override; | 106 void OnDeviceEvent(const DeviceEvent& event) override; |
| 100 | 107 |
| 101 // PlatformEventSource: | 108 // PlatformEventSource: |
| 102 void OnDispatcherListChanged() override; | 109 void OnDispatcherListChanged() override; |
| 103 | 110 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 CursorDelegateEvdev* cursor_; | 156 CursorDelegateEvdev* cursor_; |
| 150 | 157 |
| 151 #if defined(USE_EVDEV_GESTURES) | 158 #if defined(USE_EVDEV_GESTURES) |
| 152 // Gesture library property provider (used by touchpads/mice). | 159 // Gesture library property provider (used by touchpads/mice). |
| 153 scoped_ptr<GesturePropertyProvider> gesture_property_provider_; | 160 scoped_ptr<GesturePropertyProvider> gesture_property_provider_; |
| 154 #endif | 161 #endif |
| 155 | 162 |
| 156 // Object for controlling input devices. | 163 // Object for controlling input devices. |
| 157 InputControllerEvdev input_controller_; | 164 InputControllerEvdev input_controller_; |
| 158 | 165 |
| 166 // Whether we've set up the device factory & done initial scan. |
| 167 bool initialized_; |
| 168 |
| 159 // Support weak pointers for attach & detach callbacks. | 169 // Support weak pointers for attach & detach callbacks. |
| 160 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; | 170 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; |
| 161 | 171 |
| 162 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); | 172 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); |
| 163 }; | 173 }; |
| 164 | 174 |
| 165 } // namespace ui | 175 } // namespace ui |
| 166 | 176 |
| 167 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ | 177 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ |
| OLD | NEW |