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

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

Issue 806693009: Port ScopedDisableInternalMouseAndKeyboardX11 to Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/ozone/evdev/cursor_delegate_evdev.h" 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
15 #include "ui/events/ozone/evdev/event_device_info.h" 16 #include "ui/events/ozone/evdev/event_device_info.h"
16 #include "ui/events/ozone/evdev/event_device_util.h" 17 #include "ui/events/ozone/evdev/event_device_util.h"
17 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" 18 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
18 #include "ui/events/ozone/evdev/keyboard_evdev.h" 19 #include "ui/events/ozone/evdev/keyboard_evdev.h"
19 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" 21 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h"
21 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" 22 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
22 #include "ui/gfx/geometry/point_f.h" 23 #include "ui/gfx/geometry/point_f.h"
23 24
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE); 229 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE);
229 } 230 }
230 if (Event_Get_Button_Right(evdev)) { 231 if (Event_Get_Button_Right(evdev)) {
231 hwstate.buttons_down |= GetGestureButton( 232 hwstate.buttons_down |= GetGestureButton(
232 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT); 233 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT);
233 } 234 }
234 235
235 GestureInterpreterPushHardwareState(interpreter_, &hwstate); 236 GestureInterpreterPushHardwareState(interpreter_, &hwstate);
236 } 237 }
237 238
239 void GestureInterpreterLibevdevCros::SetAllowedKeys(
240 scoped_ptr<std::set<DomCode>> allowed_keys) {
241 if (!allowed_keys) {
242 allowed_keys_.reset();
243 return;
244 }
245
246 allowed_keys_.reset(new std::set<int>());
247 for (const auto& it : *allowed_keys) {
248 int evdev_code = KeyboardEvdev::NativeCodeToEvdevCode(
249 KeycodeConverter::DomCodeToNativeKeycode(it));
250 allowed_keys_->insert(evdev_code);
251 }
252 }
253
254 void GestureInterpreterLibevdevCros::AllowAllKeys() {
255 allowed_keys_.reset();
256 }
257
238 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { 258 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) {
239 switch (gesture->type) { 259 switch (gesture->type) {
240 case kGestureTypeMove: 260 case kGestureTypeMove:
241 OnGestureMove(gesture, &gesture->details.move); 261 OnGestureMove(gesture, &gesture->details.move);
242 break; 262 break;
243 case kGestureTypeScroll: 263 case kGestureTypeScroll:
244 OnGestureScroll(gesture, &gesture->details.scroll); 264 OnGestureScroll(gesture, &gesture->details.scroll);
245 break; 265 break;
246 case kGestureTypeButtonsChange: 266 case kGestureTypeButtonsChange:
247 OnGestureButtonsChange(gesture, &gesture->details.buttons); 267 OnGestureButtonsChange(gesture, &gesture->details.buttons);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key); 488 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key);
469 489
470 // Mouse buttons are handled by DispatchMouseButton. 490 // Mouse buttons are handled by DispatchMouseButton.
471 if (key >= BTN_MOUSE && key < BTN_JOYSTICK) 491 if (key >= BTN_MOUSE && key < BTN_JOYSTICK)
472 continue; 492 continue;
473 493
474 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). 494 // Ignore digi buttons (e.g. BTN_TOOL_FINGER).
475 if (key >= BTN_DIGI && key < BTN_WHEEL) 495 if (key >= BTN_DIGI && key < BTN_WHEEL)
476 continue; 496 continue;
477 497
498 if (allowed_keys_ && !allowed_keys_->count(key))
499 continue;
500
478 // Dispatch key press or release to keyboard. 501 // Dispatch key press or release to keyboard.
479 keyboard_->OnKeyChange(key, value); 502 keyboard_->OnKeyChange(key, value);
480 } 503 }
481 } 504 }
482 505
483 // Update internal key state. 506 // Update internal key state.
484 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) 507 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i)
485 prev_key_state_[i] = evdev->key_state_bitmask[i]; 508 prev_key_state_[i] = evdev->key_state_bitmask[i];
486 } 509 }
487 510
488 } // namespace ui 511 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698