[pointer] unify mouse pointer settings

This commit is contained in:
akallabeth 2023-06-26 15:39:27 +02:00 committed by akallabeth
parent 132ce797db
commit 32b60ae438
6 changed files with 64 additions and 32 deletions

View File

@ -149,19 +149,15 @@ static BOOL wlf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
BOOL wlf_register_pointer(rdpGraphics* graphics) BOOL wlf_register_pointer(rdpGraphics* graphics)
{ {
rdpPointer* pointer = NULL; rdpPointer pointer = { 0 };
if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer)))) pointer.size = sizeof(wlfPointer);
return FALSE; pointer.New = wlf_Pointer_New;
pointer.Free = wlf_Pointer_Free;
pointer->size = sizeof(wlfPointer); pointer.Set = wlf_Pointer_Set;
pointer->New = wlf_Pointer_New; pointer.SetNull = wlf_Pointer_SetNull;
pointer->Free = wlf_Pointer_Free; pointer.SetDefault = wlf_Pointer_SetDefault;
pointer->Set = wlf_Pointer_Set; pointer.SetPosition = wlf_Pointer_SetPosition;
pointer->SetNull = wlf_Pointer_SetNull; graphics_register_pointer(graphics, &pointer);
pointer->SetDefault = wlf_Pointer_SetDefault;
pointer->SetPosition = wlf_Pointer_SetPosition;
graphics_register_pointer(graphics, pointer);
free(pointer);
return TRUE; return TRUE;
} }

View File

@ -723,20 +723,16 @@ static BOOL xf_Glyph_EndDraw(rdpContext* context, INT32 x, INT32 y, INT32 width,
/* Graphics Module */ /* Graphics Module */
BOOL xf_register_pointer(rdpGraphics* graphics) BOOL xf_register_pointer(rdpGraphics* graphics)
{ {
rdpPointer* pointer = NULL; rdpPointer pointer = { 0 };
if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer)))) pointer.size = sizeof(xfPointer);
return FALSE; pointer.New = xf_Pointer_New;
pointer.Free = xf_Pointer_Free;
pointer->size = sizeof(xfPointer); pointer.Set = xf_Pointer_Set;
pointer->New = xf_Pointer_New; pointer.SetNull = xf_Pointer_SetNull;
pointer->Free = xf_Pointer_Free; pointer.SetDefault = xf_Pointer_SetDefault;
pointer->Set = xf_Pointer_Set; pointer.SetPosition = xf_Pointer_SetPosition;
pointer->SetNull = xf_Pointer_SetNull; graphics_register_pointer(graphics, &pointer);
pointer->SetDefault = xf_Pointer_SetDefault;
pointer->SetPosition = xf_Pointer_SetPosition;
graphics_register_pointer(graphics, pointer);
free(pointer);
return TRUE; return TRUE;
} }

View File

@ -4012,6 +4012,42 @@ static int freerdp_client_settings_parse_command_line_arguments_int(rdpSettings*
{ {
settings->MouseUseRelativeMove = enable; settings->MouseUseRelativeMove = enable;
} }
CommandLineSwitchCase(arg, "mouse")
{
size_t count = 0;
char** ptr = CommandLineParseCommaSeparatedValuesEx("mouse", arg->Value, &count);
UINT rc = 0;
if (ptr)
{
for (size_t x = 1; x < count; x++)
{
const char* cur = ptr[x];
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
if (bval == PARSE_FAIL)
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
else
{
const BOOL val = bval != PARSE_OFF;
size_t key = 0;
if (option_starts_with("relative", cur))
key = FreeRDP_MouseUseRelativeMove;
else if (option_starts_with("grab", cur))
key = FreeRDP_GrabMouse;
if (!freerdp_settings_set_bool(settings, key, val))
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
if (rc != 0)
break;
}
}
free(ptr);
if (rc != 0)
return rc;
}
CommandLineSwitchCase(arg, "unmap-buttons") CommandLineSwitchCase(arg, "unmap-buttons")
{ {
settings->UnmapButtons = enable; settings->UnmapButtons = enable;

View File

@ -311,6 +311,11 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = {
"Send mouse motion" }, "Send mouse motion" },
{ "mouse-relative", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "mouse-relative", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL,
"Send mouse motion with relative addressing" }, "Send mouse motion with relative addressing" },
{ "mouse", COMMAND_LINE_VALUE_REQUIRED, "[relative:[on|off],grab:[on|off]]", NULL, NULL, -1,
NULL,
"Mouse related options:"
"* relative: send relative mouse movements if supported by server"
"* grab: grab the mouse if within the window" },
#if defined(CHANNEL_TSMF_CLIENT) #if defined(CHANNEL_TSMF_CLIENT)
{ "multimedia", COMMAND_LINE_VALUE_OPTIONAL, "[sys:<sys>,][dev:<dev>,][decoder:<decoder>]", { "multimedia", COMMAND_LINE_VALUE_OPTIONAL, "[sys:<sys>,][dev:<dev>,][decoder:<decoder>]",
NULL, NULL, -1, "mmr", "[DEPRECATED], use /video] Redirect multimedia (video)" }, NULL, NULL, -1, "mmr", "[DEPRECATED], use /video] Redirect multimedia (video)" },

View File

@ -184,7 +184,7 @@ static BOOL ios_Pointer_SetDefault(rdpContext *context)
static BOOL ios_register_pointer(rdpGraphics *graphics) static BOOL ios_register_pointer(rdpGraphics *graphics)
{ {
rdpPointer pointer; rdpPointer pointer = { 0 };
if (!graphics) if (!graphics)
return FALSE; return FALSE;

View File

@ -63,18 +63,17 @@ static void pointer_free(rdpContext* context, rdpPointer* pointer)
static BOOL update_pointer_position(rdpContext* context, static BOOL update_pointer_position(rdpContext* context,
const POINTER_POSITION_UPDATE* pointer_position) const POINTER_POSITION_UPDATE* pointer_position)
{ {
rdpPointer* pointer;
BOOL GrabMouse;
if (!context || !context->graphics || !context->graphics->Pointer_Prototype || if (!context || !context->graphics || !context->graphics->Pointer_Prototype ||
!pointer_position) !pointer_position)
return FALSE; return FALSE;
GrabMouse = freerdp_settings_get_bool(context->settings, FreeRDP_GrabMouse); const BOOL GrabMouse = freerdp_settings_get_bool(context->settings, FreeRDP_GrabMouse);
if (!GrabMouse) if (!GrabMouse)
return TRUE; return TRUE;
pointer = context->graphics->Pointer_Prototype; const rdpPointer* pointer = context->graphics->Pointer_Prototype;
WINPR_ASSERT(pointer);
return IFCALLRESULT(TRUE, pointer->SetPosition, context, pointer_position->xPos, return IFCALLRESULT(TRUE, pointer->SetPosition, context, pointer_position->xPos,
pointer_position->yPos); pointer_position->yPos);
} }