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

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

Issue 63443002: Revert 233414 "x11: Move XInput2 availability information out of..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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/cursorfont.h> 7 #include <X11/cursorfont.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/extensions/XIproto.h> 10 #include <X11/extensions/XIproto.h>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "ui/events/event_switches.h" 20 #include "ui/events/event_switches.h"
21 #include "ui/events/x/device_data_manager.h"
22 #include "ui/events/x/device_list_cache_x.h" 21 #include "ui/events/x/device_list_cache_x.h"
23 #include "ui/gfx/x/x11_types.h" 22 #include "ui/gfx/x/x11_types.h"
24 23
25 namespace ui { 24 namespace ui {
26 25
27 TouchFactory::TouchFactory() 26 TouchFactory::TouchFactory()
28 : pointer_device_lookup_(), 27 : pointer_device_lookup_(),
29 touch_device_available_(false), 28 touch_device_available_(false),
30 touch_events_disabled_(false), 29 touch_events_disabled_(false),
31 touch_device_list_(), 30 touch_device_list_(),
32 id_generator_(0) { 31 id_generator_(0) {
33 if (!DeviceDataManager::GetInstance()->IsXInput2Available()) 32 #if defined(USE_AURA)
33 if (!base::MessagePumpForUI::HasXInput2())
34 return; 34 return;
35 #endif
35 36
36 XDisplay* display = gfx::GetXDisplay(); 37 XDisplay* display = gfx::GetXDisplay();
37 UpdateDeviceList(display); 38 UpdateDeviceList(display);
38 39
39 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 40 CommandLine* cmdline = CommandLine::ForCurrentProcess();
40 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && 41 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) &&
41 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == 42 cmdline->GetSwitchValueASCII(switches::kTouchEvents) ==
42 switches::kTouchEventsDisabled; 43 switches::kTouchEventsDisabled;
43 } 44 }
44 45
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false); 94 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false);
94 for (int i = 0; i < dev_list.count; i++) { 95 for (int i = 0; i < dev_list.count; i++) {
95 if (dev_list[i].type == xi_touchscreen) { 96 if (dev_list[i].type == xi_touchscreen) {
96 touch_device_lookup_[dev_list[i].id] = true; 97 touch_device_lookup_[dev_list[i].id] = true;
97 touch_device_list_[dev_list[i].id] = false; 98 touch_device_list_[dev_list[i].id] = false;
98 touch_device_available_ = true; 99 touch_device_available_ = true;
99 } 100 }
100 } 101 }
101 #endif 102 #endif
102 103
103 if (!DeviceDataManager::GetInstance()->IsXInput2Available())
104 return;
105
106 // Instead of asking X for the list of devices all the time, let's maintain a 104 // Instead of asking X for the list of devices all the time, let's maintain a
107 // list of pointer devices we care about. 105 // list of pointer devices we care about.
108 // It should not be necessary to select for slave devices. XInput2 provides 106 // It should not be necessary to select for slave devices. XInput2 provides
109 // enough information to the event callback to decide which slave device 107 // enough information to the event callback to decide which slave device
110 // triggered the event, thus decide whether the 'pointer event' is a 108 // triggered the event, thus decide whether the 'pointer event' is a
111 // 'mouse event' or a 'touch event'. 109 // 'mouse event' or a 'touch event'.
112 // However, on some desktops, some events from a master pointer are 110 // However, on some desktops, some events from a master pointer are
113 // not delivered to the client. So we select for slave devices instead. 111 // not delivered to the client. So we select for slave devices instead.
114 // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which 112 // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which
115 // is possible), then the device is detected as a floating device, and a 113 // is possible), then the device is detected as a floating device, and a
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 iter != devices.end(); ++iter) { 243 iter != devices.end(); ++iter) {
246 DCHECK(*iter < touch_device_lookup_.size()); 244 DCHECK(*iter < touch_device_lookup_.size());
247 touch_device_lookup_[*iter] = true; 245 touch_device_lookup_[*iter] = true;
248 touch_device_list_[*iter] = true; 246 touch_device_list_[*iter] = true;
249 } 247 }
250 touch_device_available_ = true; 248 touch_device_available_ = true;
251 touch_events_disabled_ = false; 249 touch_events_disabled_ = false;
252 } 250 }
253 251
254 } // namespace ui 252 } // namespace ui
OLDNEW
« no previous file with comments | « trunk/src/ui/events/x/device_list_cache_x.cc ('k') | trunk/src/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698