diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/event.h | 4 | ||||
-rw-r--r-- | views/event_x.cc | 10 | ||||
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 18 |
3 files changed, 26 insertions, 6 deletions
diff --git a/views/event.h b/views/event.h index 89909b5..ab9abf3 100644 --- a/views/event.h +++ b/views/event.h @@ -381,6 +381,10 @@ class MouseWheelEvent : public LocatedEvent { offset_(offset) { } +#if defined(TOUCH_UI) + explicit MouseWheelEvent(XEvent* xev); +#endif + int GetOffset() const { return offset_; } diff --git a/views/event_x.cc b/views/event_x.cc index 7f6e7b1..60b0d2f 100644 --- a/views/event_x.cc +++ b/views/event_x.cc @@ -25,6 +25,8 @@ int GetEventFlagsFromXState(unsigned int state) { flags |= Event::EF_SHIFT_DOWN; if (state & Mod1Mask) flags |= Event::EF_ALT_DOWN; + if (state & LockMask) + flags |= Event::EF_CAPS_LOCK_DOWN; if (state & Button1Mask) flags |= Event::EF_LEFT_BUTTON_DOWN; if (state & Button2Mask) @@ -172,4 +174,12 @@ MouseEvent::MouseEvent(XEvent* xev) GetMouseEventFlags(xev)) { } +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+. +} + } // namespace views diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index a07b977..aa971d5 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -132,13 +132,19 @@ bool DispatchXEvent(XEvent* xev) { case ButtonPress: case ButtonRelease: { - MouseEvent mouseev(xev); - if (xev->type == ButtonPress) { - return root->OnMousePressed(mouseev); + if (xev->xbutton.button == 4 || xev->xbutton.button == 5) { + // Scrolling the wheel triggers button press/release events. + MouseWheelEvent wheelev(xev); + return root->ProcessMouseWheelEvent(wheelev); } else { - root->OnMouseReleased(mouseev, false); - return true; // Assume the event has been processed to make sure we - // don't process it twice. + MouseEvent mouseev(xev); + if (xev->type == ButtonPress) { + return root->OnMousePressed(mouseev); + } else { + root->OnMouseReleased(mouseev, false); + return true; // Assume the event has been processed to make sure we + // don't process it twice. + } } } |