diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index aa08586bc..ec40d110c 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -50,6 +50,12 @@ #include "pointer-gestures-unstable-v1-client-protocol.h" #include "xwayland-keyboard-grab-unstable-v1-client-protocol.h" +struct axis_discrete_pending { + struct xorg_list l; + uint32_t axis; + int32_t discrete; +}; + struct sync_pending { struct xorg_list l; DeviceIntPtr pending_dev; @@ -607,36 +613,6 @@ dispatch_relative_motion(struct xwl_seat *xwl_seat) POINTER_RAWONLY, &mask); } -static void -dispatch_scroll_motion(struct xwl_seat *xwl_seat) -{ - ValuatorMask mask; - const int divisor = 10; - wl_fixed_t dy = xwl_seat->pending_pointer_event.scroll_dy; - wl_fixed_t dx = xwl_seat->pending_pointer_event.scroll_dx; - int32_t discrete_dy = xwl_seat->pending_pointer_event.scroll_discrete_dy; - int32_t discrete_dx = xwl_seat->pending_pointer_event.scroll_discrete_dx; - - valuator_mask_zero(&mask); - if (xwl_seat->pending_pointer_event.has_vertical_scroll) - valuator_mask_set_double(&mask, - 3, - wl_fixed_to_double(dy) / divisor); - else if (xwl_seat->pending_pointer_event.has_vertical_scroll_discrete) - valuator_mask_set(&mask, 3, discrete_dy); - - if (xwl_seat->pending_pointer_event.has_horizontal_scroll) - valuator_mask_set_double(&mask, - 2, - wl_fixed_to_double(dx) / divisor); - else if (xwl_seat->pending_pointer_event.has_horizontal_scroll_discrete) - valuator_mask_set(&mask, 2, discrete_dx); - - QueuePointerEvents(get_pointer_device(xwl_seat), - MotionNotify, 0, POINTER_RELATIVE, &mask); -} - - static void dispatch_pointer_motion_event(struct xwl_seat *xwl_seat) { @@ -653,18 +629,8 @@ dispatch_pointer_motion_event(struct xwl_seat *xwl_seat) dispatch_absolute_motion(xwl_seat); } - if (xwl_seat->pending_pointer_event.has_vertical_scroll || - xwl_seat->pending_pointer_event.has_horizontal_scroll || - xwl_seat->pending_pointer_event.has_vertical_scroll_discrete || - xwl_seat->pending_pointer_event.has_horizontal_scroll_discrete) - dispatch_scroll_motion(xwl_seat); - xwl_seat->pending_pointer_event.has_absolute = FALSE; xwl_seat->pending_pointer_event.has_relative = FALSE; - xwl_seat->pending_pointer_event.has_vertical_scroll = FALSE; - xwl_seat->pending_pointer_event.has_horizontal_scroll = FALSE; - xwl_seat->pending_pointer_event.has_vertical_scroll_discrete = FALSE; - xwl_seat->pending_pointer_event.has_horizontal_scroll_discrete = FALSE; } static void @@ -721,17 +687,42 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { struct xwl_seat *xwl_seat = data; + int index; + const int divisor = 10; + ValuatorMask mask; + struct axis_discrete_pending *pending = NULL; + struct axis_discrete_pending *iter; switch (axis) { case WL_POINTER_AXIS_VERTICAL_SCROLL: - xwl_seat->pending_pointer_event.has_vertical_scroll = TRUE; - xwl_seat->pending_pointer_event.scroll_dy = value; + index = 3; break; case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - xwl_seat->pending_pointer_event.has_horizontal_scroll = TRUE; - xwl_seat->pending_pointer_event.scroll_dx = value; + index = 2; break; + default: + return; } + + xorg_list_for_each_entry(iter, &xwl_seat->axis_discrete_pending, l) { + if (iter->axis == axis) { + pending = iter; + break; + } + } + + valuator_mask_zero(&mask); + + if (pending) { + valuator_mask_set(&mask, index, pending->discrete); + xorg_list_del(&pending->l); + free(pending); + } else { + valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor); + } + + QueuePointerEvents(get_pointer_device(xwl_seat), + MotionNotify, 0, POINTER_RELATIVE, &mask); } static void @@ -754,18 +745,6 @@ static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis) { - struct xwl_seat *xwl_seat = data; - - switch (axis) { - case WL_POINTER_AXIS_VERTICAL_SCROLL: - xwl_seat->pending_pointer_event.has_vertical_scroll = TRUE; - xwl_seat->pending_pointer_event.scroll_dy = 0; - break; - case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - xwl_seat->pending_pointer_event.has_horizontal_scroll = TRUE; - xwl_seat->pending_pointer_event.scroll_dx = 0; - break; - } } static void @@ -774,16 +753,14 @@ pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer, { struct xwl_seat *xwl_seat = data; - switch (axis) { - case WL_POINTER_AXIS_VERTICAL_SCROLL: - xwl_seat->pending_pointer_event.has_vertical_scroll_discrete = TRUE; - xwl_seat->pending_pointer_event.scroll_discrete_dy = discrete; - break; - case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - xwl_seat->pending_pointer_event.has_horizontal_scroll_discrete = TRUE; - xwl_seat->pending_pointer_event.scroll_discrete_dx = discrete; - break; - } + struct axis_discrete_pending *pending = malloc(sizeof *pending); + if (!pending) + return; + + pending->axis = axis; + pending->discrete = discrete; + + xorg_list_add(&pending->l, &xwl_seat->axis_discrete_pending); } static const struct wl_pointer_listener pointer_listener = { @@ -1759,6 +1736,7 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version wl_array_init(&xwl_seat->keys); xorg_list_init(&xwl_seat->touches); + xorg_list_init(&xwl_seat->axis_discrete_pending); xorg_list_init(&xwl_seat->sync_pending); } @@ -1767,6 +1745,7 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat) { struct xwl_touch *xwl_touch, *next_xwl_touch; struct sync_pending *p, *npd; + struct axis_discrete_pending *ad, *ad_next; xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch, &xwl_seat->touches, link_touch) { @@ -1779,6 +1758,11 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat) free (p); } + xorg_list_for_each_entry_safe(ad, ad_next, &xwl_seat->axis_discrete_pending, l) { + xorg_list_del(&ad->l); + free(ad); + } + release_tablet_manager_seat(xwl_seat); release_grab(xwl_seat); diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h index 4fd175b13..dbe215bdb 100644 --- a/hw/xwayland/xwayland-input.h +++ b/hw/xwayland/xwayland-input.h @@ -93,6 +93,7 @@ struct xwl_seat { char *keymap; struct wl_surface *keyboard_focus; + struct xorg_list axis_discrete_pending; struct xorg_list sync_pending; struct xwl_pointer_warp_emulator *pointer_warp_emulator; @@ -110,15 +111,6 @@ struct xwl_seat { double dy; double dx_unaccel; double dy_unaccel; - - wl_fixed_t scroll_dy; - wl_fixed_t scroll_dx; - int32_t scroll_discrete_dy; - int32_t scroll_discrete_dx; - Bool has_vertical_scroll; - Bool has_horizontal_scroll; - Bool has_vertical_scroll_discrete; - Bool has_horizontal_scroll_discrete; } pending_pointer_event; struct xorg_list tablets;