Chromium Code Reviews| 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/touchscreen_delegate_impl.h" | 5 #include "ui/display/chromeos/touchscreen_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ui/display/types/chromeos/display_mode.h" | 10 #include "ui/display/types/chromeos/display_mode.h" |
| 11 #include "ui/display/types/chromeos/display_snapshot.h" | 11 #include "ui/display/types/chromeos/display_snapshot.h" |
| 12 #include "ui/display/types/chromeos/touchscreen_device_manager.h" | 12 #include "ui/display/types/chromeos/touchscreen_device_manager.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 TouchscreenDelegateImpl::TouchscreenDelegateImpl( | 16 TouchscreenDelegateImpl::TouchscreenDelegateImpl( |
| 17 scoped_ptr<TouchscreenDeviceManager> touch_device_manager) | 17 scoped_ptr<TouchscreenDeviceManager> touch_device_manager) |
| 18 : touch_device_manager_(touch_device_manager.Pass()) {} | 18 : touch_device_manager_(touch_device_manager.Pass()) {} |
| 19 | 19 |
| 20 TouchscreenDelegateImpl::~TouchscreenDelegateImpl() {} | 20 TouchscreenDelegateImpl::~TouchscreenDelegateImpl() {} |
| 21 | 21 |
| 22 void TouchscreenDelegateImpl::AssociateTouchscreens( | 22 void TouchscreenDelegateImpl::AssociateTouchscreens( |
| 23 std::vector<DisplayConfigurator::DisplayState>* displays) { | 23 std::vector<DisplayConfigurator::DisplayState>* displays) { |
| 24 std::set<int> no_match_touchscreen; | 24 std::set<int> no_match_touchscreen; |
| 25 std::vector<TouchscreenDevice> devices = touch_device_manager_->GetDevices(); | 25 std::vector<TouchscreenDevice> devices = touch_device_manager_->GetDevices(); |
| 26 | |
| 27 int internal_ts = -1; | |
|
Daniel Erat
2014/07/16 02:59:46
s/ts/touchscreen/
Yufeng Shen (Slow to review)
2014/07/16 20:20:27
Done.
| |
| 26 for (size_t i = 0; i < devices.size(); ++i) { | 28 for (size_t i = 0; i < devices.size(); ++i) { |
| 29 if (devices[i].is_internal) { | |
| 30 internal_ts = i; | |
| 31 break; | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 DisplayConfigurator::DisplayState* internal_dpy_state = NULL; | |
|
Daniel Erat
2014/07/16 02:59:46
s/dpy/display/, or just name this |internal_state|
Yufeng Shen (Slow to review)
2014/07/16 20:20:27
Done.
| |
| 36 for (size_t i = 0; i < displays->size(); ++i) { | |
| 37 DisplayConfigurator::DisplayState* state = &(*displays)[i]; | |
| 38 if (state->display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL && | |
| 39 state->display->native_mode() && | |
| 40 state->touch_device_id == 0) { | |
| 41 internal_dpy_state = state; | |
| 42 break; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 if (internal_dpy_state && internal_ts >= 0) { | |
| 47 internal_dpy_state->touch_device_id = devices[internal_ts].id; | |
| 48 VLOG(2) << "Found internal touchscreen for internal display " | |
| 49 << internal_dpy_state->display->display_id() << " touch_device_id " | |
| 50 << internal_dpy_state->touch_device_id << " size " | |
| 51 << devices[internal_ts].size.ToString(); | |
| 52 } | |
| 53 | |
| 54 for (size_t i = 0; i < devices.size(); ++i) { | |
| 55 if (internal_dpy_state && | |
| 56 internal_dpy_state->touch_device_id == devices[i].id) | |
| 57 continue; | |
| 27 bool found_mapping = false; | 58 bool found_mapping = false; |
| 28 for (size_t j = 0; j < displays->size(); ++j) { | 59 for (size_t j = 0; j < displays->size(); ++j) { |
| 29 DisplayConfigurator::DisplayState* state = &(*displays)[j]; | 60 DisplayConfigurator::DisplayState* state = &(*displays)[j]; |
| 30 const DisplayMode* mode = state->display->native_mode(); | 61 const DisplayMode* mode = state->display->native_mode(); |
| 31 if (state->touch_device_id != 0 || !mode) | 62 if (state->touch_device_id != 0 || !mode) |
| 32 continue; | 63 continue; |
| 33 | 64 |
| 34 // Allow 1 pixel difference between screen and touchscreen | 65 // Allow 1 pixel difference between screen and touchscreen |
| 35 // resolutions. Because in some cases for monitor resolution | 66 // resolutions. Because in some cases for monitor resolution |
| 36 // 1024x768 touchscreen's resolution would be 1024x768, but for | 67 // 1024x768 touchscreen's resolution would be 1024x768, but for |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 VLOG(2) << "Arbitrarily matching touchscreen " | 103 VLOG(2) << "Arbitrarily matching touchscreen " |
| 73 << state->touch_device_id << " to display " | 104 << state->touch_device_id << " to display " |
| 74 << state->display->display_id(); | 105 << state->display->display_id(); |
| 75 break; | 106 break; |
| 76 } | 107 } |
| 77 } | 108 } |
| 78 } | 109 } |
| 79 } | 110 } |
| 80 | 111 |
| 81 } // namespace ui | 112 } // namespace ui |
| OLD | NEW |