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

Side by Side Diff: views/touchui/touch_factory.cc

Issue 6736029: Tweak XInput2 event subscription (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« base/message_pump_glib_x.cc ('K') | « base/message_pump_glib_x.cc ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/touchui/touch_factory.h" 5 #include "views/touchui/touch_factory.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>
(...skipping 25 matching lines...) Expand all
36 invisible_cursor_ = XCreatePixmapCursor(display, blank, blank, 36 invisible_cursor_ = XCreatePixmapCursor(display, blank, blank,
37 &black, &black, 0, 0); 37 &black, &black, 0, 0);
38 arrow_cursor_ = XCreateFontCursor(display, XC_arrow); 38 arrow_cursor_ = XCreateFontCursor(display, XC_arrow);
39 39
40 SetCursorVisible(false, false); 40 SetCursorVisible(false, false);
41 41
42 // Detect touch devices. 42 // Detect touch devices.
43 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does 43 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does
44 // not provide enough information to detect a touch device. As a result, the 44 // not provide enough information to detect a touch device. As a result, the
45 // old version of query function (XListInputDevices) is used instead. 45 // old version of query function (XListInputDevices) is used instead.
46 // If XInput2 is not supported, this will return null (with count of -1) so
47 // we assume there cannot be any touch devices.
46 int count = 0; 48 int count = 0;
47 XDeviceInfo* devlist = XListInputDevices(display, &count); 49 XDeviceInfo* devlist = XListInputDevices(display, &count);
48 for (int i = 0; i < count; i++) { 50 for (int i = 0; i < count; i++) {
49 const char* devtype = XGetAtomName(display, devlist[i].type); 51 const char* devtype = XGetAtomName(display, devlist[i].type);
50 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { 52 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) {
51 touch_device_lookup_[devlist[i].id] = true; 53 touch_device_lookup_[devlist[i].id] = true;
52 touch_device_list_.push_back(devlist[i].id); 54 touch_device_list_.push_back(devlist[i].id);
53 } 55 }
54 } 56 }
55 XFreeDeviceList(devlist); 57 if (devlist) {
58 XFreeDeviceList(devlist);
59 }
sadrul 2011/03/25 15:49:41 -braces
Rick Byers 2011/03/25 17:25:49 Done.
56 } 60 }
57 61
58 TouchFactory::~TouchFactory() { 62 TouchFactory::~TouchFactory() {
59 SetCursorVisible(true, false); 63 SetCursorVisible(true, false);
60 Display* display = ui::GetXDisplay(); 64 Display* display = ui::GetXDisplay();
61 XFreeCursor(display, invisible_cursor_); 65 XFreeCursor(display, invisible_cursor_);
62 XFreeCursor(display, arrow_cursor_); 66 XFreeCursor(display, arrow_cursor_);
63 } 67 }
64 68
65 void TouchFactory::SetTouchDeviceList( 69 void TouchFactory::SetTouchDeviceList(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 Window window = DefaultRootWindow(display); 140 Window window = DefaultRootWindow(display);
137 141
138 if (is_cursor_visible_) { 142 if (is_cursor_visible_) {
139 XDefineCursor(display, window, arrow_cursor_); 143 XDefineCursor(display, window, arrow_cursor_);
140 } else { 144 } else {
141 XDefineCursor(display, window, invisible_cursor_); 145 XDefineCursor(display, window, invisible_cursor_);
142 } 146 }
143 } 147 }
144 148
145 } // namespace views 149 } // namespace views
OLDNEW
« base/message_pump_glib_x.cc ('K') | « base/message_pump_glib_x.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698