OLD | NEW |
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 "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
11 #include "ui/display/display.h" | 11 #include "ui/display/display.h" |
12 #include "ui/display/screen.h" | 12 #include "ui/display/screen.h" |
13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
14 #include "ui/wm/core/coordinate_conversion.h" | 14 #include "ui/wm/core/coordinate_conversion.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Boost factor for non-integrated displays. | 19 // Boost factor for non-integrated displays. |
20 const float kBoostForNonIntegrated = 1.20f; | 20 const float kBoostForNonIntegrated = 1.20f; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 EventTransformationHandler::EventTransformationHandler() | 24 EventTransformationHandler::EventTransformationHandler() |
25 : transformation_mode_(TRANSFORM_AUTO) { | 25 : transformation_mode_(TRANSFORM_AUTO) {} |
26 } | |
27 | 26 |
28 EventTransformationHandler::~EventTransformationHandler() { | 27 EventTransformationHandler::~EventTransformationHandler() {} |
29 } | |
30 | 28 |
31 void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) { | 29 void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) { |
32 if (transformation_mode_ == TRANSFORM_NONE) | 30 if (transformation_mode_ == TRANSFORM_NONE) |
33 return; | 31 return; |
34 | 32 |
35 // It is unnecessary to scale the event for the device scale factor since | 33 // It is unnecessary to scale the event for the device scale factor since |
36 // the event locations etc. are already in DIP. | 34 // the event locations etc. are already in DIP. |
37 gfx::Point point_in_screen(event->location()); | 35 gfx::Point point_in_screen(event->location()); |
38 aura::Window* target = static_cast<aura::Window*>(event->target()); | 36 aura::Window* target = static_cast<aura::Window*>(event->target()); |
39 ::wm::ConvertPointToScreen(target, &point_in_screen); | 37 ::wm::ConvertPointToScreen(target, &point_in_screen); |
40 const display::Display& display = | 38 const display::Display& display = |
41 display::Screen::GetScreen()->GetDisplayNearestPoint(point_in_screen); | 39 display::Screen::GetScreen()->GetDisplayNearestPoint(point_in_screen); |
42 | 40 |
43 // Apply some additional scaling if the display is non-integrated. | 41 // Apply some additional scaling if the display is non-integrated. |
44 if (!display.IsInternal()) | 42 if (!display.IsInternal()) |
45 event->Scale(kBoostForNonIntegrated); | 43 event->Scale(kBoostForNonIntegrated); |
46 } | 44 } |
47 | 45 |
48 } // namespace ash | 46 } // namespace ash |
OLD | NEW |