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

Unified Diff: ash/display/event_transformation_handler.cc

Issue 11743013: Scaling scroll/fling events in multi-monitor setup (Closed) Base URL: https://chromium.googlesource.com/chromium/src@git-svn
Patch Set: Addressing Ben's comment Created 7 years, 11 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.h » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..380399d8b8ef18e3afa90c54a60cef3c033ab6e9
--- /dev/null
+++ b/ash/display/event_transformation_handler.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/display/event_transformation_handler.h"
+
+#include "ash/display/display_manager.h"
+#include "ash/screen_ash.h"
+#include "ash/shell.h"
+#include "ash/wm/coordinate_conversion.h"
+#include "ash/wm/window_util.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/base/events/event.h"
+#include "ui/compositor/dip_util.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/screen.h"
+
+namespace ash {
+namespace internal {
+namespace {
+
+// Boost factor for non-integrated displays.
+const float kBoostForNonIntegrated = 1.20f;
+}
+
+EventTransformationHandler::EventTransformationHandler()
+ : transformation_mode_(TRANSFORM_AUTO) {
+}
+
+EventTransformationHandler::~EventTransformationHandler() {
+}
+
+void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
+ if (transformation_mode_ == TRANSFORM_NONE)
+ return;
+
+ // Get the device scale factor and stack it on the final scale factor.
+ gfx::Point point_in_screen(event->location());
+ aura::Window* target = static_cast<aura::Window*>(event->target());
+ const float scale_at_target = ui::GetDeviceScaleFactor(target->layer());
+ float scale = scale_at_target;
+
+ // Apply some additional scaling if the display is non-integrated.
+ wm::ConvertPointToScreen(target, &point_in_screen);
+ const gfx::Display& display =
+ Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+ if (!display_manager->IsInternalDisplayId(display.id()))
+ scale *= kBoostForNonIntegrated;
+
+ event->Scale(scale);
+}
+
+} // namespace internal
+} // namespace ash
+
« no previous file with comments | « ash/display/event_transformation_handler.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698