Skip to content

Commit

Permalink
Handle WM_MOUSERELMOVE event
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored May 26, 2024
1 parent b2f99d9 commit 638b756
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions module/rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ struct _rdpPointer
DeviceIntPtr device;
int old_cursor_x;
int old_cursor_y;
int is_absolute;
int cursor_delta_x;
int cursor_delta_y;
};
typedef struct _rdpPointer rdpPointer;

Expand Down
28 changes: 21 additions & 7 deletions xrdpmouse/rdpMouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ l_bound_by(int val, int low, int high)

/******************************************************************************/
static void
rdpEnqueueMotion(DeviceIntPtr device, int x, int y)
rdpEnqueueMotion(DeviceIntPtr device, int is_absolute, int x, int y)
{
LLOGLN(10, ("rdpEnqueueMotion:"));
xf86PostMotionEvent(device, TRUE, 0, 2, x, y);
xf86PostMotionEvent(device, is_absolute, 0, 2, x, y);
}

/******************************************************************************/
Expand All @@ -123,12 +123,19 @@ PtrAddEvent(rdpPointer *pointer)

LLOGLN(10, ("PtrAddEvent: x %d y %d", pointer->cursor_x, pointer->cursor_y));

if ((pointer->old_cursor_x != pointer->cursor_x) ||
(pointer->old_cursor_y != pointer->cursor_y))
if (pointer->is_absolute)
{
rdpEnqueueMotion(pointer->device, pointer->cursor_x, pointer->cursor_y);
pointer->old_cursor_x = pointer->cursor_x;
pointer->old_cursor_y = pointer->cursor_y;
if ((pointer->old_cursor_x != pointer->cursor_x) ||
(pointer->old_cursor_y != pointer->cursor_y))
{
rdpEnqueueMotion(pointer->device, pointer->is_absolute, pointer->cursor_x, pointer->cursor_y);
pointer->old_cursor_x = pointer->cursor_x;
pointer->old_cursor_y = pointer->cursor_y;
}
}
else
{
rdpEnqueueMotion(pointer->device, pointer->is_absolute, pointer->cursor_delta_x, pointer->cursor_delta_y);
}

for (i = 0; i < NBUTTONS; i++)
Expand Down Expand Up @@ -203,6 +210,7 @@ rdpInputMouse(rdpPtr dev, int msg,
case WM_MOUSEMOVE:
/* without the minus 2, strange things happen when dragging
past the width or height */
pointer->is_absolute = TRUE;
pointer->cursor_x = l_bound_by(param1, 0, dev->width - 2);
pointer->cursor_y = l_bound_by(param2, 0, dev->height - 2);
PtrAddEvent(pointer);
Expand Down Expand Up @@ -279,6 +287,12 @@ rdpInputMouse(rdpPtr dev, int msg,
pointer->button_mask = pointer->button_mask | 256;
PtrAddEvent(pointer);
break;
case WM_MOUSERELMOVE:
pointer->is_absolute = FALSE;
pointer->cursor_delta_x = param1;
pointer->cursor_delta_y = param2;
PtrAddEvent(pointer);
break;
case WM_TOUCH_VSCROLL:
PtrAddScrollEvent(pointer, TRUE, param3);
break;
Expand Down

0 comments on commit 638b756

Please sign in to comment.