Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / ozone / evdev / event_factory_evdev.h
blob5ce5a9b3bb9bf45b23c23aea86fe8b643ce03d51
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/task_runner.h"
13 #include "ui/events/ozone/device/device_event_observer.h"
14 #include "ui/events/ozone/evdev/event_converter_evdev.h"
15 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
17 #include "ui/events/platform/platform_event_source.h"
18 #include "ui/gfx/native_widget_types.h"
20 namespace gfx {
21 class PointF;
22 } // namespace gfx
24 namespace ui {
26 class CursorDelegateEvdev;
27 class DeviceManager;
29 // Ozone events implementation for the Linux input subsystem ("evdev").
30 class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver,
31 public PlatformEventSource {
32 public:
33 EventFactoryEvdev(CursorDelegateEvdev* cursor,
34 DeviceManager* device_manager);
35 virtual ~EventFactoryEvdev();
37 void DispatchUiEvent(Event* event);
39 void WarpCursorTo(gfx::AcceleratedWidget widget,
40 const gfx::PointF& location);
42 private:
43 // Open device at path & starting processing events (on UI thread).
44 void AttachInputDevice(const base::FilePath& file_path,
45 scoped_ptr<EventConverterEvdev> converter);
47 // Close device at path (on UI thread).
48 void DetachInputDevice(const base::FilePath& file_path);
50 // DeviceEventObserver overrides:
52 // Callback for device add (on UI thread).
53 virtual void OnDeviceEvent(const DeviceEvent& event) OVERRIDE;
55 // PlatformEventSource:
56 virtual void OnDispatcherListChanged() OVERRIDE;
58 // Owned per-device event converters (by path).
59 std::map<base::FilePath, EventConverterEvdev*> converters_;
61 // Interface for scanning & monitoring input devices.
62 DeviceManager* device_manager_; // Not owned.
64 // Task runner for event dispatch.
65 scoped_refptr<base::TaskRunner> ui_task_runner_;
67 // Modifier key state (shift, ctrl, etc).
68 EventModifiersEvdev modifiers_;
70 // Cursor movement.
71 CursorDelegateEvdev* cursor_;
73 // Dispatch callback for events.
74 EventDispatchCallback dispatch_callback_;
76 // Support weak pointers for attach & detach callbacks.
77 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_;
79 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev);
82 } // namespace ui
84 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_