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

Unified Diff: ui/events/ozone/evdev/input_device_factory_evdev.cc

Issue 868043003: [PATCH 8/11] ozone: evdev: Plumb device changes to EventFactoryEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates for events_unittests 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/evdev/input_device_factory_evdev.cc
diff --git a/ui/events/ozone/evdev/input_device_factory_evdev.cc b/ui/events/ozone/evdev/input_device_factory_evdev.cc
index 508e4fb03111aa2b2fa7e602e953d73a13f8b74e..2d2904f5000fe8e6c23e05c8e1542259622abc5e 100644
--- a/ui/events/ozone/evdev/input_device_factory_evdev.cc
+++ b/ui/events/ozone/evdev/input_device_factory_evdev.cc
@@ -13,6 +13,7 @@
#include "base/time/time.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/device_util_linux.h"
+#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
@@ -306,14 +307,6 @@ void InputDeviceFactoryEvdev::EnableInternalKeyboard() {
}
}
-bool InputDeviceFactoryEvdev::HasMouse() {
- return GetDeviceIdsByType(DT_MOUSE, NULL);
-}
-
-bool InputDeviceFactoryEvdev::HasTouchpad() {
- return GetDeviceIdsByType(DT_TOUCHPAD, NULL);
-}
-
void InputDeviceFactoryEvdev::SetTouchpadSensitivity(int value) {
SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value);
SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value);
@@ -352,10 +345,15 @@ void InputDeviceFactoryEvdev::NotifyDeviceChange(
if (converter.HasKeyboard())
NotifyKeyboardsUpdated();
+
+ if (converter.HasMouse())
+ NotifyMouseDevicesUpdated();
+
+ if (converter.HasTouchpad())
+ NotifyMouseDevicesUpdated();
}
void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() {
- DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance();
std::vector<TouchscreenDevice> touchscreens;
for (auto it = converters_.begin(); it != converters_.end(); ++it) {
if (it->second->HasTouchscreen()) {
@@ -368,11 +366,10 @@ void InputDeviceFactoryEvdev::NotifyTouchscreensUpdated() {
}
}
- observer->OnTouchscreenDevicesUpdated(touchscreens);
+ dispatcher_->DispatchTouchscreenDevicesUpdated(touchscreens);
}
void InputDeviceFactoryEvdev::NotifyKeyboardsUpdated() {
- DeviceHotplugEventObserver* observer = DeviceDataManager::GetInstance();
std::vector<KeyboardDevice> keyboards;
for (auto it = converters_.begin(); it != converters_.end(); ++it) {
if (it->second->HasKeyboard()) {
@@ -381,24 +378,31 @@ void InputDeviceFactoryEvdev::NotifyKeyboardsUpdated() {
}
}
- observer->OnKeyboardDevicesUpdated(keyboards);
+ dispatcher_->DispatchKeyboardDevicesUpdated(keyboards);
}
-bool InputDeviceFactoryEvdev::GetDeviceIdsByType(const EventDeviceType type,
- std::vector<int>* device_ids) {
- if (device_ids)
- device_ids->clear();
- std::vector<int> ids;
+void InputDeviceFactoryEvdev::NotifyMouseDevicesUpdated() {
+ std::vector<InputDevice> mice;
+ for (auto it = converters_.begin(); it != converters_.end(); ++it) {
+ if (it->second->HasMouse()) {
+ mice.push_back(InputDevice(it->second->id(), it->second->type(),
+ std::string() /* Device name */));
+ }
+ }
-#if defined(USE_EVDEV_GESTURES)
- // Ask GesturePropertyProvider for matching devices.
- gesture_property_provider_->GetDeviceIdsByType(type, &ids);
-#endif
- // In the future we can add other device matching logics here.
+ dispatcher_->DispatchMouseDevicesUpdated(mice);
+}
+
+void InputDeviceFactoryEvdev::NotifyTouchpadDevicesUpdated() {
+ std::vector<InputDevice> touchpads;
+ for (auto it = converters_.begin(); it != converters_.end(); ++it) {
+ if (it->second->HasTouchpad()) {
+ touchpads.push_back(InputDevice(it->second->id(), it->second->type(),
+ std::string() /* Device name */));
+ }
+ }
- if (device_ids)
- device_ids->assign(ids.begin(), ids.end());
- return !ids.empty();
+ dispatcher_->DispatchTouchpadDevicesUpdated(touchpads);
}
void InputDeviceFactoryEvdev::SetIntPropertyForOneType(

Powered by Google App Engine
This is Rietveld 408576698