Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS-RDPBCGR] Relative mouse input #314

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading