Chromium Code Reviews| 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(int device_id, unsigned int code, bool down) override; | 62 void DispatchKeyEvent(int device_id, unsigned int code, bool down) override; |
| 89 void DispatchMouseMoveEvent(int device_id, | 63 void DispatchMouseMoveEvent(int device_id, |
| 90 const gfx::PointF& location) override; | 64 const gfx::PointF& location) override; |
| 91 void DispatchMouseButtonEvent(int device_id, | 65 void DispatchMouseButtonEvent(int device_id, |
| 92 const gfx::PointF& location, | 66 const gfx::PointF& location, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 108 // PlatformEventSource: | 82 // PlatformEventSource: |
| 109 void OnDispatcherListChanged() override; | 83 void OnDispatcherListChanged() override; |
| 110 | 84 |
| 111 private: | 85 private: |
| 112 // Post a task to dispatch an event. | 86 // Post a task to dispatch an event. |
| 113 virtual void PostUiEvent(scoped_ptr<Event> event); | 87 virtual void PostUiEvent(scoped_ptr<Event> event); |
| 114 | 88 |
| 115 // Dispatch event via PlatformEventSource. | 89 // Dispatch event via PlatformEventSource. |
| 116 void DispatchUiEventTask(scoped_ptr<Event> event); | 90 void DispatchUiEventTask(scoped_ptr<Event> event); |
| 117 | 91 |
| 118 // Open device at path & starting processing events (on UI thread). | |
| 119 void AttachInputDevice(scoped_ptr<EventConverterEvdev> converter); | |
| 120 | |
| 121 // Close device at path (on UI thread). | |
| 122 void DetachInputDevice(const base::FilePath& file_path); | |
| 123 | |
| 124 // Update observers on device changes. | |
| 125 void NotifyDeviceChange(const EventConverterEvdev& converter); | |
| 126 void NotifyKeyboardsUpdated(); | |
| 127 void NotifyTouchscreensUpdated(); | |
| 128 | |
| 129 int NextDeviceId(); | 92 int NextDeviceId(); |
| 130 | 93 |
| 131 // Owned per-device event converters (by path). | |
| 132 std::map<base::FilePath, EventConverterEvdev*> converters_; | |
| 133 | |
| 134 // Used to uniquely identify input devices. | 94 // Used to uniquely identify input devices. |
| 135 int last_device_id_; | 95 int last_device_id_; |
| 136 | 96 |
| 137 // Interface for scanning & monitoring input devices. | 97 // Interface for scanning & monitoring input devices. |
| 138 DeviceManager* device_manager_; // Not owned. | 98 DeviceManager* device_manager_; // Not owned. |
| 139 | 99 |
| 140 // Task runner for event dispatch. | 100 // Factory for per-device objects. |
|
alexst (slow to review)
2015/01/27 19:31:41
We should add threading notes here.
spang
2015/01/28 01:40:46
Will add the comment to #10, which introduces the
| |
| 141 scoped_refptr<base::TaskRunner> ui_task_runner_; | 101 scoped_ptr<InputDeviceFactoryEvdev> input_device_factory_; |
| 142 | 102 |
| 143 // Dispatch callback for events. | 103 // Dispatch callback for events. |
| 144 EventDispatchCallback dispatch_callback_; | 104 EventDispatchCallback dispatch_callback_; |
| 145 | 105 |
| 146 // Modifier key state (shift, ctrl, etc). | 106 // Modifier key state (shift, ctrl, etc). |
| 147 EventModifiersEvdev modifiers_; | 107 EventModifiersEvdev modifiers_; |
| 148 | 108 |
| 149 // Mouse button map. | 109 // Mouse button map. |
| 150 MouseButtonMapEvdev button_map_; | 110 MouseButtonMapEvdev button_map_; |
| 151 | 111 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 168 | 128 |
| 169 // Support weak pointers for attach & detach callbacks. | 129 // Support weak pointers for attach & detach callbacks. |
| 170 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; | 130 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_; |
| 171 | 131 |
| 172 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); | 132 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); |
| 173 }; | 133 }; |
| 174 | 134 |
| 175 } // namespace ui | 135 } // namespace ui |
| 176 | 136 |
| 177 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ | 137 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_ |
| OLD | NEW |