[client,X11] fix detection of need to use relative movements

Register XI raw masks when MouseUseRelativeMove enabled
Fix duplication of sent events (in previous implementation relative and absolute events were sent at the same time)
Slightly refactor code
This commit is contained in:
sasha0552 2024-03-23 01:39:45 +00:00 committed by akallabeth
parent 8bd1e72dd4
commit d864393a8a
2 changed files with 23 additions and 15 deletions

View File

@ -450,7 +450,8 @@ static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOO
{
WINPR_ASSERT(xfc);
if (xfc->xi_event)
if (xfc->xi_event ||
(xfc->common.mouse_grabbed && freerdp_client_use_relative_mouse_events(&xfc->common)))
return TRUE;
if (xfc->window)
@ -559,7 +560,8 @@ static BOOL xf_event_ButtonPress(xfContext* xfc, const XButtonEvent* event, BOOL
{
xf_grab_mouse(xfc);
if (xfc->xi_event)
if (xfc->xi_event ||
(xfc->common.mouse_grabbed && freerdp_client_use_relative_mouse_events(&xfc->common)))
return TRUE;
return xf_generic_ButtonEvent(xfc, event->x, event->y, event->button, event->window, app, TRUE);
}
@ -568,7 +570,8 @@ static BOOL xf_event_ButtonRelease(xfContext* xfc, const XButtonEvent* event, BO
{
xf_grab_mouse(xfc);
if (xfc->xi_event)
if (xfc->xi_event ||
(xfc->common.mouse_grabbed && freerdp_client_use_relative_mouse_events(&xfc->common)))
return TRUE;
return xf_generic_ButtonEvent(xfc, event->x, event->y, event->button, event->window, app,
FALSE);

View File

@ -200,7 +200,7 @@ static BOOL register_raw_events(xfContext* xfc, Window window)
settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
if (freerdp_client_use_relative_mouse_events(&xfc->common))
if (freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove))
{
XISetMask(mask_bytes, XI_RawMotion);
XISetMask(mask_bytes, XI_RawButtonPress);
@ -780,21 +780,26 @@ int xf_input_event(xfContext* xfc, const XEvent* xevent, XIDeviceEvent* event, i
switch (evtype)
{
case XI_ButtonPress:
xfc->xi_event = TRUE;
xf_generic_ButtonEvent(xfc, (int)event->event_x, (int)event->event_y, event->detail,
event->event, xfc->remote_app, TRUE);
break;
case XI_ButtonRelease:
xfc->xi_event = TRUE;
xf_generic_ButtonEvent(xfc, (int)event->event_x, (int)event->event_y, event->detail,
event->event, xfc->remote_app, FALSE);
xfc->xi_event = !xfc->common.mouse_grabbed ||
!freerdp_client_use_relative_mouse_events(&xfc->common);
if (xfc->xi_event)
{
xf_generic_ButtonEvent(xfc, (int)event->event_x, (int)event->event_y, event->detail,
event->event, xfc->remote_app, evtype == XI_ButtonPress);
}
break;
case XI_Motion:
xfc->xi_event = TRUE;
xf_generic_MotionNotify(xfc, (int)event->event_x, (int)event->event_y, event->detail,
event->event, xfc->remote_app);
xfc->xi_event = !xfc->common.mouse_grabbed ||
!freerdp_client_use_relative_mouse_events(&xfc->common);
if (xfc->xi_event)
{
xf_generic_MotionNotify(xfc, (int)event->event_x, (int)event->event_y,
event->detail, event->event, xfc->remote_app);
}
break;
case XI_RawButtonPress:
case XI_RawButtonRelease: