summaryrefslogtreecommitdiffstats
path: root/views/events
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 17:09:22 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 17:09:22 +0000
commit3746e92a7b15ff58ea91f7a2ae02d12102554544 (patch)
treed70f79aa4c2a2e0d234f319be090667a7076fb94 /views/events
parente2008d7902978df52d7cc0dd733d6b6f559e0f78 (diff)
downloadchromium_src-3746e92a7b15ff58ea91f7a2ae02d12102554544.zip
chromium_src-3746e92a7b15ff58ea91f7a2ae02d12102554544.tar.gz
chromium_src-3746e92a7b15ff58ea91f7a2ae02d12102554544.tar.bz2
Update rich touch information to conform to standard
W3C Touch Event standard (draft) https://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html introduces RadiusX, RadiusY field for touch events. This patch makes views::TouchEvent to have corresonding fields and proper default value extracted from XEvent, and pass them from RWHVV to WebKit side. BUG=None TEST=None Review URL: http://codereview.chromium.org/7129008 Patch from Yufeng Shen <miletus@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/events')
-rw-r--r--views/events/event.cc24
-rw-r--r--views/events/event.h21
-rw-r--r--views/events/event_x.cc62
3 files changed, 36 insertions, 71 deletions
diff --git a/views/events/event.cc b/views/events/event.cc
index 86166b7..8ec7ea8 100644
--- a/views/events/event.cc
+++ b/views/events/event.cc
@@ -185,22 +185,22 @@ TouchEvent::TouchEvent(ui::EventType type,
int y,
int flags,
int touch_id,
- float radius,
- float angle,
- float ratio)
+ float radius_x,
+ float radius_y,
+ float angle)
: LocatedEvent(type, gfx::Point(x, y), flags),
touch_id_(touch_id),
- radius_(radius),
- angle_(angle),
- ratio_(ratio) {
+ radius_x_(radius_x),
+ radius_y_(radius_y),
+ angle_(angle) {
}
TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target)
: LocatedEvent(model, source, target),
touch_id_(model.touch_id_),
- radius_(model.radius_),
- angle_(model.angle_),
- ratio_(model.ratio_) {
+ radius_x_(model.radius_x_),
+ radius_y_(model.radius_y_),
+ angle_(model.angle_) {
}
////////////////////////////////////////////////////////////////////////////////
@@ -209,9 +209,9 @@ TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target)
TouchEvent::TouchEvent(const TouchEvent& model, View* root)
: LocatedEvent(model, root),
touch_id_(model.touch_id_),
- radius_(model.radius_),
- angle_(model.angle_),
- ratio_(model.ratio_) {
+ radius_x_(model.radius_x_),
+ radius_y_(model.radius_y_),
+ angle_(model.angle_) {
}
#endif
diff --git a/views/events/event.h b/views/events/event.h
index 7f4b2e3..9b1d33a 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -261,9 +261,9 @@ class TouchEvent : public LocatedEvent {
int y,
int flags,
int touch_id,
- float radius,
- float angle,
- float ratio);
+ float radius_x,
+ float radius_y,
+ float angle);
// Create a new TouchEvent which is identical to the provided model.
// If source / target views are provided, the model location will be converted
@@ -272,9 +272,9 @@ class TouchEvent : public LocatedEvent {
int identity() const { return touch_id_; }
- float radius() const { return radius_; }
+ float radius_x() const { return radius_x_; }
+ float radius_y() const { return radius_y_; }
float angle() const { return angle_; }
- float ratio() const { return ratio_; }
private:
friend class internal::RootView;
@@ -285,16 +285,15 @@ class TouchEvent : public LocatedEvent {
// for each separable additional touch that the hardware can detect.
const int touch_id_;
- // Half length of the major axis of the touch ellipse. Default 0.0.
- const float radius_;
+ // Radius of the X (major) axis of the touch ellipse. 1.0 if unknown.
+ const float radius_x_;
+
+ // Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown.
+ const float radius_y_;
// Angle of the major axis away from the X axis. Default 0.0.
const float angle_;
- // Length ratio between major axis and minor axis of the touch ellipse. 1.0
- // if only the major axis is available, prentending the touch is a circle.
- const float ratio_;
-
DISALLOW_COPY_AND_ASSIGN(TouchEvent);
};
#endif
diff --git a/views/events/event_x.cc b/views/events/event_x.cc
index 3721fb2..0fa471e 100644
--- a/views/events/event_x.cc
+++ b/views/events/event_x.cc
@@ -245,53 +245,13 @@ uint16 GetCharacterFromXKeyEvent(XKeyEvent* key) {
result.length() == 1) ? result[0] : 0;
}
-float GetTouchRadiusFromXEvent(XEvent* xev) {
- float diameter = 0.0;
-
+float GetTouchParamFromXEvent(XEvent* xev,
+ TouchFactory::TouchParam tp,
+ float default_value) {
#if defined(HAVE_XINPUT2)
- TouchFactory* touch_factory = TouchFactory::GetInstance();
- touch_factory->ExtractTouchParam(*xev, TouchFactory::TP_TOUCH_MAJOR,
- &diameter);
+ TouchFactory::GetInstance()->ExtractTouchParam(*xev, tp, &default_value);
#endif
-
- return diameter / 2.0;
-}
-
-float GetTouchAngleFromXEvent(XEvent* xev) {
- float angle = 0.0;
-
-#if defined(HAVE_XINPUT2)
- TouchFactory* touch_factory = TouchFactory::GetInstance();
- touch_factory->ExtractTouchParam(*xev, TouchFactory::TP_ORIENTATION,
- &angle);
-#endif
-
- return angle;
-}
-
-
-float GetTouchRatioFromXEvent(XEvent* xev) {
- float ratio = 1.0;
-
-#if defined(HAVE_XINPUT2)
- TouchFactory* touch_factory = TouchFactory::GetInstance();
- float major_v = -1.0;
- float minor_v = -1.0;
-
- if (!touch_factory->ExtractTouchParam(*xev,
- TouchFactory::TP_TOUCH_MAJOR,
- &major_v) ||
- !touch_factory->ExtractTouchParam(*xev,
- TouchFactory::TP_TOUCH_MINOR,
- &minor_v))
- return ratio;
-
- // In case minor axis exists but is zero.
- if (minor_v > 0.0)
- ratio = major_v / minor_v;
-#endif
-
- return ratio;
+ return default_value;
}
} // namespace
@@ -421,9 +381,15 @@ TouchEvent::TouchEvent(NativeEvent2 native_event_2,
FromNativeEvent2 from_native)
: LocatedEvent(native_event_2, from_native),
touch_id_(GetTouchIDFromXEvent(native_event_2)),
- radius_(GetTouchRadiusFromXEvent(native_event_2)),
- angle_(GetTouchAngleFromXEvent(native_event_2)),
- ratio_(GetTouchRatioFromXEvent(native_event_2)) {
+ radius_x_(GetTouchParamFromXEvent(native_event_2,
+ TouchFactory::TP_TOUCH_MAJOR,
+ 2.0) / 2.0),
+ radius_y_(GetTouchParamFromXEvent(native_event_2,
+ TouchFactory::TP_TOUCH_MINOR,
+ 2.0) / 2.0),
+ angle_(GetTouchParamFromXEvent(native_event_2,
+ TouchFactory::TP_ORIENTATION,
+ 0.0)) {
if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
TouchFactory* factory = TouchFactory::GetInstance();
float slot;