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

Side by Side Diff: ui/display/chromeos/touchscreen_delegate_impl.cc

Issue 394063004: Associate internal touchscreen to internal display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/display/chromeos/touchscreen_delegate_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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_touchscreen = -1;
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_touchscreen = i;
31 break;
32 }
33 }
34
35 DisplayConfigurator::DisplayState* internal_state = NULL;
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_state = state;
42 break;
43 }
44 }
45
46 if (internal_state && internal_touchscreen >= 0) {
47 internal_state->touch_device_id = devices[internal_touchscreen].id;
48 VLOG(2) << "Found internal touchscreen for internal display "
49 << internal_state->display->display_id() << " touch_device_id "
50 << internal_state->touch_device_id << " size "
51 << devices[internal_touchscreen].size.ToString();
52 }
53
54 for (size_t i = 0; i < devices.size(); ++i) {
55 if (internal_state &&
56 internal_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
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
OLDNEW
« no previous file with comments | « no previous file | ui/display/chromeos/touchscreen_delegate_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698