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

Side by Side Diff: ash/display/event_transformation_handler.cc

Issue 23452037: Do not scale ScrollEvent by device scale factor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update the comment Created 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/display/event_transformation_handler.h" 5 #include "ash/display/event_transformation_handler.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 22 matching lines...) Expand all
33 : transformation_mode_(TRANSFORM_AUTO) { 33 : transformation_mode_(TRANSFORM_AUTO) {
34 } 34 }
35 35
36 EventTransformationHandler::~EventTransformationHandler() { 36 EventTransformationHandler::~EventTransformationHandler() {
37 } 37 }
38 38
39 void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) { 39 void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
40 if (transformation_mode_ == TRANSFORM_NONE) 40 if (transformation_mode_ == TRANSFORM_NONE)
41 return; 41 return;
42 42
43 // Get the device scale factor and stack it on the final scale factor. 43 // It is unnecessary to scale the event for the device scale factor since
44 // the event locations etc. are already in DIP.
44 gfx::Point point_in_screen(event->location()); 45 gfx::Point point_in_screen(event->location());
45 aura::Window* target = static_cast<aura::Window*>(event->target()); 46 aura::Window* target = static_cast<aura::Window*>(event->target());
46 const float scale_at_target = ui::GetDeviceScaleFactor(target->layer());
47 float scale = scale_at_target;
48
49 // Apply some additional scaling if the display is non-integrated.
50 wm::ConvertPointToScreen(target, &point_in_screen); 47 wm::ConvertPointToScreen(target, &point_in_screen);
51 const gfx::Display& display = 48 const gfx::Display& display =
52 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen); 49 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);
50
51 // Apply some additional scaling if the display is non-integrated.
53 if (!display.IsInternal()) 52 if (!display.IsInternal())
54 scale *= kBoostForNonIntegrated; 53 event->Scale(kBoostForNonIntegrated);
55
56 event->Scale(scale);
57 } 54 }
58 55
59 #if defined(OS_CHROMEOS) 56 #if defined(OS_CHROMEOS)
60 // This is to scale the TouchEvent's radius when the touch display is in 57 // This is to scale the TouchEvent's radius when the touch display is in
61 // mirror mode. TouchEvent's radius is often reported in the touchscreen's 58 // mirror mode. TouchEvent's radius is often reported in the touchscreen's
62 // native resolution. In mirror mode, the touch display could be configured 59 // native resolution. In mirror mode, the touch display could be configured
63 // at a lower resolution. We scale down the radius using the ratio defined as 60 // at a lower resolution. We scale down the radius using the ratio defined as
64 // the sqrt of 61 // the sqrt of
65 // (mirror_width * mirror_height) / (native_width * native_height) 62 // (mirror_width * mirror_height) / (native_width * native_height)
66 void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) { 63 void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) {
(...skipping 22 matching lines...) Expand all
89 } 86 }
90 87
91 float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second); 88 float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second);
92 event->set_radius_x(event->radius_x() * area_ratio_sqrt); 89 event->set_radius_x(event->radius_x() * area_ratio_sqrt);
93 event->set_radius_y(event->radius_y() * area_ratio_sqrt); 90 event->set_radius_y(event->radius_y() * area_ratio_sqrt);
94 } 91 }
95 #endif // defined(OS_CHROMEOS) 92 #endif // defined(OS_CHROMEOS)
96 93
97 } // namespace internal 94 } // namespace internal
98 } // namespace ash 95 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698