diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 17:14:46 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 17:14:46 +0000 |
commit | 39529b33b5e80e5be1d583dfd43f0d692209cbf3 (patch) | |
tree | a0c160d8626d90d6e6f0804d0573e64d8124d16e | |
parent | ad99352b1cfccb51ec9a3ef7a4ac8778413c67fc (diff) | |
download | chromium_src-39529b33b5e80e5be1d583dfd43f0d692209cbf3.zip chromium_src-39529b33b5e80e5be1d583dfd43f0d692209cbf3.tar.gz chromium_src-39529b33b5e80e5be1d583dfd43f0d692209cbf3.tar.bz2 |
touch: Fix a crash when clicking on a webpage.
Also, consolidate touch and mouse event constructions as much as possible.
BUG=clicking a webpage causes a crash
TEST=manually
Review URL: http://codereview.chromium.org/6624094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77294 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/events/event_x.cc | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/views/events/event_x.cc b/views/events/event_x.cc index c008c87..4526fd9 100644 --- a/views/events/event_x.cc +++ b/views/events/event_x.cc @@ -96,17 +96,6 @@ ui::EventType GetTouchEventType(XEvent* xev) { return ui::ET_UNKNOWN; } -gfx::Point GetTouchEventLocation(XEvent* xev) { - XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); - return gfx::Point(xiev->event_x, xiev->event_y); -} - -int GetTouchEventFlags(XEvent* xev) { - XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); - return GetButtonMaskForX2Event(xiev) | - GetEventFlagsFromXState(xiev->mods.effective); -} - int GetTouchIDFromXEvent(XEvent* xev) { // TODO(sad): How we determine the touch-id from the event is as yet // undecided. @@ -171,7 +160,7 @@ int GetMouseWheelOffset(XEvent* xev) { return xev->xbutton.button == 4 ? kWheelScrollAmount : -kWheelScrollAmount; } -gfx::Point GetMouseEventLocation(XEvent* xev) { +gfx::Point GetEventLocation(XEvent* xev) { switch (xev->type) { case ButtonPress: case ButtonRelease: @@ -193,7 +182,7 @@ gfx::Point GetMouseEventLocation(XEvent* xev) { return gfx::Point(); } -int GetMouseEventFlags(XEvent* xev) { +int GetLocatedEventFlags(XEvent* xev, bool touch) { switch (xev->type) { case ButtonPress: case ButtonRelease: @@ -211,7 +200,7 @@ int GetMouseEventFlags(XEvent* xev) { case XI_ButtonRelease: return GetButtonMaskForX2Event(xievent) | GetEventFlagsFromXState(xievent->mods.effective) | - GetEventFlagsForButton(xievent->detail); + (touch ? 0 : GetEventFlagsForButton(xievent->detail)); case XI_Motion: return GetButtonMaskForX2Event(xievent) | @@ -243,9 +232,9 @@ LocatedEvent::LocatedEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native) : Event(native_event_2, EventTypeFromNative(native_event_2), - GetEventFlagsFromXState(native_event_2->xbutton.state), + GetLocatedEventFlags(native_event_2, false), from_native), - location_(GetMouseEventLocation(native_event_2)) { + location_(GetEventLocation(native_event_2)) { } //////////////////////////////////////////////////////////////////////////////// @@ -283,8 +272,8 @@ MouseWheelEvent::MouseWheelEvent(NativeEvent2 native_event_2, TouchEvent::TouchEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native) : LocatedEvent(GetTouchEventType(native_event_2), - GetTouchEventLocation(native_event_2), - GetTouchEventFlags(native_event_2)), + GetEventLocation(native_event_2), + GetLocatedEventFlags(native_event_2, true)), touch_id_(GetTouchIDFromXEvent(native_event_2)) { } #endif |