Merge pull request #240 from acrisci/feature/x11-backend-axis

x11-backend: axis events
This commit is contained in:
Drew DeVault 2017-10-08 10:01:22 -04:00 committed by GitHub
commit 2f36e78de1
1 changed files with 24 additions and 9 deletions

View File

@ -62,6 +62,20 @@ 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;
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,
@ -72,6 +86,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
};
wl_signal_emit(&x11->pointer.events.button, &button);
}
x11->time = ev->time;
break;
}