From 7cdc19d57f39127e8460e34b89f8d765cf4d5374 Mon Sep 17 00:00:00 2001 From: "D.B" Date: Fri, 13 Oct 2017 22:50:59 +0200 Subject: [PATCH] Fix duplicated pointer axis events In pointer.c, some axis event was emitted even if the event pointer did not have current axis. In X11 backend pointer scroll events seem to be composed of both BUTTON_PRESS and BUTTON_RELEASE. Therefore we should skip one of them (RELEASE) to avoid event duplication. --- backend/libinput/pointer.c | 2 +- backend/x11/backend.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 005c9516..ad9b8f02 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -128,7 +128,7 @@ void handle_pointer_axis(struct libinput_event *event, } wlr_event.delta = libinput_event_pointer_get_axis_value( pevent, axies[i]); + wl_signal_emit(&wlr_dev->pointer->events.axis, &wlr_event); } - wl_signal_emit(&wlr_dev->pointer->events.axis, &wlr_event); } } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index bcc2e970..11dd8568 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -63,8 +63,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e x11->time = ev->time; break; } - case XCB_BUTTON_PRESS: - case XCB_BUTTON_RELEASE: { + case XCB_BUTTON_PRESS: { xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event; if (ev->detail == XCB_BUTTON_INDEX_4 || @@ -79,7 +78,16 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e .delta = delta, }; wl_signal_emit(&x11->pointer.events.axis, &axis); - } else { + x11->time = ev->time; + break; + } + } + /* fallthrough */ + 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) { struct wlr_event_pointer_button button = { .device = &x11->pointer_dev, .time_sec = ev->time / 1000,