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

Unified Diff: ash/display/event_transformation_handler.cc

Issue 14279002: Scale TouchEvent's radius when touchscreen is in mirror mode (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed oshima's comments Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/event_transformation_handler.h ('k') | ash/shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/event_transformation_handler.cc
diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc
index 7ecc6341dbf30756eeda253051fd5861a16493f6..2cdffeafaf5d9b81bc0f1b01f7d1c3ef4a7942fb 100644
--- a/ash/display/event_transformation_handler.cc
+++ b/ash/display/event_transformation_handler.cc
@@ -4,10 +4,13 @@
#include "ash/display/event_transformation_handler.h"
+#include <cmath>
+
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
+#include "chromeos/display/output_configurator.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/events/event.h"
@@ -50,6 +53,39 @@ void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
event->Scale(scale);
}
+#if defined(OS_CHROMEOS)
+// This is to scale the TouchEvent's radius when the touch display is in
+// mirror mode. TouchEvent's radius is often reported in the touchscreen's
+// native resolution. In mirror mode, the touch display could be configured
+// at a lower resolution. We scale down the radius using the ratio defined as
+// the sqrt of
+// (mirror_width * mirror_height) / (native_width * native_height)
+void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) {
+ using chromeos::OutputConfigurator;
+ OutputConfigurator* output_configurator =
+ ash::Shell::GetInstance()->output_configurator();
+
+ if (output_configurator->output_state() != chromeos::STATE_DUAL_MIRROR)
+ return;
+
+ const std::map<int, float>& area_ratio_map =
+ output_configurator->GetMirroredDisplayAreaRatioMap();
+
+ // TODO(miletus): When there are more than 1 touchscreen (e.g. Link connected
+ // to an external touchscreen), the correct way to do is to have a way
+ // to find out which touchscreen is the event originating from and use the
+ // 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.
+ if (area_ratio_map.size() != 1) {
+ LOG(ERROR) << "Mirroring mode with " << area_ratio_map.size()
+ << " touch display found";
+ return;
+ }
+
+ float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second);
+ event->set_radius_x(event->radius_x() * area_ratio_sqrt);
+ event->set_radius_y(event->radius_y() * area_ratio_sqrt);
+}
+#endif // defined(OS_CHROMEOS)
+
} // namespace internal
} // namespace ash
-
« no previous file with comments | « ash/display/event_transformation_handler.h ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698