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

Unified Diff: ui/events/x/device_data_manager_x11.cc

Issue 336863002: Moving input device hotplug event processing outside of ui/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« ui/events/device_data_manager.h ('K') | « ui/events/x/device_data_manager_x11.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/device_data_manager_x11.cc
diff --git a/ui/events/x/device_data_manager_x11.cc b/ui/events/x/device_data_manager_x11.cc
index 97ffe3036f04eb5b757b5c8ac5338c41f58d91d9..6c26d90de83d11ee7ad5edd6e79cc5301dc0114f 100644
--- a/ui/events/x/device_data_manager_x11.cc
+++ b/ui/events/x/device_data_manager_x11.cc
@@ -13,6 +13,7 @@
#include "base/sys_info.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_switches.h"
+#include "ui/events/input_device_event_observer.h"
#include "ui/events/x/device_list_cache_x.h"
#include "ui/events/x/touch_factory_x11.h"
#include "ui/gfx/display.h"
@@ -263,6 +264,10 @@ void DeviceDataManagerX11::UpdateDeviceList(Display* display) {
if (possible_cmt && !not_cmt)
cmt_devices_[deviceid] = true;
}
+
+ FOR_EACH_OBSERVER(InputDeviceEventObserver,
+ observers_,
+ OnInputDeviceConfigurationChanged());
}
bool DeviceDataManagerX11::GetSlotNumber(const XIDeviceEvent* xiev, int* slot) {
@@ -659,4 +664,64 @@ bool DeviceDataManagerX11::TouchEventNeedsCalibrate(int touch_device_id) const {
return false;
}
+std::vector<TouchscreenDevice> DeviceDataManagerX11::GetTouchscreenDevices() {
+ std::vector<TouchscreenDevice> devices;
+ Display* display = gfx::GetXDisplay();
+
+ Atom valuator_x = XInternAtom(display, "Abs MT Position X", False);
+ Atom valuator_y = XInternAtom(display, "Abs MT Position Y", False);
+ if (valuator_x == None || valuator_y == None)
+ return devices;
+
+ XIDeviceList native_devices =
+ DeviceListCacheX::GetInstance()->GetXI2DeviceList(display);
+ for (int i = 0; i < native_devices.count; ++i) {
+ if (!native_devices[i].enabled || native_devices[i].use != XIFloatingSlave)
+ continue; // Assume all touchscreens are floating slaves
+
+ double width = -1.0;
+ double height = -1.0;
+ bool is_direct_touch = false;
+
+ for (int j = 0; j < native_devices[i].num_classes; j++) {
+ XIAnyClassInfo* class_info = native_devices[i].classes[j];
+
+ if (class_info->type == XIValuatorClass) {
+ XIValuatorClassInfo* valuator_info =
+ reinterpret_cast<XIValuatorClassInfo*>(class_info);
+
+ if (valuator_x == valuator_info->label) {
+ // Ignore X axis valuator with unexpected properties
+ if (valuator_info->number == 0 && valuator_info->mode == Absolute &&
+ valuator_info->min == 0.0) {
+ width = valuator_info->max;
+ }
+ } else if (valuator_y == valuator_info->label) {
+ // Ignore Y axis valuator with unexpected properties
+ if (valuator_info->number == 1 && valuator_info->mode == Absolute &&
+ valuator_info->min == 0.0) {
+ height = valuator_info->max;
+ }
+ }
+ }
+#if defined(USE_XI2_MT)
+ if (class_info->type == XITouchClass) {
+ XITouchClassInfo* touch_info =
+ reinterpret_cast<XITouchClassInfo*>(class_info);
+ is_direct_touch = touch_info->mode == XIDirectTouch;
+ }
+#endif
+ }
+
+ // Touchscreens should have absolute X and Y axes, and be direct touch
+ // devices.
+ if (width > 0.0 && height > 0.0 && is_direct_touch) {
+ devices.push_back(TouchscreenDevice(native_devices[i].deviceid,
+ gfx::Size(width, height)));
+ }
+ }
+
+ return devices;
+}
+
} // namespace ui
« ui/events/device_data_manager.h ('K') | « ui/events/x/device_data_manager_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698