[libfreerdp] final freerdp_prevent_session_lock() implementation
Injects fake mouse movement when idle
This commit is contained in:
parent
90f82bf418
commit
550ba7fe34
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
@ -393,6 +394,46 @@ DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events, DWORD count
|
|||||||
return nCount;
|
return nCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Resend mouse cursor position to prevent session lock in prevent-session-lock mode */
|
||||||
|
static BOOL freerdp_prevent_session_lock(rdpContext* context)
|
||||||
|
{
|
||||||
|
WINPR_ASSERT(context);
|
||||||
|
WINPR_ASSERT(context->input);
|
||||||
|
|
||||||
|
rdp_input_internal* in = input_cast(context->input);
|
||||||
|
|
||||||
|
UINT32 FakeMouseMotionInterval =
|
||||||
|
freerdp_settings_get_uint32(context->settings, FreeRDP_FakeMouseMotionInterval);
|
||||||
|
if (FakeMouseMotionInterval && in->lastInputTimestamp)
|
||||||
|
{
|
||||||
|
struct timespec ts = { 0 };
|
||||||
|
if (timespec_get(&ts, TIME_UTC) == 0)
|
||||||
|
return FALSE;
|
||||||
|
if (ts.tv_sec - in->lastInputTimestamp > FakeMouseMotionInterval)
|
||||||
|
{
|
||||||
|
WLog_Print(context->log, WLOG_DEBUG,
|
||||||
|
"fake mouse move: x=%d y=%d lastInputTimestamp=%d "
|
||||||
|
"FakeMouseMotionInterval=%d",
|
||||||
|
in->lastX, in->lastY, in->lastInputTimestamp, FakeMouseMotionInterval);
|
||||||
|
|
||||||
|
BOOL status = freerdp_input_send_mouse_event(context->input, PTR_FLAGS_MOVE, in->lastX,
|
||||||
|
in->lastY);
|
||||||
|
if (!status)
|
||||||
|
{
|
||||||
|
if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
|
||||||
|
WLog_Print(context->log, WLOG_ERROR,
|
||||||
|
"freerdp_prevent_session_lock() failed - %" PRIi32 "", status);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL freerdp_check_event_handles(rdpContext* context)
|
BOOL freerdp_check_event_handles(rdpContext* context)
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(context);
|
WINPR_ASSERT(context);
|
||||||
@ -430,6 +471,8 @@ BOOL freerdp_check_event_handles(rdpContext* context)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = freerdp_prevent_session_lock(context);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user