OLD | NEW |
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 Loading... |
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 Loading... |
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 DCHECK(!converter->HasKeyboard()); |
| 323 converter->set_ignore_events(true); |
| 324 } |
| 325 } |
| 326 } |
| 327 |
| 328 void EventFactoryEvdev::EnableInternalTouchpad() { |
| 329 for (const auto& it : converters_) { |
| 330 EventConverterEvdev* converter = it.second; |
| 331 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 332 converter->HasTouchpad()) { |
| 333 DCHECK(!converter->HasKeyboard()); |
| 334 converter->set_ignore_events(false); |
| 335 } |
| 336 } |
| 337 } |
| 338 |
| 339 void EventFactoryEvdev::DisableInternalKeyboardExceptKeys( |
| 340 scoped_ptr<std::set<DomCode>> excepted_keys) { |
| 341 for (const auto& it : converters_) { |
| 342 EventConverterEvdev* converter = it.second; |
| 343 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 344 converter->HasKeyboard()) { |
| 345 converter->SetAllowedKeys(excepted_keys.Pass()); |
| 346 } |
| 347 } |
| 348 } |
| 349 |
| 350 void EventFactoryEvdev::EnableInternalKeyboard() { |
| 351 for (const auto& it : converters_) { |
| 352 EventConverterEvdev* converter = it.second; |
| 353 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 354 converter->HasKeyboard()) { |
| 355 converter->AllowAllKeys(); |
| 356 } |
| 357 } |
| 358 } |
| 359 |
318 void EventFactoryEvdev::NotifyDeviceChange( | 360 void EventFactoryEvdev::NotifyDeviceChange( |
319 const EventConverterEvdev& converter) { | 361 const EventConverterEvdev& converter) { |
320 if (converter.HasTouchscreen()) | 362 if (converter.HasTouchscreen()) |
321 NotifyTouchscreensUpdated(); | 363 NotifyTouchscreensUpdated(); |
322 | 364 |
323 if (converter.HasKeyboard()) | 365 if (converter.HasKeyboard()) |
324 NotifyKeyboardsUpdated(); | 366 NotifyKeyboardsUpdated(); |
325 } | 367 } |
326 | 368 |
327 void EventFactoryEvdev::NotifyTouchscreensUpdated() { | 369 void EventFactoryEvdev::NotifyTouchscreensUpdated() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 gesture_property_provider_->GetDeviceIdsByType(type, &ids); | 411 gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
370 #endif | 412 #endif |
371 // In the future we can add other device matching logics here. | 413 // In the future we can add other device matching logics here. |
372 | 414 |
373 if (device_ids) | 415 if (device_ids) |
374 device_ids->assign(ids.begin(), ids.end()); | 416 device_ids->assign(ids.begin(), ids.end()); |
375 return !ids.empty(); | 417 return !ids.empty(); |
376 } | 418 } |
377 | 419 |
378 } // namespace ui | 420 } // namespace ui |
OLD | NEW |