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

Unified Diff: base/message_pump_glib_x.cc

Issue 6736029: Tweak XInput2 event subscription (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove unnecessary braces Created 9 years, 9 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
« no previous file with comments | « base/message_pump_glib_x.h ('k') | views/touchui/touch_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_glib_x.cc
diff --git a/base/message_pump_glib_x.cc b/base/message_pump_glib_x.cc
index 35cfc1a533e158cd71b31f57b5501b88feac7c64..34313e5a6bb098d63f18930ac4a3ecfa9548bb08 100644
--- a/base/message_pump_glib_x.cc
+++ b/base/message_pump_glib_x.cc
@@ -79,8 +79,7 @@ namespace base {
MessagePumpGlibX::MessagePumpGlibX() : base::MessagePumpForUI(),
#if defined(HAVE_XINPUT2)
xiopcode_(-1),
- masters_(),
- floats_(),
+ pointer_devices_(),
#endif
gdksource_(NULL),
dispatching_event_(false),
@@ -112,29 +111,17 @@ void MessagePumpGlibX::SetupXInput2ForXWindow(Window xwindow) {
XISetMask(mask, XI_ButtonRelease);
XISetMask(mask, XI_Motion);
- // It is not necessary to select for slave devices. XInput2 provides enough
- // information to the event callback to decide which slave device triggered
- // the event, thus decide whether the 'pointer event' is a 'mouse event' or a
- // 'touch event'.
- // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which
- // is possible), then the device is detected as a floating device, and a
- // floating device is not connected to a master device. So it is necessary to
- // also select on the floating devices.
- std::set<int> devices;
- std::set_union(masters_.begin(), masters_.end(),
- floats_.begin(), floats_.end(),
- std::inserter(devices, devices.begin()));
- XIEventMask evmasks[devices.size()];
+ XIEventMask evmasks[pointer_devices_.size()];
int count = 0;
- for (std::set<int>::const_iterator iter = devices.begin();
- iter != devices.end();
+ for (std::set<int>::const_iterator iter = pointer_devices_.begin();
+ iter != pointer_devices_.end();
++iter, ++count) {
evmasks[count].deviceid = *iter;
evmasks[count].mask_len = sizeof(mask);
evmasks[count].mask = mask;
}
- XISelectEvents(xdisplay, xwindow, evmasks, devices.size());
+ XISelectEvents(xdisplay, xwindow, evmasks, pointer_devices_.size());
// TODO(sad): Setup masks for keyboard events.
@@ -297,16 +284,21 @@ void MessagePumpGlibX::InitializeXInput2(void) {
SetupGtkWidgetRealizeNotifier(this);
// Instead of asking X for the list of devices all the time, let's maintain a
- // list of slave (physical) and master (virtual) pointer devices.
+ // list of pointer devices we care about.
+ // It is not necessary to select for slave devices. XInput2 provides enough
+ // information to the event callback to decide which slave device triggered
+ // the event, thus decide whether the 'pointer event' is a 'mouse event' or a
+ // 'touch event'.
+ // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which
+ // is possible), then the device is detected as a floating device, and a
+ // floating device is not connected to a master device. So it is necessary to
+ // also select on the floating devices.
int count = 0;
XIDeviceInfo* devices = XIQueryDevice(xdisplay, XIAllDevices, &count);
for (int i = 0; i < count; i++) {
XIDeviceInfo* devinfo = devices + i;
- if (devinfo->use == XIFloatingSlave) {
- floats_.insert(devinfo->deviceid);
- } else if (devinfo->use == XIMasterPointer) {
- masters_.insert(devinfo->deviceid);
- }
+ if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer)
+ pointer_devices_.insert(devinfo->deviceid);
}
XIFreeDeviceInfo(devices);
« no previous file with comments | « base/message_pump_glib_x.h ('k') | views/touchui/touch_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698