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

Side by Side Diff: ash/touch/touch_transformer_controller.cc

Issue 336863002: Moving input device hotplug event processing outside of ui/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TouchscreenDelegate references from display_unittests Created 6 years, 3 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 | « ash/display/display_info.cc ('k') | ash/touch/touchscreen_util.h » ('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 "ash/touch/touch_transformer_controller.h" 5 #include "ash/touch/touch_transformer_controller.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/host/ash_window_tree_host.h" 9 #include "ash/host/ash_window_tree_host.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ui/aura/window_tree_host.h" 12 #include "ui/aura/window_tree_host.h"
13 #include "ui/display/chromeos/display_configurator.h" 13 #include "ui/display/chromeos/display_configurator.h"
14 #include "ui/display/types/chromeos/display_snapshot.h" 14 #include "ui/display/types/chromeos/display_snapshot.h"
15 #include "ui/events/device_data_manager.h" 15 #include "ui/events/device_data_manager.h"
16 #include "ui/events/x/device_data_manager_x11.h" 16 #include "ui/events/x/device_data_manager_x11.h"
17 17
18 namespace ash { 18 namespace ash {
19 19
20 namespace { 20 namespace {
21 21
22 DisplayManager* GetDisplayManager() { 22 DisplayManager* GetDisplayManager() {
23 return Shell::GetInstance()->display_manager(); 23 return Shell::GetInstance()->display_manager();
24 } 24 }
25 25
26 } // namespace 26 } // namespace
27 27
28
29 // This is to compute the scale ratio for the TouchEvent's radius. The 28 // This is to compute the scale ratio for the TouchEvent's radius. The
30 // configured resolution of the display is not always the same as the touch 29 // configured resolution of the display is not always the same as the touch
31 // screen's reporting resolution, e.g. the display could be set as 30 // screen's reporting resolution, e.g. the display could be set as
32 // 1920x1080 while the touchscreen is reporting touch position range at 31 // 1920x1080 while the touchscreen is reporting touch position range at
33 // 32767x32767. Touch radius is reported in the units the same as touch position 32 // 32767x32767. Touch radius is reported in the units the same as touch position
34 // so we need to scale the touch radius to be compatible with the display's 33 // so we need to scale the touch radius to be compatible with the display's
35 // resolution. We compute the scale as 34 // resolution. We compute the scale as
36 // sqrt of (display_area / touchscreen_area) 35 // sqrt of (display_area / touchscreen_area)
37 double TouchTransformerController::GetTouchResolutionScale( 36 double TouchTransformerController::GetTouchResolutionScale(
38 const DisplayInfo& touch_display) const { 37 const DisplayInfo& touch_display) const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 88 }
90 89
91 bool TouchTransformerController::ShouldComputeMirrorModeTouchTransformer( 90 bool TouchTransformerController::ShouldComputeMirrorModeTouchTransformer(
92 const DisplayInfo& touch_display) const { 91 const DisplayInfo& touch_display) const {
93 if (force_compute_mirror_mode_touch_transformer_) 92 if (force_compute_mirror_mode_touch_transformer_)
94 return true; 93 return true;
95 94
96 if (touch_display.touch_device_id() == 0) 95 if (touch_display.touch_device_id() == 0)
97 return false; 96 return false;
98 97
99 const ui::DisplayConfigurator::DisplayState* state = NULL; 98 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
100 const std::vector<ui::DisplayConfigurator::DisplayState>& cached_displays = 99 const std::vector<gfx::Display>& displays = display_manager->displays();
101 Shell::GetInstance()->display_configurator()->cached_displays(); 100 const DisplayInfo* info = NULL;
102 for (size_t i = 0; i < cached_displays.size(); i++) { 101 for (size_t i = 0; i < displays.size(); i++) {
103 if (cached_displays[i].touch_device_id == touch_display.touch_device_id()) { 102 const DisplayInfo& current_info =
104 state = &cached_displays[i]; 103 display_manager->GetDisplayInfo(displays[i].id());
104 if (current_info.touch_device_id() == touch_display.touch_device_id()) {
105 info = &current_info;
105 break; 106 break;
106 } 107 }
107 } 108 }
108 109
109 if (!state || state->mirror_mode == state->display->native_mode() || 110 if (!info || info->size_in_pixel() == info->GetNativeModeSize() ||
110 !state->display->is_aspect_preserving_scaling()) { 111 !info->is_aspect_preserving_scaling()) {
111 return false; 112 return false;
112 } 113 }
113 return true; 114 return true;
114 } 115 }
115 116
116 // This function computes the mirror mode TouchTransformer for |touch_display|. 117 // This function computes the mirror mode TouchTransformer for |touch_display|.
117 // When internal monitor is applied a resolution that does not have 118 // When internal monitor is applied a resolution that does not have
118 // the same aspect ratio as its native resolution, there would be 119 // the same aspect ratio as its native resolution, there would be
119 // blank regions in the letterboxing/pillarboxing mode. 120 // blank regions in the letterboxing/pillarboxing mode.
120 // The TouchTransformer will make sure the touch events on the blank region 121 // The TouchTransformer will make sure the touch events on the blank region
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 293
293 void TouchTransformerController::OnDisplaysInitialized() { 294 void TouchTransformerController::OnDisplaysInitialized() {
294 UpdateTouchTransformer(); 295 UpdateTouchTransformer();
295 } 296 }
296 297
297 void TouchTransformerController::OnDisplayConfigurationChanged() { 298 void TouchTransformerController::OnDisplayConfigurationChanged() {
298 UpdateTouchTransformer(); 299 UpdateTouchTransformer();
299 } 300 }
300 301
301 } // namespace ash 302 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_info.cc ('k') | ash/touch/touchscreen_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698