Chromium Code Reviews| 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> | |
| 8 | |
| 7 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 9 #include "ash/wm/coordinate_conversion.h" | 11 #include "ash/wm/coordinate_conversion.h" |
| 10 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 13 #include "chromeos/display/output_configurator.h" | |
| 11 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 13 #include "ui/base/events/event.h" | 16 #include "ui/base/events/event.h" |
| 14 #include "ui/compositor/dip_util.h" | 17 #include "ui/compositor/dip_util.h" |
| 15 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 17 | 20 |
| 18 namespace ash { | 21 namespace ash { |
| 19 namespace internal { | 22 namespace internal { |
| 20 namespace { | 23 namespace { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 43 // Apply some additional scaling if the display is non-integrated. | 46 // Apply some additional scaling if the display is non-integrated. |
| 44 wm::ConvertPointToScreen(target, &point_in_screen); | 47 wm::ConvertPointToScreen(target, &point_in_screen); |
| 45 const gfx::Display& display = | 48 const gfx::Display& display = |
| 46 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen); | 49 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen); |
| 47 if (!display.IsInternal()) | 50 if (!display.IsInternal()) |
| 48 scale *= kBoostForNonIntegrated; | 51 scale *= kBoostForNonIntegrated; |
| 49 | 52 |
| 50 event->Scale(scale); | 53 event->Scale(scale); |
| 51 } | 54 } |
| 52 | 55 |
| 56 #if defined(OS_CHROMEOS) | |
| 57 // This is to scale the TouchEvent's radius when the touch display is in | |
| 58 // mirror mode. TouchEvent's radius is often reported in the touchscreen's | |
| 59 // native resolution. In mirror mode, the touch display could be configured | |
| 60 // at a lower resolution. We scale down the radius using the ratio defined as | |
| 61 // the sqrt of | |
| 62 // (mirror_width * mirror_height) / (native_width * native_height) | |
| 63 void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) { | |
| 64 using chromeos::OutputConfigurator; | |
| 65 OutputConfigurator* output_configurator = | |
| 66 ash::Shell::GetInstance()->output_configurator(); | |
| 67 | |
| 68 if (output_configurator->output_state() != chromeos::STATE_DUAL_MIRROR) | |
| 69 return; | |
| 70 | |
| 71 const std::map<int, float>& area_ratio_map = | |
| 72 output_configurator->GetMirroredDisplayAreaRatioMap(); | |
| 73 | |
| 74 // TODO(miletus): When there are more than 1 touchscreen (e.g. Link connected | |
| 75 // to an external touchscreen), the correct way to do is to have a way | |
| 76 // to find out which touchscreen is the event originating from and use the | |
| 77 // area ratio of that touchscreen to scale the event's radius. | |
|
oshima
2013/04/18 17:51:36
can you file a bug and add reference here so that
Yufeng Shen (Slow to review)
2013/04/18 18:05:56
Done.
| |
| 78 if (area_ratio_map.size() != 1) { | |
| 79 LOG(ERROR) << "Mirroring mode with " << area_ratio_map.size() | |
| 80 << " touch display found"; | |
| 81 return; | |
| 82 } | |
| 83 | |
| 84 float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second); | |
| 85 event->set_radius_x(event->radius_x() * area_ratio_sqrt); | |
| 86 event->set_radius_y(event->radius_y() * area_ratio_sqrt); | |
| 87 } | |
| 88 #endif // defined(OS_CHROMEOS) | |
| 89 | |
| 53 } // namespace internal | 90 } // namespace internal |
| 54 } // namespace ash | 91 } // namespace ash |
| 55 | |
| OLD | NEW |