| OLD | NEW |
| 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 "chromeos/display/touchscreen_delegate_x11.h" | 5 #include "chromeos/display/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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 VLOG(2) << "Arbitrarily matching touchscreen " | 124 VLOG(2) << "Arbitrarily matching touchscreen " |
| 125 << (*outputs)[i].touch_device_id << " to output #" << i; | 125 << (*outputs)[i].touch_device_id << " to output #" << i; |
| 126 break; | 126 break; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 XIFreeDeviceInfo(info); | 131 XIFreeDeviceInfo(info); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void TouchscreenDelegateX11::ConfigureCTM( | |
| 135 int touch_device_id, | |
| 136 const OutputConfigurator::CoordinateTransformation& ctm) { | |
| 137 VLOG(1) << "ConfigureCTM: id=" << touch_device_id | |
| 138 << " scale=" << ctm.x_scale << "x" << ctm.y_scale | |
| 139 << " offset=(" << ctm.x_offset << ", " << ctm.y_offset << ")"; | |
| 140 int ndevices = 0; | |
| 141 XIDeviceInfo* info = XIQueryDevice(display_, touch_device_id, &ndevices); | |
| 142 Atom prop = XInternAtom(display_, "Coordinate Transformation Matrix", False); | |
| 143 Atom float_atom = XInternAtom(display_, "FLOAT", False); | |
| 144 if (ndevices == 1 && prop != None && float_atom != None) { | |
| 145 Atom type; | |
| 146 int format; | |
| 147 unsigned long num_items; | |
| 148 unsigned long bytes_after; | |
| 149 unsigned char* data = NULL; | |
| 150 // Verify that the property exists with correct format, type, etc. | |
| 151 int status = XIGetProperty(display_, info->deviceid, prop, 0, 0, False, | |
| 152 AnyPropertyType, &type, &format, &num_items, &bytes_after, &data); | |
| 153 if (data) | |
| 154 XFree(data); | |
| 155 if (status == Success && type == float_atom && format == 32) { | |
| 156 float value[3][3] = { | |
| 157 { ctm.x_scale, 0.0, ctm.x_offset }, | |
| 158 { 0.0, ctm.y_scale, ctm.y_offset }, | |
| 159 { 0.0, 0.0, 1.0 } | |
| 160 }; | |
| 161 XIChangeProperty(display_, | |
| 162 info->deviceid, | |
| 163 prop, | |
| 164 type, | |
| 165 format, | |
| 166 PropModeReplace, | |
| 167 reinterpret_cast<unsigned char*>(value), | |
| 168 9); | |
| 169 } | |
| 170 } | |
| 171 XIFreeDeviceInfo(info); | |
| 172 } | |
| 173 | |
| 174 } // namespace chromeos | 134 } // namespace chromeos |
| OLD | NEW |