summaryrefslogtreecommitdiffstats
path: root/views/events
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 16:06:35 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 16:06:35 +0000
commit5951806fdc9a6d3063014b0479307dba66767f97 (patch)
tree1b52d819db6119600bcaeab8f51ccc3a3d48c925 /views/events
parentb5ad6bd0e8eda70dc4f3b1dbd6229f9d82cdb17b (diff)
downloadchromium_src-5951806fdc9a6d3063014b0479307dba66767f97.zip
chromium_src-5951806fdc9a6d3063014b0479307dba66767f97.tar.gz
chromium_src-5951806fdc9a6d3063014b0479307dba66767f97.tar.bz2
aura: Add support for touch events.
Among the changes: . Add touch event handling in EventFilter. Be default, activates a window on TOUCH_START (like for MOUSE_PRESSED). . Move TouchEvent details functions into ui/. Moved the X11 implementations from views/ to ui/. NOTIMPLEMENTED on windows. . Disable RWHVAura et. al. for touchui for now (they are still compiled in, but not used). BUG=100269 TEST=none Review URL: http://codereview.chromium.org/8274025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105816 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/events')
-rw-r--r--views/events/event.h2
-rw-r--r--views/events/event_aura.cc12
-rw-r--r--views/events/event_x.cc61
3 files changed, 19 insertions, 56 deletions
diff --git a/views/events/event.h b/views/events/event.h
index 5312ecd..a7b3620 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -243,7 +243,7 @@ class VIEWS_EXPORT MouseEvent : public LocatedEvent {
////////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT TouchEvent : public LocatedEvent {
public:
- explicit TouchEvent(const base::NativeEvent& native_event);
+ explicit TouchEvent(const NativeEvent& native_event);
// Create a new touch event.
TouchEvent(ui::EventType type,
diff --git a/views/events/event_aura.cc b/views/events/event_aura.cc
index dca43fd..bf6a1c5 100644
--- a/views/events/event_aura.cc
+++ b/views/events/event_aura.cc
@@ -18,6 +18,18 @@ LocatedEvent::LocatedEvent(const NativeEvent& native_event)
}
////////////////////////////////////////////////////////////////////////////////
+// TouchEvent, public:
+
+TouchEvent::TouchEvent(const NativeEvent& event)
+ : LocatedEvent(event),
+ touch_id_(static_cast<aura::TouchEvent*>(event)->touch_id()),
+ radius_x_(static_cast<aura::TouchEvent*>(event)->radius_x()),
+ radius_y_(static_cast<aura::TouchEvent*>(event)->radius_y()),
+ rotation_angle_(static_cast<aura::TouchEvent*>(event)->rotation_angle()),
+ force_(static_cast<aura::TouchEvent*>(event)->force()) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:
KeyEvent::KeyEvent(const NativeEvent& native_event)
diff --git a/views/events/event_x.cc b/views/events/event_x.cc
index 7dbaedb..1c1c51d 100644
--- a/views/events/event_x.cc
+++ b/views/events/event_x.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
+#include "ui/base/events.h"
#include "ui/base/keycodes/keyboard_code_conversion_x.h"
#include "ui/base/touch/touch_factory.h"
#include "views/widget/root_view.h"
@@ -19,31 +20,6 @@ namespace views {
namespace {
-int GetTouchIDFromXEvent(XEvent* xev) {
- float slot = 0;
- ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
- XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
- if (!factory->IsRealTouchDevice(xievent->sourceid)) {
- // TODO(sad): Come up with a way to generate touch-ids for multi-touch
- // events when touch-events are generated from a mouse.
- return slot;
- }
-
-#if defined(USE_XI2_MT)
- float tracking_id;
- if (!factory->ExtractTouchParam(
- *xev, ui::TouchFactory::TP_TRACKING_ID, &tracking_id))
- LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
- else
- slot = factory->GetSlotForTrackingID(tracking_id);
-#else
- if (!factory->ExtractTouchParam(
- *xev, ui::TouchFactory::TP_SLOT_ID, &slot))
- LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
-#endif
- return slot;
-}
-
uint16 GetCharacterFromXKeyEvent(XKeyEvent* key) {
char buf[6];
int bytes_written = XLookupString(key, buf, 6, NULL, NULL);
@@ -54,25 +30,6 @@ uint16 GetCharacterFromXKeyEvent(XKeyEvent* key) {
result.length() == 1) ? result[0] : 0;
}
-float GetTouchParamFromXEvent(XEvent* xev,
- ui::TouchFactory::TouchParam tp,
- float default_value) {
- ui::TouchFactory::GetInstance()->ExtractTouchParam(*xev, tp, &default_value);
- return default_value;
-}
-
-float GetTouchForceFromXEvent(XEvent* xev) {
- float force = 0.0;
- force = GetTouchParamFromXEvent(xev, ui::TouchFactory::TP_PRESSURE, 0.0);
- unsigned int deviceid =
- static_cast<XIDeviceEvent*>(xev->xcookie.data)->sourceid;
- // Force is normalized to fall into [0, 1]
- if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam(
- deviceid, ui::TouchFactory::TP_PRESSURE, &force))
- force = 0.0;
- return force;
-}
-
// The following two functions are copied from event_gtk.cc. These will be
// removed when GTK dependency is removed.
#if defined(TOOLKIT_USES_GTK)
@@ -171,17 +128,11 @@ uint16 KeyEvent::GetUnmodifiedCharacter() const {
TouchEvent::TouchEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
- touch_id_(GetTouchIDFromXEvent(native_event)),
- radius_x_(GetTouchParamFromXEvent(native_event,
- ui::TouchFactory::TP_TOUCH_MAJOR,
- 2.0) / 2.0),
- radius_y_(GetTouchParamFromXEvent(native_event,
- ui::TouchFactory::TP_TOUCH_MINOR,
- 2.0) / 2.0),
- rotation_angle_(GetTouchParamFromXEvent(native_event,
- ui::TouchFactory::TP_ORIENTATION,
- 0.0)),
- force_(GetTouchForceFromXEvent(native_event)) {
+ touch_id_(ui::GetTouchId(native_event)),
+ radius_x_(ui::GetTouchRadiusX(native_event)),
+ radius_y_(ui::GetTouchRadiusY(native_event)),
+ rotation_angle_(ui::GetTouchAngle(native_event)),
+ force_(ui::GetTouchForce(native_event)) {
#if defined(USE_XI2_MT)
if (type() == ui::ET_TOUCH_RELEASED) {
// NOTE: The slot is allocated by TouchFactory for each XI_TouchBegin