diff options
author | sadrul@google.com <sadrul@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 02:39:02 +0000 |
---|---|---|
committer | sadrul@google.com <sadrul@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 02:39:02 +0000 |
commit | 922ed27ba30b69a5e83e8719145997af5953697e (patch) | |
tree | 755c2710ff2c21a12a958e3ac37690c5bbc7d2be /views | |
parent | 1e46a12cf34dbf71d6a07bc3f7bab666b01565a7 (diff) | |
download | chromium_src-922ed27ba30b69a5e83e8719145997af5953697e.zip chromium_src-922ed27ba30b69a5e83e8719145997af5953697e.tar.gz chromium_src-922ed27ba30b69a5e83e8719145997af5953697e.tar.bz2 |
touch: Fix wheel scrolling for xinput2.
BUG=wheel scrolling doesn't work
TEST=wheel scrolling scrolls the page when possible
Review URL: http://codereview.chromium.org/6250195
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/event_x.cc | 16 | ||||
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 8 |
2 files changed, 22 insertions, 2 deletions
diff --git a/views/event_x.cc b/views/event_x.cc index c9ead16..dddcd2f 100644 --- a/views/event_x.cc +++ b/views/event_x.cc @@ -17,6 +17,9 @@ namespace views { namespace { +// Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. +static int kWheelScrollAmount = 53; + int GetEventFlagsFromXState(unsigned int state) { int flags = 0; if (state & ControlMask) @@ -113,6 +116,16 @@ int GetTouchIDFromXEvent(XEvent* xev) { #endif // HAVE_XINPUT2 +int GetMouseWheelOffset(XEvent* xev) { +#if defined(HAVE_XINPUT2) + if (xev->type == GenericEvent) { + XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); + return xiev->detail == 4 ? kWheelScrollAmount : -kWheelScrollAmount; + } +#endif + return xev->xbutton.button == 4 ? kWheelScrollAmount : -kWheelScrollAmount; +} + Event::EventType GetMouseEventType(XEvent* xev) { switch (xev->type) { case ButtonPress: @@ -219,8 +232,7 @@ MouseWheelEvent::MouseWheelEvent(XEvent* xev) : LocatedEvent(Event::ET_MOUSEWHEEL, GetMouseEventLocation(xev), GetEventFlagsFromXState(xev->xbutton.state)), - offset_(xev->xbutton.button == 4 ? 53 : -53) { // '53' is also the value - // used for GTK+. + offset_(GetMouseWheelOffset(xev)) { } #if defined(HAVE_XINPUT2) diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index 4532034f..9847beb 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -87,6 +87,14 @@ bool DispatchX2Event(RootView* root, XEvent* xev) { case XI_ButtonPress: case XI_ButtonRelease: case XI_Motion: { + // Scrolling the wheel generates press/release events with button id's 4 + // and 5. In case of a wheelscroll, we do not want to show the cursor. + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); + if (xievent->detail == 4 || xievent->detail == 5) { + MouseWheelEvent wheelev(xev); + return root->ProcessMouseWheelEvent(wheelev); + } + MouseEvent mouseev(xev); if (!touch_event) { // Show the cursor, and decide whether or not the cursor should be |