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

Side by Side Diff: ui/events/x/touch_factory_x11.cc

Issue 538143002: Fix test for master device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Identify virtual core keyboard. Created 6 years, 3 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 | « ui/events/x/touch_factory_x11.h ('k') | no next file » | 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/x/touch_factory_x11.h" 5 #include "ui/events/x/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 14 matching lines...) Expand all
25 #include "ui/gfx/x/x11_types.h" 25 #include "ui/gfx/x/x11_types.h"
26 26
27 namespace ui { 27 namespace ui {
28 28
29 TouchFactory::TouchFactory() 29 TouchFactory::TouchFactory()
30 : pointer_device_lookup_(), 30 : pointer_device_lookup_(),
31 touch_device_available_(false), 31 touch_device_available_(false),
32 touch_events_disabled_(false), 32 touch_events_disabled_(false),
33 touch_device_list_(), 33 touch_device_list_(),
34 max_touch_points_(-1), 34 max_touch_points_(-1),
35 virtual_core_keyboard_device_(-1),
35 id_generator_(0) { 36 id_generator_(0) {
36 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) 37 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available())
37 return; 38 return;
38 39
39 XDisplay* display = gfx::GetXDisplay(); 40 XDisplay* display = gfx::GetXDisplay();
40 UpdateDeviceList(display); 41 UpdateDeviceList(display);
41 42
42 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 43 CommandLine* cmdline = CommandLine::ForCurrentProcess();
43 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && 44 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) &&
44 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == 45 cmdline->GetSwitchValueASCII(switches::kTouchEvents) ==
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 touch_device_lookup_[devinfo->deviceid] = true; 138 touch_device_lookup_[devinfo->deviceid] = true;
138 touch_device_list_[devinfo->deviceid] = true; 139 touch_device_list_[devinfo->deviceid] = true;
139 touch_device_available_ = true; 140 touch_device_available_ = true;
140 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_) 141 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_)
141 max_touch_points_ = tci->num_touches; 142 max_touch_points_ = tci->num_touches;
142 } 143 }
143 } 144 }
144 } 145 }
145 #endif 146 #endif
146 pointer_device_lookup_[devinfo->deviceid] = true; 147 pointer_device_lookup_[devinfo->deviceid] = true;
148 } else if (devinfo->use == XIMasterKeyboard) {
149 virtual_core_keyboard_device_ = devinfo->deviceid;
147 } 150 }
148 151
149 #if defined(USE_XI2_MT) 152 #if defined(USE_XI2_MT)
150 if (devinfo->use == XIFloatingSlave || devinfo->use == XISlavePointer) { 153 if (devinfo->use == XIFloatingSlave || devinfo->use == XISlavePointer) {
151 for (int k = 0; k < devinfo->num_classes; ++k) { 154 for (int k = 0; k < devinfo->num_classes; ++k) {
152 XIAnyClassInfo* xiclassinfo = devinfo->classes[k]; 155 XIAnyClassInfo* xiclassinfo = devinfo->classes[k];
153 if (xiclassinfo->type == XITouchClass) { 156 if (xiclassinfo->type == XITouchClass) {
154 XITouchClassInfo* tci = 157 XITouchClassInfo* tci =
155 reinterpret_cast<XITouchClassInfo*>(xiclassinfo); 158 reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
156 // Only care direct touch device (such as touch screen) right now 159 // Only care direct touch device (such as touch screen) right now
(...skipping 11 matching lines...) Expand all
168 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 171 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
169 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 172 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
170 173
171 #if defined(USE_XI2_MT) 174 #if defined(USE_XI2_MT)
172 if (event->evtype == XI_TouchBegin || 175 if (event->evtype == XI_TouchBegin ||
173 event->evtype == XI_TouchUpdate || 176 event->evtype == XI_TouchUpdate ||
174 event->evtype == XI_TouchEnd) { 177 event->evtype == XI_TouchEnd) {
175 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); 178 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid);
176 } 179 }
177 #endif 180 #endif
178 // Make sure only key-events from the master device are processed. 181 // Make sure only key-events from the virtual core keyboard are processed.
179 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) 182 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) {
180 return xiev->deviceid == xiev->sourceid; 183 return (virtual_core_keyboard_device_ < 0) ||
184 (virtual_core_keyboard_device_ == xiev->deviceid);
185 }
181 186
182 if (event->evtype != XI_ButtonPress && 187 if (event->evtype != XI_ButtonPress &&
183 event->evtype != XI_ButtonRelease && 188 event->evtype != XI_ButtonRelease &&
184 event->evtype != XI_Motion) 189 event->evtype != XI_Motion)
185 return true; 190 return true;
186 191
187 if (!pointer_device_lookup_[xiev->deviceid]) 192 if (!pointer_device_lookup_[xiev->deviceid])
188 return false; 193 return false;
189 194
190 return IsTouchDevice(xiev->deviceid) ? !touch_events_disabled_ : true; 195 return IsTouchDevice(xiev->deviceid) ? !touch_events_disabled_ : true;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (ptr[0] || ptr[1]) 352 if (ptr[0] || ptr[1])
348 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 353 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
349 } 354 }
350 XFree(prop_return); 355 XFree(prop_return);
351 } 356 }
352 357
353 XCloseDevice(display, device); 358 XCloseDevice(display, device);
354 } 359 }
355 360
356 } // namespace ui 361 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/touch_factory_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698