[client,common] check for relative mouse events

Added freerdp_client_use_relative_mouse_events to tell the client if the
coordinates should be relative or absolute
This commit is contained in:
Armin Novak 2023-12-06 10:03:27 +01:00 committed by David Fort
parent c8b142a10f
commit 6f6c0248f0
4 changed files with 27 additions and 9 deletions

View File

@ -202,8 +202,7 @@ BOOL sdl_handle_mouse_motion(SdlContext* sdl, const SDL_MouseMotionEvent* ev)
WINPR_ASSERT(ev);
sdl->input.mouse_focus(ev->windowID);
const BOOL relative =
freerdp_settings_get_bool(sdl->context()->settings, FreeRDP_MouseUseRelativeMove);
const BOOL relative = freerdp_client_use_relative_mouse_events(sdl->common());
INT32 x = relative ? ev->xrel : ev->x;
INT32 y = relative ? ev->yrel : ev->y;
sdl_scale_coordinates(sdl, ev->windowID, &x, &y, TRUE, TRUE);
@ -269,8 +268,7 @@ BOOL sdl_handle_mouse_button(SdlContext* sdl, const SDL_MouseButtonEvent* ev)
break;
}
const BOOL relative =
freerdp_settings_get_bool(sdl->context()->settings, FreeRDP_MouseUseRelativeMove);
const BOOL relative = freerdp_client_use_relative_mouse_events(sdl->common());
INT32 x = relative ? 0 : ev->x;
INT32 y = relative ? 0 : ev->y;
sdl_scale_coordinates(sdl, ev->windowID, &x, &y, TRUE, TRUE);

View File

@ -198,7 +198,7 @@ static BOOL register_raw_events(xfContext* xfc, Window window)
settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
if (freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove))
if (freerdp_client_use_relative_mouse_events(&xfc->common))
{
XISetMask(mask_bytes, XI_RawMotion);
XISetMask(mask_bytes, XI_RawButtonPress);
@ -798,8 +798,8 @@ int xf_input_event(xfContext* xfc, const XEvent* xevent, XIDeviceEvent* event, i
break;
case XI_RawButtonPress:
case XI_RawButtonRelease:
xfc->xi_rawevent = xfc->common.mouse_grabbed &&
freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove);
xfc->xi_rawevent =
xfc->common.mouse_grabbed && freerdp_client_use_relative_mouse_events(&xfc->common);
if (xfc->xi_rawevent)
{
@ -809,8 +809,8 @@ int xf_input_event(xfContext* xfc, const XEvent* xevent, XIDeviceEvent* event, i
}
break;
case XI_RawMotion:
xfc->xi_rawevent = xfc->common.mouse_grabbed &&
freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove);
xfc->xi_rawevent =
xfc->common.mouse_grabbed && freerdp_client_use_relative_mouse_events(&xfc->common);
if (xfc->xi_rawevent)
{

View File

@ -2132,3 +2132,14 @@ BOOL freerdp_client_is_pen(rdpClientContext* cctx, INT32 deviceid)
return FALSE;
}
BOOL freerdp_client_use_relative_mouse_events(rdpClientContext* ccontext)
{
WINPR_ASSERT(ccontext);
const rdpSettings* settings = ccontext->context.settings;
const BOOL useRelative = freerdp_settings_get_bool(settings, FreeRDP_MouseUseRelativeMove);
const BOOL haveRelative = freerdp_settings_get_bool(settings, FreeRDP_HasRelativeMouseEvent);
const BOOL ainput = ccontext->ainput != NULL;
return useRelative && (haveRelative || ainput);
}

View File

@ -267,6 +267,15 @@ extern "C"
FREERDP_API BOOL freerdp_client_send_mouse_event(rdpClientContext* cctx, UINT64 mflags, INT32 x,
INT32 y);
/** @brief this function checks if relative mouse events are supported and enabled for this
* session.
*
* @param cctx The \b rdpClientContext to check
*
* @return \b TRUE if relative mouse events are to be sent, \b FALSE otherwise
*/
FREERDP_API BOOL freerdp_client_use_relative_mouse_events(rdpClientContext* cctx);
FREERDP_API BOOL freerdp_client_send_button_event(rdpClientContext* cctx, BOOL relative,
UINT16 mflags, INT32 x, INT32 y);