mfreerdp: fix termination of MacFreeRDP
This commit is contained in:
parent
3d339b04d9
commit
9921e519a9
@ -170,6 +170,7 @@ DWORD mac_client_thread(void* param)
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
freerdp* instance = context->instance;
|
||||
MRDPView* view = mfc->view;
|
||||
rdpSettings* settings = context->settings;
|
||||
|
||||
status = freerdp_connect(context->instance);
|
||||
|
||||
@ -185,17 +186,17 @@ DWORD mac_client_thread(void* param)
|
||||
|
||||
events[nCount++] = mfc->stopEvent;
|
||||
|
||||
if (instance->settings->AsyncUpdate)
|
||||
if (settings->AsyncUpdate)
|
||||
{
|
||||
events[nCount++] = update_event = freerdp_get_message_queue_event_handle(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
|
||||
}
|
||||
|
||||
if (instance->settings->AsyncInput)
|
||||
if (settings->AsyncInput)
|
||||
{
|
||||
events[nCount++] = input_event = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
}
|
||||
|
||||
if (instance->settings->AsyncChannels)
|
||||
if (settings->AsyncChannels)
|
||||
{
|
||||
events[nCount++] = channels_event = freerdp_channels_get_event_handle(instance);
|
||||
}
|
||||
@ -206,10 +207,11 @@ DWORD mac_client_thread(void* param)
|
||||
|
||||
if (WaitForSingleObject(mfc->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
freerdp_disconnect(instance);
|
||||
break;
|
||||
}
|
||||
|
||||
if (instance->settings->AsyncUpdate)
|
||||
if (settings->AsyncUpdate)
|
||||
{
|
||||
if (WaitForSingleObject(update_event, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
@ -217,7 +219,7 @@ DWORD mac_client_thread(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
if (instance->settings->AsyncInput)
|
||||
if (settings->AsyncInput)
|
||||
{
|
||||
if (WaitForSingleObject(input_event, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
@ -225,7 +227,7 @@ DWORD mac_client_thread(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
if (instance->settings->AsyncChannels)
|
||||
if (settings->AsyncChannels)
|
||||
{
|
||||
if (WaitForSingleObject(channels_event, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
|
@ -46,12 +46,12 @@ int mfreerdp_client_start(rdpContext* context)
|
||||
MRDPView* view;
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
|
||||
if (mfc->view == NULL)
|
||||
{
|
||||
// view not specified beforehand. Create view dynamically
|
||||
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, context->settings->DesktopWidth, context->settings->DesktopHeight)];
|
||||
mfc->view_ownership = TRUE;
|
||||
}
|
||||
if (mfc->view == NULL)
|
||||
{
|
||||
// view not specified beforehand. Create view dynamically
|
||||
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, context->settings->DesktopWidth, context->settings->DesktopHeight)];
|
||||
mfc->view_ownership = TRUE;
|
||||
}
|
||||
|
||||
view = (MRDPView*) mfc->view;
|
||||
[view rdpStart:context];
|
||||
@ -63,44 +63,21 @@ int mfreerdp_client_stop(rdpContext* context)
|
||||
{
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
|
||||
if (context->settings->AsyncUpdate)
|
||||
if (mfc->thread)
|
||||
{
|
||||
wMessageQueue* queue;
|
||||
queue = freerdp_get_message_queue(context->instance, FREERDP_UPDATE_MESSAGE_QUEUE);
|
||||
if (queue)
|
||||
{
|
||||
MessageQueue_PostQuit(queue, 0);
|
||||
}
|
||||
}
|
||||
else if (context->settings->AsyncInput)
|
||||
{
|
||||
wMessageQueue* queue;
|
||||
queue = freerdp_get_message_queue(context->instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
if (queue)
|
||||
{
|
||||
MessageQueue_PostQuit(queue, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mfc->disconnect = TRUE;
|
||||
}
|
||||
|
||||
if (mfc->thread)
|
||||
{
|
||||
SetEvent(mfc->stopEvent);
|
||||
WaitForSingleObject(mfc->thread, INFINITE);
|
||||
CloseHandle(mfc->thread);
|
||||
mfc->thread = NULL;
|
||||
}
|
||||
WaitForSingleObject(mfc->thread, INFINITE);
|
||||
CloseHandle(mfc->thread);
|
||||
mfc->thread = NULL;
|
||||
}
|
||||
|
||||
if (mfc->view_ownership)
|
||||
{
|
||||
MRDPView* view = (MRDPView*) mfc->view;
|
||||
[view releaseResources];
|
||||
[view release];
|
||||
mfc->view = nil;
|
||||
}
|
||||
if (mfc->view_ownership)
|
||||
{
|
||||
MRDPView* view = (MRDPView*) mfc->view;
|
||||
[view releaseResources];
|
||||
[view release];
|
||||
mfc->view = nil;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -112,22 +89,21 @@ int mfreerdp_client_new(freerdp* instance, rdpContext* context)
|
||||
|
||||
mfc = (mfContext*) instance->context;
|
||||
|
||||
mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
context->instance->PreConnect = mac_pre_connect;
|
||||
context->instance->PostConnect = mac_post_connect;
|
||||
context->instance->ReceiveChannelData = mac_receive_channel_data;
|
||||
context->instance->Authenticate = mac_authenticate;
|
||||
context->instance->PreConnect = mac_pre_connect;
|
||||
context->instance->PostConnect = mac_post_connect;
|
||||
context->instance->ReceiveChannelData = mac_receive_channel_data;
|
||||
context->instance->Authenticate = mac_authenticate;
|
||||
|
||||
context->channels = freerdp_channels_new();
|
||||
context->channels = freerdp_channels_new();
|
||||
|
||||
settings = instance->settings;
|
||||
|
||||
settings->AsyncUpdate = TRUE;
|
||||
settings->AsyncInput = TRUE;
|
||||
settings->AsyncUpdate = TRUE;
|
||||
settings->AsyncInput = TRUE;
|
||||
settings->AsyncChannels = TRUE;
|
||||
settings->AsyncTransport = TRUE;
|
||||
settings->RedirectClipboard = TRUE;
|
||||
|
||||
settings->OsMajorType = OSMAJORTYPE_MACINTOSH;
|
||||
settings->OsMinorType = OSMINORTYPE_MACINTOSH;
|
||||
@ -195,35 +171,35 @@ void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y)
|
||||
|
||||
void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
MRDPView* view = (MRDPView*) mfc->view;
|
||||
|
||||
int ww, wh, dw, dh;
|
||||
int ww, wh, dw, dh;
|
||||
|
||||
ww = mfc->client_width;
|
||||
wh = mfc->client_height;
|
||||
dw = mfc->context.settings->DesktopWidth;
|
||||
dh = mfc->context.settings->DesktopHeight;
|
||||
dh = mfc->context.settings->DesktopHeight;
|
||||
|
||||
// Convert to windows coordinates
|
||||
y = [view frame].size.height - y;
|
||||
|
||||
if (!mfc->context.settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
||||
{
|
||||
y = y + mfc->yCurrentScroll;
|
||||
if (!mfc->context.settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
||||
{
|
||||
y = y + mfc->yCurrentScroll;
|
||||
|
||||
if (wh != dh)
|
||||
{
|
||||
y -= (dh - wh);
|
||||
}
|
||||
if (wh != dh)
|
||||
{
|
||||
y -= (dh - wh);
|
||||
}
|
||||
|
||||
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = y * dh / wh + mfc->yCurrentScroll;
|
||||
input->MouseEvent(input, flags, x * dw / ww + mfc->xCurrentScroll, y);
|
||||
}
|
||||
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = y * dh / wh + mfc->yCurrentScroll;
|
||||
input->MouseEvent(input, flags, x * dw / ww + mfc->xCurrentScroll, y);
|
||||
}
|
||||
}
|
||||
|
||||
int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||
|
@ -977,7 +977,7 @@ static void* transport_client_thread(void* arg)
|
||||
|
||||
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
WLog_Print(transport->log, WLOG_DEBUG, "Terminating transport thread");
|
||||
ExitThread(0);
|
||||
@ -995,7 +995,7 @@ static void* transport_client_thread(void* arg)
|
||||
|
||||
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
if (!freerdp_check_fds(instance))
|
||||
|
Loading…
Reference in New Issue
Block a user