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

Unified Diff: ui/base/events/event.cc

Issue 10905163: aura-x11: Fix touch-calibration for multi-monitor setups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 | « ui/base/events/event.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/events/event.cc
diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc
index fdc40b42df159137ddc75e34bc5a985e19302fad..f2881072be311dda12aad0d1fc49217967ca8486 100644
--- a/ui/base/events/event.cc
+++ b/ui/base/events/event.cc
@@ -8,6 +8,7 @@
#include <X11/Xlib.h>
#endif
+#include <cmath>
#include <cstring>
#include "ui/base/keycodes/keyboard_code_conversion.h"
@@ -37,6 +38,17 @@ base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
#endif
}
+gfx::Point CalibratePoint(const gfx::Point& point,
+ const gfx::Size& from,
+ const gfx::Size& to) {
+ float calibrated_x =
+ static_cast<float>(point.x()) * to.width() / from.width();
+ float calibrated_y =
+ static_cast<float>(point.y()) * to.height() / from.height();
+ return gfx::Point(static_cast<int>(floorf(calibrated_x + 0.5f)),
+ static_cast<int>(floorf(calibrated_y + 0.5f)));
+}
+
} // namespace
namespace ui {
@@ -291,6 +303,11 @@ TouchEvent::TouchEvent(EventType type,
TouchEvent::~TouchEvent() {
}
+void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) {
+ location_ = CalibratePoint(location_, from, to);
+ root_location_ = CalibratePoint(root_location_, from, to);
+}
+
void TouchEvent::UpdateForRootTransform(const Transform& root_transform) {
LocatedEvent::UpdateForRootTransform(root_transform);
gfx::Point3f scale;
« no previous file with comments | « ui/base/events/event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698