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

Side by Side Diff: ui/base/touch/multi_touch_device_x11.cc

Issue 9773024: This patch implements Chromium's Aura gesture recognizer in terms of utouch-grail and utouch-frame … (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 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 | « ui/base/touch/multi_touch_device_x11.h ('k') | ui/base/touch/touch_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <X11/extensions/XInput.h>
6 #include <X11/extensions/XInput2.h>
7 #include <X11/extensions/XIproto.h>
8
9 #include <xorg/xserver-properties.h>
10
11 #include "ui/base/touch/multi_touch_device.h"
12 #include "ui/base/touch/multi_touch_device_x11.h"
13 #include "ui/base/x/x11_util.h"
14
15 namespace {
16
17 const char * AxisNameForType(ui::Axis::Type type) {
18 // Defines are taken from xorg/xserver-properties.h
19 static const char* names[ui::Axis::AXIS_TYPE_LAST+1] = {
20 AXIS_LABEL_PROP_ABS_MT_POSITION_X,
21 AXIS_LABEL_PROP_ABS_MT_POSITION_Y,
22 AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR,
23 AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR,
24 AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR,
25 AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR,
26 AXIS_LABEL_PROP_ABS_MT_ORIENTATION,
27 AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE,
28 AXIS_LABEL_PROP_ABS_MT_BLOB_ID,
29 AXIS_LABEL_PROP_ABS_MT_TRACKING_ID,
30 AXIS_LABEL_PROP_ABS_MT_PRESSURE,
31 AXIS_LABEL_PROP_ABS_MISC,
32 "Unknown axis type",
33 "ui::Axis::AXIS_TYPE_LAST"
34 };
35
36 return names[type];
37 }
38
39 ui::Axis::Type AxisTypeForLabel(Display* display, Atom label) {
40 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR,
41 True))
42 return ui::Axis::AXIS_TYPE_TOUCH_MAJOR;
43 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR,
44 True))
45 return ui::Axis::AXIS_TYPE_TOUCH_MINOR;
46 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR,
47 True))
48 return ui::Axis::AXIS_TYPE_WIDTH_MAJOR;
49 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR,
50 True))
51 return ui::Axis::AXIS_TYPE_WIDTH_MINOR;
52 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_ORIENTATION,
53 True))
54 return ui::Axis::AXIS_TYPE_ORIENTATION;
55 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE,
56 True))
57 return ui::Axis::AXIS_TYPE_TOOL;
58 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_BLOB_ID,
59 True))
60 return ui::Axis::AXIS_TYPE_BLOB_ID;
61 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID,
62 True))
63 return ui::Axis::AXIS_TYPE_TRACKING_ID;
64 if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_PRESSURE,
65 True))
66 return ui::Axis::AXIS_TYPE_PRESSURE;
67
68 return ui::Axis::AXIS_TYPE_UNKNOWN;
69 }
70
71 } // namespace
72
73 namespace ui {
74
75 bool xi_device_info_to_mt_device(XIDeviceInfo * info,
76 MultiTouchDevice & out) {
77 if (info == NULL)
78 return false;
79
80 out.set_id(info->deviceid);
81 out.set_name(info->name);
82 MultiTouchDevice::Axes axes;
83
84 for (int i = 0; i < info->num_classes; ++i) {
85 switch (info->classes[i]->type) {
86 case XITouchClass: {
87 XITouchClassInfo* touch_info =
88 reinterpret_cast<XITouchClassInfo*>(info->classes[i]);
89
90 switch (touch_info->mode) {
91 case XIDirectTouch:
92 out.set_type(MultiTouchDevice::DIRECT_TOUCH_DEVICE_TYPE);
93 break;
94 case XIDependentTouch:
95 out.set_type(MultiTouchDevice::DEPENDENT_TOUCH_DEVICE_TYPE);
96 break;
97 }
98
99 out.set_max_num_touches(touch_info->num_touches);
100 break;
101 }
102
103 case XIValuatorClass: {
104 XIValuatorClassInfo* valuator_info =
105 reinterpret_cast<XIValuatorClassInfo*>(info->classes[i]);
106
107 Axis::Type type;
108
109 /* X and Y axes are always 0 and 1 in X11. Due to historical reasons,
110 * the labels of these axes may not be consistent across input modules.
111 * Hard code them here instead. */
112 if (valuator_info->number == 0) {
113 type = Axis::AXIS_TYPE_X;
114 } else if (valuator_info->number == 1) {
115 type = Axis::AXIS_TYPE_Y;
116 } else {
117 type = AxisTypeForLabel(ui::GetXDisplay(), valuator_info->label);
118 }
119
120 if (type == Axis::AXIS_TYPE_UNKNOWN)
121 continue;
122
123 Axis axis;
124 axis.set_name(AxisNameForType(type));
125 axis.set_type(type);
126 axis.set_min(valuator_info->min);
127 axis.set_max(valuator_info->max);
128 axis.set_resolution(valuator_info->resolution);
129
130 axes[type] = axis;
131
132 break;
133 }
134
135 default:
136 break;
137 }
138 }
139
140 out.set_axes(axes);
141
142 out.set_window_resolution_x(0.f);
143 out.set_window_resolution_y(0.f);
144
145 return out.type() != ui::MultiTouchDevice::UNKNOWN_TOUCH_DEVICE_TYPE;
146 }
147
148 } // namespace ui
149
OLDNEW
« no previous file with comments | « ui/base/touch/multi_touch_device_x11.h ('k') | ui/base/touch/touch_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698