Added wayland discrete axis events for mouse wheel
authorakallabeth <akallabeth@posteo.net>
Wed, 27 Jan 2021 18:42:32 +0000 (19:42 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Thu, 25 Feb 2021 08:51:41 +0000 (09:51 +0100)
the discrete axis event gives changes in steps just like the
xfreerdp version uses. This way scrolling can be implemented
consistent with the behaviour of xfreerdp

(cherry picked from commit 2cce37a82a08b0a7c24302a6819371218dea1ec6)

client/Wayland/wlf_input.c
client/Wayland/wlfreerdp.c
uwac/include/uwac/uwac.h
uwac/libuwac/uwac-input.c

index 8dcbb5f..6a9b017 100644 (file)
@@ -137,9 +137,9 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
 {
        rdpInput* input;
        UINT16 flags = 0;
-       int direction;
-       uint32_t step;
+       int32_t direction;
        uint32_t x, y;
+       uint32_t i;
 
        if (!instance || !ev || !instance->input)
                return FALSE;
@@ -152,7 +152,7 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
 
        input = instance->input;
 
-       direction = wl_fixed_to_int(ev->value);
+       direction = ev->value;
        switch (ev->axis)
        {
                case WL_POINTER_AXIS_VERTICAL_SCROLL:
@@ -176,17 +176,14 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
         * positive: 0 ... 0xFF  -> slow ... fast
         * negative: 0 ... 0xFF  -> fast ... slow
         */
-       step = abs(direction);
-       if (step > 0xFF)
-               step = 0xFF;
-
-       /* Negative rotation, so count down steps from top */
-       if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
-               step = 0xFF - step;
-
-       flags |= step;
+       for (i = 0; i < abs(direction); i++)
+       {
+               const uint32_t cflags = flags | 0x78;
+               if (!freerdp_input_send_mouse_event(input, cflags, (UINT16)x, (UINT16)y))
+                       return FALSE;
+       }
 
-       return freerdp_input_send_mouse_event(input, flags, (UINT16)x, (UINT16)y);
+       return TRUE;
 }
 
 BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev)
index 4a58306..4e2f693 100644 (file)
@@ -356,6 +356,9 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
                                break;
 
                        case UWAC_EVENT_POINTER_AXIS:
+                               break;
+
+                       case UWAC_EVENT_POINTER_AXIS_DISCRETE:
                                if (!wlf_handle_pointer_axis(instance, &event.mouse_axis))
                                        return FALSE;
 
index ddda997..ae3452e 100644 (file)
@@ -104,6 +104,7 @@ enum
        UWAC_EVENT_CLIPBOARD_SELECT,
        UWAC_EVENT_CLIPBOARD_OFFER,
        UWAC_EVENT_OUTPUT_GEOMETRY,
+       UWAC_EVENT_POINTER_AXIS_DISCRETE
 };
 
 /** @brief window states */
index 482c79e..7a15e2e 100644 (file)
@@ -847,6 +847,24 @@ static void pointer_axis_discrete(void* data, struct wl_pointer* wl_pointer, uin
                                   int32_t discrete)
 {
        /*UwacSeat *seat = data;*/
+       UwacPointerAxisEvent* event;
+       UwacSeat* seat = data;
+       UwacWindow* window = seat->pointer_focus;
+
+       if (!window)
+               return;
+
+       event =
+           (UwacPointerAxisEvent*)UwacDisplayNewEvent(seat->display, UWAC_EVENT_POINTER_AXIS_DISCRETE);
+       if (!event)
+               return;
+
+       event->seat = seat;
+       event->window = window;
+       event->x = seat->sx;
+       event->y = seat->sy;
+       event->axis = axis;
+       event->value = discrete;
 }
 
 static const struct wl_pointer_listener pointer_listener = {