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

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: Trimmed comments and fix the code 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 as
44 // in the CrOS X server patch since the event locations etc. are already
45 // in DIP.
sadrul 2013/09/20 04:48:53 Remove 'as in the CrOS X server patch'. i.e. 'It
Shecky Lin 2013/09/20 05:02:00 Done.
44 gfx::Point point_in_screen(event->location()); 46 gfx::Point point_in_screen(event->location());
45 aura::Window* target = static_cast<aura::Window*>(event->target()); 47 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); 48 wm::ConvertPointToScreen(target, &point_in_screen);
51 const gfx::Display& display = 49 const gfx::Display& display =
52 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen); 50 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);
51
52 // Apply some additional scaling if the display is non-integrated.
53 if (!display.IsInternal()) 53 if (!display.IsInternal())
54 scale *= kBoostForNonIntegrated; 54 event->Scale(kBoostForNonIntegrated);
55
56 event->Scale(scale);
57 } 55 }
58 56
59 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
60 // This is to scale the TouchEvent's radius when the touch display is in 58 // 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 59 // mirror mode. TouchEvent's radius is often reported in the touchscreen's
62 // native resolution. In mirror mode, the touch display could be configured 60 // 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 61 // at a lower resolution. We scale down the radius using the ratio defined as
64 // the sqrt of 62 // the sqrt of
65 // (mirror_width * mirror_height) / (native_width * native_height) 63 // (mirror_width * mirror_height) / (native_width * native_height)
66 void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) { 64 void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) {
(...skipping 22 matching lines...) Expand all
89 } 87 }
90 88
91 float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second); 89 float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second);
92 event->set_radius_x(event->radius_x() * area_ratio_sqrt); 90 event->set_radius_x(event->radius_x() * area_ratio_sqrt);
93 event->set_radius_y(event->radius_y() * area_ratio_sqrt); 91 event->set_radius_y(event->radius_y() * area_ratio_sqrt);
94 } 92 }
95 #endif // defined(OS_CHROMEOS) 93 #endif // defined(OS_CHROMEOS)
96 94
97 } // namespace internal 95 } // namespace internal
98 } // namespace ash 96 } // 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