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

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

Issue 12087124: Disable touch calibration on external touchscreen. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review + Rebase on top of 12321086 Created 7 years, 9 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
Index: ui/base/events/event.h
diff --git a/ui/base/events/event.h b/ui/base/events/event.h
index b29d1ede253cf1fea02b9ebd1e6f52c774f242e7..2188e75f1ffd097de08350de8fbef483a457df33 100644
--- a/ui/base/events/event.h
+++ b/ui/base/events/event.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/event_types.h"
#include "base/logging.h"
+#include "base/memory/singleton.h"
#include "base/time.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/events/event_constants.h"
@@ -444,6 +445,35 @@ class UI_EXPORT MouseWheelEvent : public MouseEvent {
DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent);
};
+#if defined(USE_XI2_MT)
+// A singleton, which reads touch event calibration parameters
+// from the command line once - in constructor.
+// These parameters are then used in Calibrate() to compensate
+// for the bezels on the internal touchscreen.
+class TouchCoordinatesCalibrator {
+public:
oshima 2013/03/14 01:23:27 indent
ynovikov 2013/03/14 20:27:04 Done.
+ static TouchCoordinatesCalibrator* GetInstance();
+ // Modify the location of the |event|,
+ // expanding it from |bounds| to (|bounds| + bezels).
+ // Required when touchscreen is bigger than screen (i.e. has bezels),
+ // because we receive events in touchscreen coordinates,
+ // which needs to be expanded when converting to screen coordinates,
+ // so that location on bezels will be outside of screen area.
+ void Calibrate(TouchEvent* event, const gfx::Rect& bounds);
+private:
oshima 2013/03/14 01:23:27 indent
ynovikov 2013/03/14 20:27:04 Done.
+ TouchCoordinatesCalibrator();
+ friend struct DefaultSingletonTraits<TouchCoordinatesCalibrator>;
+
+ // The (positive) calibration values for the four border sides.
+ int left_;
+ int right_;
+ int top_;
+ int bottom_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchCoordinatesCalibrator);
+};
+#endif
+
class UI_EXPORT TouchEvent : public LocatedEvent {
public:
explicit TouchEvent(const base::NativeEvent& native_event);
@@ -489,6 +519,12 @@ class UI_EXPORT TouchEvent : public LocatedEvent {
// and it needs to be mapped into Aura Root Window coordinates.
void Relocate(const gfx::Point& origin);
+#if defined(USE_XI2_MT)
+ // Apply bezels calibration, given |bounds| screen size,
+ // and bezel sizes previously read from command line.
+ void Calibrate(const gfx::Rect& bounds);
+#endif
+
// Used for unit tests.
void set_radius_x(const float r) { radius_x_ = r; }
void set_radius_y(const float r) { radius_y_ = r; }

Powered by Google App Engine
This is Rietveld 408576698