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

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

Issue 618283003: Adds special support to the device manager for keyboards devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master. Created 6 years, 2 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
« no previous file with comments | « ash/display/display_info.h ('k') | ash/touch/touch_transformer_controller_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 "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"
(...skipping 17 matching lines...) Expand all
28 // 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
29 // 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
30 // 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
31 // 1920x1080 while the touchscreen is reporting touch position range at 31 // 1920x1080 while the touchscreen is reporting touch position range at
32 // 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
33 // 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
34 // resolution. We compute the scale as 34 // resolution. We compute the scale as
35 // sqrt of (display_area / touchscreen_area) 35 // sqrt of (display_area / touchscreen_area)
36 double TouchTransformerController::GetTouchResolutionScale( 36 double TouchTransformerController::GetTouchResolutionScale(
37 const DisplayInfo& touch_display) const { 37 const DisplayInfo& touch_display) const {
38 if (touch_display.touch_device_id() == 0) 38 if (touch_display.touch_device_id() == 0u)
39 return 1.0; 39 return 1.0;
40 40
41 double min_x, max_x; 41 double min_x, max_x;
42 double min_y, max_y; 42 double min_y, max_y;
43 if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange( 43 if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange(
44 touch_display.touch_device_id(), 44 touch_display.touch_device_id(),
45 ui::DeviceDataManagerX11::DT_TOUCH_POSITION_X, 45 ui::DeviceDataManagerX11::DT_TOUCH_POSITION_X,
46 &min_x, &max_x) || 46 &min_x, &max_x) ||
47 !ui::DeviceDataManagerX11::GetInstance()->GetDataRange( 47 !ui::DeviceDataManagerX11::GetInstance()->GetDataRange(
48 touch_display.touch_device_id(), 48 touch_display.touch_device_id(),
(...skipping 21 matching lines...) Expand all
70 return ratio; 70 return ratio;
71 } 71 }
72 72
73 // This function computes the extended mode TouchTransformer for 73 // This function computes the extended mode TouchTransformer for
74 // |touch_display|. The TouchTransformer maps the touch event position 74 // |touch_display|. The TouchTransformer maps the touch event position
75 // from framebuffer size to the display size. 75 // from framebuffer size to the display size.
76 gfx::Transform 76 gfx::Transform
77 TouchTransformerController::GetExtendedModeTouchTransformer( 77 TouchTransformerController::GetExtendedModeTouchTransformer(
78 const DisplayInfo& touch_display, const gfx::Size& fb_size) const { 78 const DisplayInfo& touch_display, const gfx::Size& fb_size) const {
79 gfx::Transform ctm; 79 gfx::Transform ctm;
80 if (touch_display.touch_device_id() == 0 || 80 if (touch_display.touch_device_id() == 0u || fb_size.width() == 0.0 ||
81 fb_size.width() == 0.0 ||
82 fb_size.height() == 0.0) 81 fb_size.height() == 0.0)
83 return ctm; 82 return ctm;
84 float width = touch_display.bounds_in_native().width(); 83 float width = touch_display.bounds_in_native().width();
85 float height = touch_display.bounds_in_native().height(); 84 float height = touch_display.bounds_in_native().height();
86 ctm.Scale(width / fb_size.width(), height / fb_size.height()); 85 ctm.Scale(width / fb_size.width(), height / fb_size.height());
87 return ctm; 86 return ctm;
88 } 87 }
89 88
90 bool TouchTransformerController::ShouldComputeMirrorModeTouchTransformer( 89 bool TouchTransformerController::ShouldComputeMirrorModeTouchTransformer(
91 const DisplayInfo& touch_display) const { 90 const DisplayInfo& touch_display) const {
92 if (force_compute_mirror_mode_touch_transformer_) 91 if (force_compute_mirror_mode_touch_transformer_)
93 return true; 92 return true;
94 93
95 if (touch_display.touch_device_id() == 0) 94 if (touch_display.touch_device_id() == 0u)
96 return false; 95 return false;
97 96
98 if (touch_display.size_in_pixel() == touch_display.GetNativeModeSize() || 97 if (touch_display.size_in_pixel() == touch_display.GetNativeModeSize() ||
99 !touch_display.is_aspect_preserving_scaling()) { 98 !touch_display.is_aspect_preserving_scaling()) {
100 return false; 99 return false;
101 } 100 }
102 101
103 return true; 102 return true;
104 } 103 }
105 104
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 271
273 void TouchTransformerController::OnDisplaysInitialized() { 272 void TouchTransformerController::OnDisplaysInitialized() {
274 UpdateTouchTransformer(); 273 UpdateTouchTransformer();
275 } 274 }
276 275
277 void TouchTransformerController::OnDisplayConfigurationChanged() { 276 void TouchTransformerController::OnDisplayConfigurationChanged() {
278 UpdateTouchTransformer(); 277 UpdateTouchTransformer();
279 } 278 }
280 279
281 } // namespace ash 280 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_info.h ('k') | ash/touch/touch_transformer_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698