Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ui/base/touch/touch_factory.h" | 5 #include "ui/base/touch/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 if (!atom_tp) | 57 if (!atom_tp) |
| 58 return NULL; | 58 return NULL; |
| 59 | 59 |
| 60 for (int i = 0; i < info->num_classes; i++) { | 60 for (int i = 0; i < info->num_classes; i++) { |
| 61 if (info->classes[i]->type != XIValuatorClass) | 61 if (info->classes[i]->type != XIValuatorClass) |
| 62 continue; | 62 continue; |
| 63 XIValuatorClassInfo* v = | 63 XIValuatorClassInfo* v = |
| 64 reinterpret_cast<XIValuatorClassInfo*>(info->classes[i]); | 64 reinterpret_cast<XIValuatorClassInfo*>(info->classes[i]); |
| 65 | 65 |
| 66 if (v->label) { | 66 if (v->label) { |
| 67 const char* atom = XGetAtomName(display, v->label); | 67 char* atom = XGetAtomName(display, v->label); |
|
sky
2012/02/06 17:55:47
How about a scoping object?
sadrul
2012/02/06 19:48:30
Sounds good. Done.
| |
| 68 if (atom && strcmp(atom, atom_tp) == 0) | 68 if (atom && strcmp(atom, atom_tp) == 0) { |
| 69 XFree(atom); | |
| 69 return v; | 70 return v; |
| 71 } | |
| 72 XFree(atom); | |
| 70 } | 73 } |
| 71 } | 74 } |
| 72 | 75 |
| 73 return NULL; | 76 return NULL; |
| 74 } | 77 } |
| 75 | 78 |
| 76 } // namespace | 79 } // namespace |
| 77 | 80 |
| 78 namespace ui { | 81 namespace ui { |
| 79 | 82 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 // If XInput2 is not supported, this will return null (with count of -1) so | 147 // If XInput2 is not supported, this will return null (with count of -1) so |
| 145 // we assume there cannot be any touch devices. | 148 // we assume there cannot be any touch devices. |
| 146 int count = 0; | 149 int count = 0; |
| 147 touch_device_available_ = false; | 150 touch_device_available_ = false; |
| 148 touch_device_lookup_.reset(); | 151 touch_device_lookup_.reset(); |
| 149 touch_device_list_.clear(); | 152 touch_device_list_.clear(); |
| 150 #if !defined(USE_XI2_MT) | 153 #if !defined(USE_XI2_MT) |
| 151 XDeviceInfo* devlist = XListInputDevices(display, &count); | 154 XDeviceInfo* devlist = XListInputDevices(display, &count); |
| 152 for (int i = 0; i < count; i++) { | 155 for (int i = 0; i < count; i++) { |
| 153 if (devlist[i].type) { | 156 if (devlist[i].type) { |
| 154 const char* devtype = XGetAtomName(display, devlist[i].type); | 157 char* devtype = XGetAtomName(display, devlist[i].type); |
| 155 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { | 158 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { |
| 156 touch_device_lookup_[devlist[i].id] = true; | 159 touch_device_lookup_[devlist[i].id] = true; |
| 157 touch_device_list_[devlist[i].id] = true; | 160 touch_device_list_[devlist[i].id] = true; |
| 158 touch_device_available_ = true; | 161 touch_device_available_ = true; |
| 159 } | 162 } |
| 163 XFree(devtype); | |
| 160 } | 164 } |
| 161 } | 165 } |
| 162 if (devlist) | 166 if (devlist) |
| 163 XFreeDeviceList(devlist); | 167 XFreeDeviceList(devlist); |
| 164 #endif | 168 #endif |
| 165 | 169 |
| 166 // Instead of asking X for the list of devices all the time, let's maintain a | 170 // Instead of asking X for the list of devices all the time, let's maintain a |
| 167 // list of pointer devices we care about. | 171 // list of pointer devices we care about. |
| 168 // It should not be necessary to select for slave devices. XInput2 provides | 172 // It should not be necessary to select for slave devices. XInput2 provides |
| 169 // enough information to the event callback to decide which slave device | 173 // enough information to the event callback to decide which slave device |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 float* max) { | 497 float* max) { |
| 494 if (valuator_lookup_[deviceid][tp] >= 0) { | 498 if (valuator_lookup_[deviceid][tp] >= 0) { |
| 495 *min = touch_param_min_[deviceid][tp]; | 499 *min = touch_param_min_[deviceid][tp]; |
| 496 *max = touch_param_max_[deviceid][tp]; | 500 *max = touch_param_max_[deviceid][tp]; |
| 497 return true; | 501 return true; |
| 498 } | 502 } |
| 499 return false; | 503 return false; |
| 500 } | 504 } |
| 501 | 505 |
| 502 } // namespace ui | 506 } // namespace ui |
| OLD | NEW |