diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-10-08 10:01:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-08 10:01:22 -0400 |
commit | 2f36e78de1da5ca8ef3a975674b02bcc988cd06a (patch) | |
tree | 3ee586f8039d111baafb228bb2065db43336a91f | |
parent | e3342927a34c709e5c7edc56c3c1c80e92550897 (diff) | |
parent | 6d9b4f330e2ff6c84663031d9a3071df919eb205 (diff) |
Merge pull request #240 from acrisci/feature/x11-backend-axis
x11-backend: axis events
-rw-r--r-- | backend/x11/backend.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c index a8a18f8e..1eb5a952 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -62,16 +62,31 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: { xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event; - struct wlr_event_pointer_button button = { - .device = &x11->pointer_dev, - .time_sec = ev->time / 1000, - .time_usec = ev->time * 1000, - .button = xcb_button_to_wl(ev->detail), - .state = event->response_type == XCB_BUTTON_PRESS ? - WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED, - }; - wl_signal_emit(&x11->pointer.events.button, &button); + if (ev->detail == XCB_BUTTON_INDEX_4 || + ev->detail == XCB_BUTTON_INDEX_5) { + double delta = (ev->detail == XCB_BUTTON_INDEX_4 ? -15 : 15); + struct wlr_event_pointer_axis axis = { + .device = &x11->pointer_dev, + .time_sec = ev->time / 1000, + .time_usec = ev->time * 1000, + .source = WLR_AXIS_SOURCE_WHEEL, + .orientation = WLR_AXIS_ORIENTATION_VERTICAL, + .delta = delta, + }; + wl_signal_emit(&x11->pointer.events.axis, &axis); + } else { + struct wlr_event_pointer_button button = { + .device = &x11->pointer_dev, + .time_sec = ev->time / 1000, + .time_usec = ev->time * 1000, + .button = xcb_button_to_wl(ev->detail), + .state = event->response_type == XCB_BUTTON_PRESS ? + WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED, + }; + + wl_signal_emit(&x11->pointer.events.button, &button); + } x11->time = ev->time; break; } |