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