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

Side by Side Diff: ui/events/devices/x11/touch_factory_x11.cc

Issue 968343002: Make the native select menu work on Linux touch screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/x11_pointer_grab.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/devices/x11/touch_factory_x11.h" 5 #include "ui/events/devices/x11/touch_factory_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { 155 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
156 DCHECK_EQ(GenericEvent, xev->type); 156 DCHECK_EQ(GenericEvent, xev->type);
157 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 157 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
158 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 158 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
159 159
160 if (event->evtype == XI_TouchBegin || 160 if (event->evtype == XI_TouchBegin ||
161 event->evtype == XI_TouchUpdate || 161 event->evtype == XI_TouchUpdate ||
162 event->evtype == XI_TouchEnd) { 162 event->evtype == XI_TouchEnd) {
163 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); 163 // Since SetupXI2ForXWindow() selects events from all devices, for a
164 // touchscreen attached to a master pointer device, X11 sends two
165 // events for each touch: one from the slave (deviceid == the id of
166 // the touchscreen device), and one from the master (deviceid == the
167 // id of the master pointer device). Instead of processing both
168 // events, discard the event that comes from the slave, and only
169 // allow processing the event coming from the master.
170 // For a 'floating' touchscreen device, X11 sends only one event for
171 // each touch, with both deviceid and sourceid set to the id of the
172 // touchscreen device.
173 bool is_from_master_or_float = touch_device_list_[xiev->deviceid];
174 bool is_from_slave_device = !is_from_master_or_float
175 && xiev->sourceid == xiev->deviceid;
176 return !touch_events_disabled_ &&
177 IsTouchDevice(xiev->deviceid) &&
178 !is_from_slave_device;
164 } 179 }
165 180
166 // Make sure only key-events from the virtual core keyboard are processed. 181 // Make sure only key-events from the virtual core keyboard are processed.
167 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) { 182 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) {
168 return (virtual_core_keyboard_device_ < 0) || 183 return (virtual_core_keyboard_device_ < 0) ||
169 (virtual_core_keyboard_device_ == xiev->deviceid); 184 (virtual_core_keyboard_device_ == xiev->deviceid);
170 } 185 }
171 186
172 if (event->evtype != XI_ButtonPress && 187 if (event->evtype != XI_ButtonPress &&
173 event->evtype != XI_ButtonRelease && 188 event->evtype != XI_ButtonRelease &&
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (ptr[0] || ptr[1]) 339 if (ptr[0] || ptr[1])
325 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 340 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
326 } 341 }
327 XFree(prop_return); 342 XFree(prop_return);
328 } 343 }
329 344
330 XCloseDevice(display, device); 345 XCloseDevice(display, device);
331 } 346 }
332 347
333 } // namespace ui 348 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/x11_pointer_grab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698