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

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

Issue 1047733003: Make the Mouse integration work in Virtualbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove comment and change CL description Created 5 years, 8 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 | 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/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); 76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids);
77 } 77 }
78 } 78 }
79 79
80 void TouchFactory::UpdateDeviceList(Display* display) { 80 void TouchFactory::UpdateDeviceList(Display* display) {
81 // Detect touch devices. 81 // Detect touch devices.
82 touch_device_lookup_.reset(); 82 touch_device_lookup_.reset();
83 touch_device_list_.clear(); 83 touch_device_list_.clear();
84 touchscreen_ids_.clear(); 84 touchscreen_ids_.clear();
85 85
86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does
87 // not provide enough information to detect a touch device. As a result, the
88 // old version of query function (XListInputDevices) is used instead.
89 // If XInput2 is not supported, this will return null (with count of -1) so
90 // we assume there cannot be any touch devices.
91 // With XI2.1 or older, we allow only single touch devices.
92 const XDeviceList& dev_list =
93 DeviceListCacheX11::GetInstance()->GetXDeviceList(display);
94 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false);
95 for (int i = 0; i < dev_list.count; i++) {
96 if (dev_list[i].type == xi_touchscreen) {
97 touch_device_lookup_[dev_list[i].id] = true;
98 touch_device_list_[dev_list[i].id] = false;
99 }
100 }
101
102 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) 86 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available())
103 return; 87 return;
104 88
105 // Instead of asking X for the list of devices all the time, let's maintain a 89 // Instead of asking X for the list of devices all the time, let's maintain a
106 // list of pointer devices we care about. 90 // list of pointer devices we care about.
107 // It should not be necessary to select for slave devices. XInput2 provides 91 // It should not be necessary to select for slave devices. XInput2 provides
108 // enough information to the event callback to decide which slave device 92 // enough information to the event callback to decide which slave device
109 // triggered the event, thus decide whether the 'pointer event' is a 93 // triggered the event, thus decide whether the 'pointer event' is a
110 // 'mouse event' or a 'touch event'. 94 // 'mouse event' or a 'touch event'.
111 // However, on some desktops, some events from a master pointer are 95 // However, on some desktops, some events from a master pointer are
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (ptr[0] || ptr[1]) 323 if (ptr[0] || ptr[1])
340 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 324 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
341 } 325 }
342 XFree(prop_return); 326 XFree(prop_return);
343 } 327 }
344 328
345 XCloseDevice(display, device); 329 XCloseDevice(display, device);
346 } 330 }
347 331
348 } // namespace ui 332 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698