Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc

Issue 872883003: [PATCH 2/11] ozone: evdev: Move KeyboardEvdev usage during dispatch to EventFactoryEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates for events_unittests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h" 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h"
6 6
7 #include <gestures/gestures.h> 7 #include <gestures/gestures.h>
8 #include <libevdev/libevdev.h> 8 #include <libevdev/libevdev.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 10
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/keycodes/dom4/keycode_converter.h" 14 #include "ui/events/keycodes/dom4/keycode_converter.h"
15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
16 #include "ui/events/ozone/evdev/event_device_info.h" 16 #include "ui/events/ozone/evdev/event_device_info.h"
17 #include "ui/events/ozone/evdev/event_device_util.h" 17 #include "ui/events/ozone/evdev/event_device_util.h"
18 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" 18 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
19 #include "ui/events/ozone/evdev/keyboard_evdev.h" 19 #include "ui/events/ozone/evdev/keyboard_util_evdev.h"
20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
21 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" 21 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h"
22 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" 22 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
23 #include "ui/gfx/geometry/point_f.h" 23 #include "ui/gfx/geometry/point_f.h"
24 24
25 namespace ui { 25 namespace ui {
26 26
27 namespace { 27 namespace {
28 28
29 // Convert libevdev device class to libgestures device class. 29 // Convert libevdev device class to libgestures device class.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Number of fingers for swipe gestures. 103 // Number of fingers for swipe gestures.
104 const int kGestureSwipeFingerCount = 3; 104 const int kGestureSwipeFingerCount = 3;
105 105
106 } // namespace 106 } // namespace
107 107
108 GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros( 108 GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros(
109 int id, 109 int id,
110 EventModifiersEvdev* modifiers, 110 EventModifiersEvdev* modifiers,
111 MouseButtonMapEvdev* button_map, 111 MouseButtonMapEvdev* button_map,
112 CursorDelegateEvdev* cursor, 112 CursorDelegateEvdev* cursor,
113 KeyboardEvdev* keyboard,
114 GesturePropertyProvider* property_provider, 113 GesturePropertyProvider* property_provider,
114 const KeyEventDispatchCallback& key_callback,
115 const EventDispatchCallback& callback) 115 const EventDispatchCallback& callback)
116 : id_(id), 116 : id_(id),
117 is_mouse_(false), 117 is_mouse_(false),
118 modifiers_(modifiers), 118 modifiers_(modifiers),
119 button_map_(button_map), 119 button_map_(button_map),
120 cursor_(cursor), 120 cursor_(cursor),
121 keyboard_(keyboard),
122 property_provider_(property_provider), 121 property_provider_(property_provider),
122 key_callback_(key_callback),
123 dispatch_callback_(callback), 123 dispatch_callback_(callback),
124 interpreter_(NULL), 124 interpreter_(NULL),
125 evdev_(NULL), 125 evdev_(NULL),
126 device_properties_(new GestureDeviceProperties) { 126 device_properties_(new GestureDeviceProperties) {
127 memset(&prev_key_state_, 0, sizeof(prev_key_state_)); 127 memset(&prev_key_state_, 0, sizeof(prev_key_state_));
128 } 128 }
129 129
130 GestureInterpreterLibevdevCros::~GestureInterpreterLibevdevCros() { 130 GestureInterpreterLibevdevCros::~GestureInterpreterLibevdevCros() {
131 // Note that this destructor got called after the evdev device node has been 131 // Note that this destructor got called after the evdev device node has been
132 // closed. Therefore, all clean-up codes here shouldn't depend on the device 132 // closed. Therefore, all clean-up codes here shouldn't depend on the device
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 void GestureInterpreterLibevdevCros::SetAllowedKeys( 239 void GestureInterpreterLibevdevCros::SetAllowedKeys(
240 scoped_ptr<std::set<DomCode>> allowed_keys) { 240 scoped_ptr<std::set<DomCode>> allowed_keys) {
241 if (!allowed_keys) { 241 if (!allowed_keys) {
242 allowed_keys_.reset(); 242 allowed_keys_.reset();
243 return; 243 return;
244 } 244 }
245 245
246 allowed_keys_.reset(new std::set<int>()); 246 allowed_keys_.reset(new std::set<int>());
247 for (const auto& it : *allowed_keys) { 247 for (const auto& it : *allowed_keys) {
248 int evdev_code = KeyboardEvdev::NativeCodeToEvdevCode( 248 int evdev_code =
249 KeycodeConverter::DomCodeToNativeKeycode(it)); 249 NativeCodeToEvdevCode(KeycodeConverter::DomCodeToNativeKeycode(it));
250 allowed_keys_->insert(evdev_code); 250 allowed_keys_->insert(evdev_code);
251 } 251 }
252 } 252 }
253 253
254 void GestureInterpreterLibevdevCros::AllowAllKeys() { 254 void GestureInterpreterLibevdevCros::AllowAllKeys() {
255 allowed_keys_.reset(); 255 allowed_keys_.reset();
256 } 256 }
257 257
258 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { 258 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) {
259 switch (gesture->type) { 259 switch (gesture->type) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 continue; 501 continue;
502 502
503 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). 503 // Ignore digi buttons (e.g. BTN_TOOL_FINGER).
504 if (key >= BTN_DIGI && key < BTN_WHEEL) 504 if (key >= BTN_DIGI && key < BTN_WHEEL)
505 continue; 505 continue;
506 506
507 if (allowed_keys_ && !allowed_keys_->count(key)) 507 if (allowed_keys_ && !allowed_keys_->count(key))
508 continue; 508 continue;
509 509
510 // Dispatch key press or release to keyboard. 510 // Dispatch key press or release to keyboard.
511 keyboard_->OnKeyChange(key, value); 511 key_callback_.Run(id_, key, value);
512 } 512 }
513 } 513 }
514 514
515 // Update internal key state. 515 // Update internal key state.
516 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) 516 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i)
517 prev_key_state_[i] = evdev->key_state_bitmask[i]; 517 prev_key_state_[i] = evdev->key_state_bitmask[i];
518 } 518 }
519 519
520 } // namespace ui 520 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698