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

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 6 years 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
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE); 228 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE);
229 } 229 }
230 if (Event_Get_Button_Right(evdev)) { 230 if (Event_Get_Button_Right(evdev)) {
231 hwstate.buttons_down |= GetGestureButton( 231 hwstate.buttons_down |= GetGestureButton(
232 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT); 232 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT);
233 } 233 }
234 234
235 GestureInterpreterPushHardwareState(interpreter_, &hwstate); 235 GestureInterpreterPushHardwareState(interpreter_, &hwstate);
236 } 236 }
237 237
238 void GestureInterpreterLibevdevCros::SetAllowedKeys(
239 scoped_ptr<std::set<KeyboardCode>> allowed_keys) {
240 allowed_keys_ = allowed_keys.Pass();
241 }
242
243 void GestureInterpreterLibevdevCros::AllowAllKeys() {
244 allowed_keys_.reset();
245 }
246
238 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { 247 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) {
239 switch (gesture->type) { 248 switch (gesture->type) {
240 case kGestureTypeMove: 249 case kGestureTypeMove:
241 OnGestureMove(gesture, &gesture->details.move); 250 OnGestureMove(gesture, &gesture->details.move);
242 break; 251 break;
243 case kGestureTypeScroll: 252 case kGestureTypeScroll:
244 OnGestureScroll(gesture, &gesture->details.scroll); 253 OnGestureScroll(gesture, &gesture->details.scroll);
245 break; 254 break;
246 case kGestureTypeButtonsChange: 255 case kGestureTypeButtonsChange:
247 OnGestureButtonsChange(gesture, &gesture->details.buttons); 256 OnGestureButtonsChange(gesture, &gesture->details.buttons);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key); 485 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key);
477 486
478 // Mouse buttons are handled by DispatchMouseButton. 487 // Mouse buttons are handled by DispatchMouseButton.
479 if (key >= BTN_MOUSE && key < BTN_JOYSTICK) 488 if (key >= BTN_MOUSE && key < BTN_JOYSTICK)
480 continue; 489 continue;
481 490
482 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). 491 // Ignore digi buttons (e.g. BTN_TOOL_FINGER).
483 if (key >= BTN_DIGI && key < BTN_WHEEL) 492 if (key >= BTN_DIGI && key < BTN_WHEEL)
484 continue; 493 continue;
485 494
495 KeyboardCode key_code = KeyboardEvdev::KeyboardCodeFromEvdevKey(key);
496 if (allowed_keys_ && !allowed_keys_->count(key_code))
497 continue;
498
486 // Dispatch key press or release to keyboard. 499 // Dispatch key press or release to keyboard.
487 keyboard_->OnKeyChange(key, value); 500 keyboard_->OnKeyChange(key, value);
488 } 501 }
489 } 502 }
490 503
491 // Update internal key state. 504 // Update internal key state.
492 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) 505 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i)
493 prev_key_state_[i] = evdev->key_state_bitmask[i]; 506 prev_key_state_[i] = evdev->key_state_bitmask[i];
494 } 507 }
495 508
496 } // namespace ui 509 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698