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

Side by Side Diff: ui/events/ozone/evdev/event_factory_evdev.cc

Issue 806693009: Port ScopedDisableInternalMouseAndKeyboardX11 to Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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/event_factory_evdev.h" 5 #include "ui/events/ozone/evdev/event_factory_evdev.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 MouseButtonMapEvdev* button_map; 55 MouseButtonMapEvdev* button_map;
56 KeyboardEvdev* keyboard; 56 KeyboardEvdev* keyboard;
57 CursorDelegateEvdev* cursor; 57 CursorDelegateEvdev* cursor;
58 #if defined(USE_EVDEV_GESTURES) 58 #if defined(USE_EVDEV_GESTURES)
59 GesturePropertyProvider* gesture_property_provider; 59 GesturePropertyProvider* gesture_property_provider;
60 #endif 60 #endif
61 }; 61 };
62 62
63 #if defined(USE_EVDEV_GESTURES) 63 #if defined(USE_EVDEV_GESTURES)
64 bool UseGesturesLibraryForDevice(const EventDeviceInfo& devinfo) { 64 bool UseGesturesLibraryForDevice(const EventDeviceInfo& devinfo) {
65 if ((devinfo.HasAbsXY() || devinfo.HasMTAbsXY()) && 65 if (devinfo.HasTouchpad())
66 !devinfo.IsMappedToScreen()) 66 return true;
67 return true; // touchpad
68 67
69 if (devinfo.HasRelXY()) 68 if (devinfo.HasRelXY())
70 return true; // mouse 69 return true; // mouse
71 70
72 return false; 71 return false;
73 } 72 }
74 #endif 73 #endif
75 74
76 scoped_ptr<EventConverterEvdev> CreateConverter( 75 scoped_ptr<EventConverterEvdev> CreateConverter(
77 const OpenInputDeviceParams& params, 76 const OpenInputDeviceParams& params,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (cursor_) { 307 if (cursor_) {
309 cursor_->MoveCursorTo(widget, location); 308 cursor_->MoveCursorTo(widget, location);
310 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, 309 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED,
311 cursor_->GetLocation(), 310 cursor_->GetLocation(),
312 cursor_->GetLocation(), 311 cursor_->GetLocation(),
313 modifiers_.GetModifierFlags(), 312 modifiers_.GetModifierFlags(),
314 /* changed_button_flags */ 0))); 313 /* changed_button_flags */ 0)));
315 } 314 }
316 } 315 }
317 316
317 void EventFactoryEvdev::DisableInternalTouchpad() {
318 for (const auto& it : converters_) {
319 EventConverterEvdev* converter = it.second;
320 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
321 converter->HasTouchpad()) {
322 converter->set_ignore_events(true);
323 }
324 }
325 }
326
327 void EventFactoryEvdev::EnableInternalTouchpad() {
328 for (const auto& it : converters_) {
329 EventConverterEvdev* converter = it.second;
330 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
331 converter->HasTouchpad()) {
332 converter->set_ignore_events(false);
333 }
334 }
335 }
336
337 void EventFactoryEvdev::DisableInternalKeyboardExceptKeys(
338 scoped_ptr<std::set<DomCode>> excepted_keys) {
339 for (const auto& it : converters_) {
340 EventConverterEvdev* converter = it.second;
341 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
342 converter->HasKeyboard()) {
343 converter->SetAllowedKeys(excepted_keys.Pass());
344 }
345 }
346 }
347
348 void EventFactoryEvdev::EnableInternalKeyboard() {
349 for (const auto& it : converters_) {
350 EventConverterEvdev* converter = it.second;
351 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
352 converter->HasKeyboard()) {
353 converter->AllowAllKeys();
354 }
355 }
356 }
357
318 void EventFactoryEvdev::NotifyDeviceChange( 358 void EventFactoryEvdev::NotifyDeviceChange(
319 const EventConverterEvdev& converter) { 359 const EventConverterEvdev& converter) {
320 if (converter.HasTouchscreen()) 360 if (converter.HasTouchscreen())
321 NotifyTouchscreensUpdated(); 361 NotifyTouchscreensUpdated();
322 362
323 if (converter.HasKeyboard()) 363 if (converter.HasKeyboard())
324 NotifyKeyboardsUpdated(); 364 NotifyKeyboardsUpdated();
325 } 365 }
326 366
327 void EventFactoryEvdev::NotifyTouchscreensUpdated() { 367 void EventFactoryEvdev::NotifyTouchscreensUpdated() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 gesture_property_provider_->GetDeviceIdsByType(type, &ids); 406 gesture_property_provider_->GetDeviceIdsByType(type, &ids);
367 #endif 407 #endif
368 // In the future we can add other device matching logics here. 408 // In the future we can add other device matching logics here.
369 409
370 if (device_ids) 410 if (device_ids)
371 device_ids->assign(ids.begin(), ids.end()); 411 device_ids->assign(ids.begin(), ids.end());
372 return !ids.empty(); 412 return !ids.empty();
373 } 413 }
374 414
375 } // namespace ui 415 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698