Moved common async input handling to core library.
This commit is contained in:
parent
b8b84473a3
commit
f2d7766db6
@ -4,7 +4,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
classpath 'com.android.tools.build:gradle:2.1.3'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#Wed Jul 06 13:01:23 CEST 2016
|
||||
#Mon Sep 12 15:54:49 CEST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
|
@ -555,13 +555,6 @@ static int android_freerdp_run(freerdp* instance)
|
||||
|
||||
if (async_input)
|
||||
{
|
||||
if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE)))
|
||||
{
|
||||
WLog_ERR(TAG, "async input: failed to get input event handle");
|
||||
goto disconnect;
|
||||
}
|
||||
|
||||
if (!(inputThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) jni_input_thread, instance, 0, NULL)))
|
||||
{
|
||||
@ -576,10 +569,11 @@ static int android_freerdp_run(freerdp* instance)
|
||||
{
|
||||
DWORD tmp;
|
||||
count = 0;
|
||||
handles[count++] = inputEvent;
|
||||
|
||||
if (inputThread)
|
||||
handles[count++] = inputThread;
|
||||
else
|
||||
handles[count++] = inputEvent;
|
||||
|
||||
tmp = freerdp_get_event_handles(context, &handles[count], 64 - count);
|
||||
|
||||
@ -622,18 +616,6 @@ static int android_freerdp_run(freerdp* instance)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (inputEvent)
|
||||
{
|
||||
if (WaitForSingleObject(inputEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
if (!freerdp_message_queue_process_pending_messages(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE))
|
||||
{
|
||||
WLog_INFO(TAG, "User Disconnect");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disconnect:
|
||||
@ -641,15 +623,7 @@ disconnect:
|
||||
|
||||
if (async_input && inputThread)
|
||||
{
|
||||
wMessageQueue* input_queue = freerdp_get_message_queue(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
|
||||
if (input_queue)
|
||||
{
|
||||
if (MessageQueue_PostQuit(input_queue, 0))
|
||||
WaitForSingleObject(inputThread, INFINITE);
|
||||
}
|
||||
|
||||
CloseHandle(inputThread);
|
||||
}
|
||||
|
||||
|
@ -1315,7 +1315,7 @@ static void* xf_input_thread(void* arg)
|
||||
{
|
||||
DWORD status;
|
||||
DWORD nCount;
|
||||
HANDLE events[2];
|
||||
HANDLE events[3];
|
||||
XEvent xevent;
|
||||
wMessage msg;
|
||||
wMessageQueue* queue;
|
||||
@ -1327,6 +1327,7 @@ static void* xf_input_thread(void* arg)
|
||||
nCount = 0;
|
||||
events[nCount++] = MessageQueue_Event(queue);
|
||||
events[nCount++] = xfc->x11event;
|
||||
events[nCount++] = instance->context->abortEvent;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -1366,6 +1367,11 @@ static void* xf_input_thread(void* arg)
|
||||
if (!process_status)
|
||||
break;
|
||||
}
|
||||
|
||||
if (WaitForSingleObject(events[2], 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MessageQueue_PostQuit(queue, 0);
|
||||
@ -1408,7 +1414,7 @@ static BOOL xf_auto_reconnect(freerdp* instance)
|
||||
|
||||
if (freerdp_reconnect(instance))
|
||||
{
|
||||
xfc->disconnect = FALSE;
|
||||
freerdp_abort_connect(instance);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1485,17 +1491,10 @@ static void* xf_client_thread(void* param)
|
||||
if (!settings->AsyncInput)
|
||||
{
|
||||
inputEvent = xfc->x11event;
|
||||
handles[0] = inputEvent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE)))
|
||||
{
|
||||
WLog_ERR(TAG, "async input: failed to get input event handle");
|
||||
exit_code = XF_EXIT_UNKNOWN;
|
||||
goto disconnect;
|
||||
}
|
||||
|
||||
if (!(inputThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) xf_input_thread, instance, 0, NULL)))
|
||||
{
|
||||
@ -1505,7 +1504,7 @@ static void* xf_client_thread(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
while (!xfc->disconnect && !freerdp_shall_disconnect(instance))
|
||||
while (!freerdp_shall_disconnect(instance))
|
||||
{
|
||||
/*
|
||||
* win8 and server 2k12 seem to have some timing issue/race condition
|
||||
@ -1518,8 +1517,7 @@ static void* xf_client_thread(void* param)
|
||||
xf_keyboard_focus_in(xfc);
|
||||
}
|
||||
|
||||
nCount = 0;
|
||||
handles[nCount++] = inputEvent;
|
||||
nCount = (settings->AsyncInput) ? 0 : 1;
|
||||
|
||||
if (!settings->AsyncTransport)
|
||||
{
|
||||
@ -1556,29 +1554,11 @@ static void* xf_client_thread(void* param)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WaitForSingleObject(inputEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
if (!freerdp_message_queue_process_pending_messages(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE))
|
||||
{
|
||||
WLog_INFO(TAG, "User Disconnect");
|
||||
xfc->disconnect = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (settings->AsyncInput)
|
||||
{
|
||||
wMessageQueue* inputQueue = freerdp_get_message_queue(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
|
||||
if (MessageQueue_PostQuit(inputQueue, 0))
|
||||
WaitForSingleObject(inputThread, INFINITE);
|
||||
|
||||
CloseHandle(inputThread);
|
||||
}
|
||||
|
||||
@ -1611,21 +1591,7 @@ DWORD xf_exit_code_from_disconnect_reason(DWORD reason)
|
||||
|
||||
static void xf_TerminateEventHandler(rdpContext* context, TerminateEventArgs* e)
|
||||
{
|
||||
wMessageQueue* queue;
|
||||
xfContext* xfc = (xfContext*) context;
|
||||
|
||||
if (context->settings->AsyncInput)
|
||||
{
|
||||
queue = freerdp_get_message_queue(context->instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
|
||||
if (queue)
|
||||
MessageQueue_PostQuit(queue, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
xfc->disconnect = TRUE;
|
||||
}
|
||||
freerdp_abort_connect(context->instance);
|
||||
}
|
||||
|
||||
#ifdef WITH_XRENDER
|
||||
@ -1699,8 +1665,6 @@ static int xfreerdp_client_start(rdpContext* context)
|
||||
return -1;
|
||||
}
|
||||
|
||||
xfc->disconnect = FALSE;
|
||||
|
||||
if (!(xfc->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) xf_client_thread,
|
||||
context->instance, 0, NULL)))
|
||||
@ -1716,19 +1680,7 @@ static int xfreerdp_client_stop(rdpContext* context)
|
||||
{
|
||||
xfContext* xfc = (xfContext*) context;
|
||||
|
||||
if (context->settings->AsyncInput)
|
||||
{
|
||||
wMessageQueue* queue;
|
||||
queue = freerdp_get_message_queue(context->instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
|
||||
if (queue)
|
||||
MessageQueue_PostQuit(queue, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
xfc->disconnect = TRUE;
|
||||
}
|
||||
freerdp_abort_connect(context->instance);
|
||||
|
||||
if (xfc->thread)
|
||||
{
|
||||
|
@ -645,7 +645,7 @@ static UINT xf_rail_server_execute_result(RailClientContext* context,
|
||||
{
|
||||
WLog_ERR(TAG, "RAIL exec error: execResult=%s NtError=0x%X\n",
|
||||
error_code_names[execResult->execResult], execResult->rawResult);
|
||||
xfc->disconnect = TRUE;
|
||||
freerdp_abort_connect(xfc->context.instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -125,7 +125,6 @@ struct xf_context
|
||||
xfFullscreenMonitors fullscreenMonitors;
|
||||
int current_desktop;
|
||||
BOOL remote_app;
|
||||
BOOL disconnect;
|
||||
HANDLE mutex;
|
||||
BOOL UseXThreads;
|
||||
BOOL cursorHidden;
|
||||
|
@ -294,6 +294,14 @@ DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events,
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (context->settings->AsyncInput)
|
||||
{
|
||||
if (nCount >= count)
|
||||
return 0;
|
||||
events[nCount++] = freerdp_get_message_queue_event_handle(
|
||||
context->instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
}
|
||||
|
||||
return nCount;
|
||||
}
|
||||
|
||||
@ -320,6 +328,16 @@ BOOL freerdp_check_event_handles(rdpContext* context)
|
||||
return FALSE;
|
||||
|
||||
status = checkChannelErrorEvent(context);
|
||||
|
||||
if (!status)
|
||||
return FALSE;
|
||||
|
||||
if (context->settings->AsyncInput)
|
||||
{
|
||||
status = freerdp_message_queue_process_pending_messages(
|
||||
context->instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -404,6 +422,14 @@ BOOL freerdp_disconnect(freerdp* instance)
|
||||
rdp_client_disconnect(rdp);
|
||||
update_post_disconnect(instance->update);
|
||||
|
||||
if (instance->settings->AsyncInput)
|
||||
{
|
||||
wMessageQueue* inputQueue = freerdp_get_message_queue(instance,
|
||||
FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
|
||||
MessageQueue_PostQuit(inputQueue, 0);
|
||||
}
|
||||
|
||||
if (freerdp_channels_disconnect(instance->context->channels,
|
||||
instance) != CHANNEL_RC_OK)
|
||||
rc = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user