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

Side by Side Diff: ui/display/chromeos/x11/touchscreen_delegate_x11.cc

Issue 191223007: Move touch CTM from X into Chrome (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move the logic of if a touch event should be dispatched to a root window into CanDispatchEvent() Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display/chromeos/x11/touchscreen_delegate_x11.h" 5 #include "ui/display/chromeos/x11/touchscreen_delegate_x11.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 VLOG(2) << "Arbitrarily matching touchscreen " 122 VLOG(2) << "Arbitrarily matching touchscreen "
123 << (*outputs)[i].touch_device_id << " to output #" << i; 123 << (*outputs)[i].touch_device_id << " to output #" << i;
124 break; 124 break;
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 XIFreeDeviceInfo(info); 129 XIFreeDeviceInfo(info);
130 } 130 }
131 131
132 void TouchscreenDelegateX11::ConfigureCTM(
133 int touch_device_id,
134 const DisplayConfigurator::CoordinateTransformation& ctm) {
135 VLOG(1) << "ConfigureCTM: id=" << touch_device_id << " scale=" << ctm.x_scale
136 << "x" << ctm.y_scale << " offset=(" << ctm.x_offset << ", "
137 << ctm.y_offset << ")";
138 int ndevices = 0;
139 XIDeviceInfo* info = XIQueryDevice(display_, touch_device_id, &ndevices);
140 Atom prop = XInternAtom(display_, "Coordinate Transformation Matrix", False);
141 Atom float_atom = XInternAtom(display_, "FLOAT", False);
142 if (ndevices == 1 && prop != None && float_atom != None) {
143 Atom type;
144 int format;
145 unsigned long num_items;
146 unsigned long bytes_after;
147 unsigned char* data = NULL;
148 // Verify that the property exists with correct format, type, etc.
149 int status = XIGetProperty(display_,
150 info->deviceid,
151 prop,
152 0,
153 0,
154 False,
155 AnyPropertyType,
156 &type,
157 &format,
158 &num_items,
159 &bytes_after,
160 &data);
161 if (data)
162 XFree(data);
163 if (status == Success && type == float_atom && format == 32) {
164 float value[3][3] = {
165 { ctm.x_scale, 0.0, ctm.x_offset },
166 { 0.0, ctm.y_scale, ctm.y_offset },
167 { 0.0, 0.0, 1.0 }
168 };
169 XIChangeProperty(display_,
170 info->deviceid,
171 prop,
172 type,
173 format,
174 PropModeReplace,
175 reinterpret_cast<unsigned char*>(value),
176 9);
177 }
178 }
179 XIFreeDeviceInfo(info);
180 }
181
182 } // namespace ui 132 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698