| 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> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback.h" | 8 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 14 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 15 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
| 16 #include "ui/events/ozone/device/device_event_observer.h" | 13 #include "ui/events/ozone/device/device_event_observer.h" |
| 17 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 14 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 18 #include "ui/events/ozone/evdev/event_converter_evdev.h" | |
| 19 #include "ui/events/ozone/evdev/event_device_info.h" | |
| 20 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 15 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
| 21 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 22 #include "ui/events/ozone/evdev/input_controller_evdev.h" | 17 #include "ui/events/ozone/evdev/input_controller_evdev.h" |
| 23 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 18 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 24 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" | 19 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" |
| 25 #include "ui/events/platform/platform_event_source.h" | 20 #include "ui/events/platform/platform_event_source.h" |
| 26 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
| 27 #include "ui/ozone/public/system_input_injector.h" | 22 #include "ui/ozone/public/system_input_injector.h" |
| 28 | 23 |
| 29 namespace gfx { | 24 namespace gfx { |
| 30 class PointF; | 25 class PointF; |
| 31 } // namespace gfx | 26 } // namespace gfx |
| 32 | 27 |
| 33 namespace ui { | 28 namespace ui { |
| 34 | 29 |
| 35 class CursorDelegateEvdev; | 30 class CursorDelegateEvdev; |
| 36 class DeviceManager; | 31 class DeviceManager; |
| 32 class InputDeviceFactoryEvdev; |
| 37 class SystemInputInjector; | 33 class SystemInputInjector; |
| 38 enum class DomCode; | 34 enum class DomCode; |
| 39 | 35 |
| 40 #if !defined(USE_EVDEV) | 36 #if !defined(USE_EVDEV) |
| 41 #error Missing dependency on ui/events/ozone:events_ozone_evdev | 37 #error Missing dependency on ui/events/ozone:events_ozone_evdev |
| 42 #endif | 38 #endif |
| 43 | 39 |
| 44 #if defined(USE_EVDEV_GESTURES) | |
| 45 class GesturePropertyProvider; | |
| 46 #endif | |
| 47 | |
| 48 // Ozone events implementation for the Linux input subsystem ("evdev"). | 40 // Ozone events implementation for the Linux input subsystem ("evdev"). |
| 49 class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev | 41 class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev |
| 50 : public DeviceEventObserver, | 42 : public DeviceEventObserver, |
| 51 public PlatformEventSource, | 43 public PlatformEventSource, |
| 52 public DeviceEventDispatcherEvdev { | 44 public DeviceEventDispatcherEvdev { |
| 53 public: | 45 public: |
| 54 EventFactoryEvdev(CursorDelegateEvdev* cursor, | 46 EventFactoryEvdev(CursorDelegateEvdev* cursor, |
| 55 DeviceManager* device_manager, | 47 DeviceManager* device_manager, |
| 56 KeyboardLayoutEngine* keyboard_layout_engine); | 48 KeyboardLayoutEngine* keyboard_layout_engine); |
| 57 ~EventFactoryEvdev() override; | 49 ~EventFactoryEvdev() override; |
| 58 | 50 |
| 59 // Initialize. Must be called with a valid message loop. | 51 // Initialize. Must be called with a valid message loop. |
| 60 void Init(); | 52 void Init(); |
| 61 | 53 |
| 62 // Get a list of device ids that matches a device type. Return true if the | |
| 63 // list is not empty. |device_ids| can be NULL. | |
| 64 bool GetDeviceIdsByType(const EventDeviceType type, | |
| 65 std::vector<int>* device_ids); | |
| 66 | |
| 67 void WarpCursorTo(gfx::AcceleratedWidget widget, | 54 void WarpCursorTo(gfx::AcceleratedWidget widget, |
| 68 const gfx::PointF& location); | 55 const gfx::PointF& location); |
| 69 | 56 |
| 70 // Disables the internal touchpad. | |
| 71 void DisableInternalTouchpad(); | |
| 72 | |
| 73 // Enables the internal touchpad. | |
| 74 void EnableInternalTouchpad(); | |
| 75 | |
| 76 // Disables all keys on the internal keyboard except |excepted_keys|. | |
| 77 void DisableInternalKeyboardExceptKeys( | |
| 78 scoped_ptr<std::set<DomCode>> excepted_keys); | |
| 79 | |
| 80 // Enables all keys on the internal keyboard. | |
| 81 void EnableInternalKeyboard(); | |
| 82 | |
| 83 scoped_ptr<SystemInputInjector> CreateSystemInputInjector(); | 57 scoped_ptr<SystemInputInjector> CreateSystemInputInjector(); |
| 84 | 58 |
| 85 InputController* input_controller() { return &input_controller_; } | 59 InputController* input_controller() { return &input_controller_; } |
| 86 | 60 |
| 87 // DeviceEventDispatchEvdev: | 61 // DeviceEventDispatchEvdev: |
| 88 void DispatchKeyEvent(const KeyEventParams& params) override; | 62 void DispatchKeyEvent(const KeyEventParams& params) override; |
| 89 void DispatchMouseMoveEvent(const MouseMoveEventParams& params) override; | 63 void DispatchMouseMoveEvent(const MouseMoveEventParams& params) override; |
| 90 void DispatchMouseButtonEvent(const MouseButtonEventParams& params) override; | 64 void DispatchMouseButtonEvent(const MouseButtonEventParams& params) override; |
| 91 void DispatchMouseWheelEvent(const MouseWheelEventParams& params) override; | 65 void DispatchMouseWheelEvent(const MouseWheelEventParams& params) override; |
| 92 void DispatchScrollEvent(const ScrollEventParams& params) override; | 66 void DispatchScrollEvent(const ScrollEventParams& params) override; |
| 93 void DispatchTouchEvent(const TouchEventParams& params) override; | 67 void DispatchTouchEvent(const TouchEventParams& params) override; |
| 94 | 68 |
| 95 protected: | 69 protected: |
| 96 // DeviceEventObserver overrides: | 70 // DeviceEventObserver overrides: |
| 97 // | 71 // |
| 98 // Callback for device add (on UI thread). | 72 // Callback for device add (on UI thread). |
| 99 void OnDeviceEvent(const DeviceEvent& event) override; | 73 void OnDeviceEvent(const DeviceEvent& event) override; |
| 100 | 74 |
| 101 // PlatformEventSource: | 75 // PlatformEventSource: |
| 102 void OnDispatcherListChanged() override; | 76 void OnDispatcherListChanged() override; |
| 103 | 77 |
| 104 private: | 78 private: |
| 105 // Post a task to dispatch an event. | 79 // Post a task to dispatch an event. |
| 106 virtual void PostUiEvent(scoped_ptr<Event> event); | 80 virtual void PostUiEvent(scoped_ptr<Event> event); |
| 107 | 81 |
| 108 // Dispatch event via PlatformEventSource. | 82 // Dispatch event via PlatformEventSource. |
| 109 void DispatchUiEventTask(scoped_ptr<Event> event); | 83 void DispatchUiEventTask(scoped_ptr<Event> event); |
| 110 | 84 |
| 111 // Open device at path & starting processing events (on UI thread). | |
| 112 void AttachInputDevice(scoped_ptr<EventConverterEvdev> converter); | |
| 113 | |
| 114 // Close device at path (on UI thread). | |
| 115 void DetachInputDevice(const base::FilePath& file_path); | |
| 116 | |
| 117 // Update observers on device changes. | |
| 118 void NotifyDeviceChange(const EventConverterEvdev& converter); | |
| 119 void NotifyKeyboardsUpdated(); | |
| 120 void NotifyTouchscreensUpdated(); | |
| 121 | |
| 122 int NextDeviceId(); | 85 int NextDeviceId(); |
| 123 | 86 |
| 124 // Owned per-device event converters (by path). | |
| 125 std::map<base::FilePath, EventConverterEvdev*> converters_; | |
| 126 | |
| 127 // Used to uniquely identify input devices. | 87 // Used to uniquely identify input devices. |
| 128 int last_device_id_; | 88 int last_device_id_; |
| 129 | 89 |
| 130 // Interface for scanning & monitoring input devices. | 90 // Interface for scanning & monitoring input devices. |
| 131 DeviceManager* device_manager_; // Not owned. | 91 DeviceManager* device_manager_; // Not owned. |
| 132 | 92 |
| 133 // Task runner for event dispatch. | 93 // Factory for per-device objects. |
| 134 scoped_refptr<base::TaskRunner> ui_task_runner_; | 94 scoped_ptr<InputDeviceFactoryEvdev> input_device_factory_; |
| 135 | 95 |
| 136 // Dispatch callback for events. | 96 // Dispatch callback for events. |
| 137 EventDispatchCallback dispatch_callback_; | 97 EventDispatchCallback dispatch_callback_; |
| 138 | 98 |
| 139 // Modifier key state (shift, ctrl, etc). | 99 // Modifier key state (shift, ctrl, etc). |
| 140 EventModifiersEvdev modifiers_; | 100 EventModifiersEvdev modifiers_; |
| 141 | 101 |
| 142 // Mouse button map. | 102 // Mouse button map. |
| 143 MouseButtonMapEvdev button_map_; | 103 MouseButtonMapEvdev button_map_; |
| 144 | 104 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 161 | 121 |
| 162 // Support weak pointers for attach & detach callbacks. | 122 // Support weak pointers for attach & detach callbacks. |
| 163 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; | 123 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; |
| 164 | 124 |
| 165 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); | 125 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); |
| 166 }; | 126 }; |
| 167 | 127 |
| 168 } // namespace ui | 128 } // namespace ui |
| 169 | 129 |
| 170 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ | 130 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ |
| OLD | NEW |