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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 if (cursor_) { | 305 if (cursor_) { |
307 cursor_->MoveCursorTo(widget, location); | 306 cursor_->MoveCursorTo(widget, location); |
308 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, | 307 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, |
309 cursor_->GetLocation(), | 308 cursor_->GetLocation(), |
310 cursor_->GetLocation(), | 309 cursor_->GetLocation(), |
311 modifiers_.GetModifierFlags(), | 310 modifiers_.GetModifierFlags(), |
312 /* changed_button_flags */ 0))); | 311 /* changed_button_flags */ 0))); |
313 } | 312 } |
314 } | 313 } |
315 | 314 |
| 315 void EventFactoryEvdev::DisableInternalTouchpad() { |
| 316 for (const auto& it : converters_) { |
| 317 EventConverterEvdev* converter = it.second; |
| 318 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 319 converter->HasTouchpad()) { |
| 320 converter->set_ignore_events(true); |
| 321 } |
| 322 } |
| 323 } |
| 324 |
| 325 void EventFactoryEvdev::EnableInternalTouchpad() { |
| 326 for (const auto& it : converters_) { |
| 327 EventConverterEvdev* converter = it.second; |
| 328 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 329 converter->HasTouchpad()) { |
| 330 converter->set_ignore_events(false); |
| 331 } |
| 332 } |
| 333 } |
| 334 |
| 335 void EventFactoryEvdev::DisableInternalKeyboardExceptKeys( |
| 336 scoped_ptr<std::set<ui::KeyboardCode>> excepted_keys) { |
| 337 for (const auto& it : converters_) { |
| 338 EventConverterEvdev* converter = it.second; |
| 339 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 340 converter->HasKeyboard()) { |
| 341 converter->SetAllowedKeys(excepted_keys.Pass()); |
| 342 } |
| 343 } |
| 344 } |
| 345 |
| 346 void EventFactoryEvdev::EnableInternalKeyboard() { |
| 347 for (const auto& it : converters_) { |
| 348 EventConverterEvdev* converter = it.second; |
| 349 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 350 converter->HasKeyboard()) { |
| 351 converter->AllowAllKeys(); |
| 352 } |
| 353 } |
| 354 } |
| 355 |
316 void EventFactoryEvdev::NotifyDeviceChange( | 356 void EventFactoryEvdev::NotifyDeviceChange( |
317 const EventConverterEvdev& converter) { | 357 const EventConverterEvdev& converter) { |
318 if (converter.HasTouchscreen()) | 358 if (converter.HasTouchscreen()) |
319 NotifyTouchscreensUpdated(); | 359 NotifyTouchscreensUpdated(); |
320 | 360 |
321 if (converter.HasKeyboard()) | 361 if (converter.HasKeyboard()) |
322 NotifyKeyboardsUpdated(); | 362 NotifyKeyboardsUpdated(); |
323 } | 363 } |
324 | 364 |
325 void EventFactoryEvdev::NotifyTouchscreensUpdated() { | 365 void EventFactoryEvdev::NotifyTouchscreensUpdated() { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 gesture_property_provider_->GetDeviceIdsByType(type, &ids); | 404 gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
365 #endif | 405 #endif |
366 // In the future we can add other device matching logics here. | 406 // In the future we can add other device matching logics here. |
367 | 407 |
368 if (device_ids) | 408 if (device_ids) |
369 device_ids->assign(ids.begin(), ids.end()); | 409 device_ids->assign(ids.begin(), ids.end()); |
370 return !ids.empty(); | 410 return !ids.empty(); |
371 } | 411 } |
372 | 412 |
373 } // namespace ui | 413 } // namespace ui |
OLD | NEW |