| 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 "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> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/message_loop/message_pump_x11.h" | 13 #include "base/message_loop/message_pump_x11.h" |
| 14 #include "ui/display/chromeos/display_mode.h" | 14 #include "ui/display/chromeos/display_mode.h" |
| 15 #include "ui/display/chromeos/display_snapshot.h" | 15 #include "ui/display/chromeos/display_snapshot.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 TouchscreenDelegateX11::TouchscreenDelegateX11() | 19 TouchscreenDelegateX11::TouchscreenDelegateX11() |
| 20 : display_(base::MessagePumpX11::GetDefaultXDisplay()) {} | 20 : display_(base::MessagePumpX11::GetDefaultXDisplay()) {} |
| 21 | 21 |
| 22 TouchscreenDelegateX11::~TouchscreenDelegateX11() {} | 22 TouchscreenDelegateX11::~TouchscreenDelegateX11() {} |
| 23 | 23 |
| 24 void TouchscreenDelegateX11::AssociateTouchscreens( | 24 void TouchscreenDelegateX11::AssociateTouchscreens( |
| 25 OutputConfigurator::DisplayStateList* outputs) { | 25 DisplayConfigurator::DisplayStateList* outputs) { |
| 26 int ndevices = 0; | 26 int ndevices = 0; |
| 27 Atom valuator_x = XInternAtom(display_, "Abs MT Position X", False); | 27 Atom valuator_x = XInternAtom(display_, "Abs MT Position X", False); |
| 28 Atom valuator_y = XInternAtom(display_, "Abs MT Position Y", False); | 28 Atom valuator_y = XInternAtom(display_, "Abs MT Position Y", False); |
| 29 if (valuator_x == None || valuator_y == None) | 29 if (valuator_x == None || valuator_y == None) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 std::set<int> no_match_touchscreen; | 32 std::set<int> no_match_touchscreen; |
| 33 XIDeviceInfo* info = XIQueryDevice(display_, XIAllDevices, &ndevices); | 33 XIDeviceInfo* info = XIQueryDevice(display_, XIAllDevices, &ndevices); |
| 34 for (int i = 0; i < ndevices; i++) { | 34 for (int i = 0; i < ndevices; i++) { |
| 35 if (!info[i].enabled || info[i].use != XIFloatingSlave) | 35 if (!info[i].enabled || info[i].use != XIFloatingSlave) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 is_direct_touch = touch_info->mode == XIDirectTouch; | 67 is_direct_touch = touch_info->mode == XIDirectTouch; |
| 68 } | 68 } |
| 69 #endif | 69 #endif |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Touchscreens should have absolute X and Y axes, | 72 // Touchscreens should have absolute X and Y axes, |
| 73 // and be direct touch devices. | 73 // and be direct touch devices. |
| 74 if (width > 0.0 && height > 0.0 && is_direct_touch) { | 74 if (width > 0.0 && height > 0.0 && is_direct_touch) { |
| 75 size_t k = 0; | 75 size_t k = 0; |
| 76 for (; k < outputs->size(); k++) { | 76 for (; k < outputs->size(); k++) { |
| 77 OutputConfigurator::DisplayState* output = &(*outputs)[k]; | 77 DisplayConfigurator::DisplayState* output = &(*outputs)[k]; |
| 78 if (output->touch_device_id != None) | 78 if (output->touch_device_id != None) |
| 79 continue; | 79 continue; |
| 80 | 80 |
| 81 const DisplayMode* mode_info = output->display->native_mode(); | 81 const DisplayMode* mode_info = output->display->native_mode(); |
| 82 if (!mode_info) | 82 if (!mode_info) |
| 83 continue; | 83 continue; |
| 84 | 84 |
| 85 // Allow 1 pixel difference between screen and touchscreen | 85 // Allow 1 pixel difference between screen and touchscreen |
| 86 // resolutions. Because in some cases for monitor resolution | 86 // resolutions. Because in some cases for monitor resolution |
| 87 // 1024x768 touchscreen's resolution would be 1024x768, but for | 87 // 1024x768 touchscreen's resolution would be 1024x768, but for |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 132 void TouchscreenDelegateX11::ConfigureCTM( |
| 133 int touch_device_id, | 133 int touch_device_id, |
| 134 const OutputConfigurator::CoordinateTransformation& ctm) { | 134 const DisplayConfigurator::CoordinateTransformation& ctm) { |
| 135 VLOG(1) << "ConfigureCTM: id=" << touch_device_id << " scale=" << ctm.x_scale | 135 VLOG(1) << "ConfigureCTM: id=" << touch_device_id << " scale=" << ctm.x_scale |
| 136 << "x" << ctm.y_scale << " offset=(" << ctm.x_offset << ", " | 136 << "x" << ctm.y_scale << " offset=(" << ctm.x_offset << ", " |
| 137 << ctm.y_offset << ")"; | 137 << ctm.y_offset << ")"; |
| 138 int ndevices = 0; | 138 int ndevices = 0; |
| 139 XIDeviceInfo* info = XIQueryDevice(display_, touch_device_id, &ndevices); | 139 XIDeviceInfo* info = XIQueryDevice(display_, touch_device_id, &ndevices); |
| 140 Atom prop = XInternAtom(display_, "Coordinate Transformation Matrix", False); | 140 Atom prop = XInternAtom(display_, "Coordinate Transformation Matrix", False); |
| 141 Atom float_atom = XInternAtom(display_, "FLOAT", False); | 141 Atom float_atom = XInternAtom(display_, "FLOAT", False); |
| 142 if (ndevices == 1 && prop != None && float_atom != None) { | 142 if (ndevices == 1 && prop != None && float_atom != None) { |
| 143 Atom type; | 143 Atom type; |
| 144 int format; | 144 int format; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 173 format, | 173 format, |
| 174 PropModeReplace, | 174 PropModeReplace, |
| 175 reinterpret_cast<unsigned char*>(value), | 175 reinterpret_cast<unsigned char*>(value), |
| 176 9); | 176 9); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 XIFreeDeviceInfo(info); | 179 XIFreeDeviceInfo(info); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace ui | 182 } // namespace ui |
| OLD | NEW |