diff --git a/client/Android/Studio/build.gradle b/client/Android/Studio/build.gradle index aa1413807..bbe9eb20f 100644 --- a/client/Android/Studio/build.gradle +++ b/client/Android/Studio/build.gradle @@ -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' } } diff --git a/client/Android/Studio/gradle/wrapper/gradle-wrapper.properties b/client/Android/Studio/gradle/wrapper/gradle-wrapper.properties index a67ea0bfd..782bd8b44 100644 --- a/client/Android/Studio/gradle/wrapper/gradle-wrapper.properties +++ b/client/Android/Studio/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/client/Android/android_freerdp.c b/client/Android/android_freerdp.c index 239854c90..a443c4ff6 100644 --- a/client/Android/android_freerdp.c +++ b/client/Android/android_freerdp.c @@ -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); - } - + WaitForSingleObject(inputThread, INFINITE); CloseHandle(inputThread); } diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 7852f566d..63f5b2271 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -153,7 +153,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) { XSetRegion(xfc->display, xfc->gc, reg1); XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0, - xfc->window->width, xfc->window->height); + xfc->window->width, xfc->window->height); XSetClipMask(xfc->display, xfc->gc, None); } @@ -163,9 +163,9 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) picFormat = XRenderFindVisualFormat(xfc->display, xfc->visual); pa.subwindow_mode = IncludeInferiors; primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat, - CPSubwindowMode, &pa); + CPSubwindowMode, &pa); windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle, - picFormat, CPSubwindowMode, &pa); + picFormat, CPSubwindowMode, &pa); XRenderSetPictureFilter(xfc->display, primaryPicture, FilterBilinear, 0, 0); transform.matrix[0][0] = XDoubleToFixed(xScalingFactor); transform.matrix[0][1] = XDoubleToFixed(0.0); @@ -185,7 +185,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) h = ceil(y2 / yScalingFactor) + 1 - y; XRenderSetPictureTransform(xfc->display, primaryPicture, &transform); XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x, - y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h); + y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h); XRenderFreePicture(xfc->display, primaryPicture); XRenderFreePicture(xfc->display, windowPicture); } @@ -223,7 +223,7 @@ void xf_draw_screen(xfContext* xfc, int x, int y, int w, int h) #endif XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y, w, h, - x, y); + x, y); } static BOOL xf_desktop_resize(rdpContext* context) @@ -238,9 +238,9 @@ static BOOL xf_desktop_resize(rdpContext* context) XFreePixmap(xfc->display, xfc->primary); if (!(xfc->primary = XCreatePixmap( - xfc->display, xfc->drawable, - settings->DesktopWidth, - settings->DesktopHeight, xfc->depth))) + xfc->display, xfc->drawable, + settings->DesktopWidth, + settings->DesktopHeight, xfc->depth))) return FALSE; if (same) @@ -260,7 +260,7 @@ static BOOL xf_desktop_resize(rdpContext* context) if (!xfc->fullscreen) { xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth, - settings->DesktopHeight); + settings->DesktopHeight); } else { @@ -279,7 +279,7 @@ static BOOL xf_desktop_resize(rdpContext* context) XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, 0); XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, xfc->window->width, - xfc->window->height); + xfc->window->height); } return TRUE; @@ -318,7 +318,7 @@ static BOOL xf_sw_end_paint(rdpContext* context) xf_lock_x11(xfc, FALSE); XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, - x, y, x, y, w, h); + x, y, x, y, w, h); xf_draw_screen(xfc, x, y, w, h); xf_unlock_x11(xfc, FALSE); } @@ -336,7 +336,7 @@ static BOOL xf_sw_end_paint(rdpContext* context) w = cinvalid[i].w; h = cinvalid[i].h; XPutImage(xfc->display, xfc->primary, xfc->gc, - xfc->image, x, y, x, y, w, h); + xfc->image, x, y, x, y, w, h); xf_draw_screen(xfc, x, y, w, h); } @@ -375,8 +375,8 @@ static BOOL xf_sw_desktop_resize(rdpContext* context) } if (!(xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, - 0, - (char*) gdi->primary_buffer, gdi->width, gdi->height, xfc->scanline_pad, 0))) + 0, + (char*) gdi->primary_buffer, gdi->width, gdi->height, xfc->scanline_pad, 0))) { goto out; } @@ -540,15 +540,15 @@ BOOL xf_create_window(xfContext* xfc) else if (settings->ServerPort == 3389) { windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen( - settings->ServerHostname)); + settings->ServerHostname)); sprintf(windowTitle, "FreeRDP: %s", settings->ServerHostname); } else { windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(settings->ServerHostname) - + sizeof(":00000")); + + sizeof(":00000")); sprintf(windowTitle, "FreeRDP: %s:%i", settings->ServerHostname, - settings->ServerPort); + settings->ServerPort); } #ifdef WITH_XRENDER @@ -593,8 +593,8 @@ BOOL xf_create_window(xfContext* xfc) if (!xfc->primary) xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, - settings->DesktopWidth, - settings->DesktopHeight, xfc->depth); + settings->DesktopWidth, + settings->DesktopHeight, xfc->depth); xfc->drawing = xfc->primary; @@ -603,24 +603,24 @@ BOOL xf_create_window(xfContext* xfc) if (!xfc->gc_mono) xfc->gc_mono = XCreateGC(xfc->display, xfc->bitmap_mono, GCGraphicsExposures, - &gcv); + &gcv); XSetFunction(xfc->display, xfc->gc, GXcopy); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen)); XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, - settings->DesktopWidth, - settings->DesktopHeight); + settings->DesktopWidth, + settings->DesktopHeight); XFlush(xfc->display); if (!xfc->image) { rdpGdi* gdi = xfc->context.gdi; xfc->image = XCreateImage(xfc->display, xfc->visual, - xfc->depth, - ZPixmap, 0, (char*) gdi->primary_buffer, - settings->DesktopWidth, settings->DesktopHeight, - xfc->scanline_pad, 0); + xfc->depth, + ZPixmap, 0, (char*) gdi->primary_buffer, + settings->DesktopWidth, settings->DesktopHeight, + xfc->scanline_pad, 0); } return TRUE; @@ -722,7 +722,7 @@ void xf_toggle_control(xfContext* xfc) * @return 0 on success, otherwise a Win32 error code */ static UINT xf_encomsp_participant_created(EncomspClientContext* context, - ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) + ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) { return CHANNEL_RC_OK; } @@ -811,14 +811,14 @@ static BOOL xf_get_pixmap_info(xfContext* xfc) tpl.screen = xfc->screen_number; if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), - &window_attributes) == 0) + &window_attributes) == 0) { WLog_ERR(TAG, "XGetWindowAttributes failed"); return FALSE; } vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask, - &tpl, &vi_count); + &tpl, &vi_count); if (!vis) { @@ -853,9 +853,9 @@ static BOOL xf_get_pixmap_info(xfContext* xfc) /* calculate color shifts required for rdp order color conversion */ xf_calculate_color_shifts(vi->red_mask, &xfc->red_shift_r, &xfc->red_shift_l); xf_calculate_color_shifts(vi->green_mask, &xfc->green_shift_r, - &xfc->green_shift_l); + &xfc->green_shift_l); xf_calculate_color_shifts(vi->blue_mask, &xfc->blue_shift_r, - &xfc->blue_shift_l); + &xfc->blue_shift_l); } XFree(vis); @@ -894,7 +894,7 @@ static int _xf_error_handler(Display* d, XErrorEvent* ev) } static BOOL xf_play_sound(rdpContext* context, - const PLAY_SOUND_UPDATE* play_sound) + const PLAY_SOUND_UPDATE* play_sound) { xfContext* xfc = (xfContext*) context; XkbBell(xfc->display, None, 100, 0); @@ -909,7 +909,7 @@ static void xf_check_extensions(xfContext* context) if (XkbLibraryVersion(&xkb_major, &xkb_minor) && XkbQueryExtension(context->display, &xkb_opcode, &xkb_event, - &xkb_error, &xkb_major, &xkb_minor)) + &xkb_error, &xkb_major, &xkb_minor)) { context->xkbAvailable = TRUE; } @@ -920,7 +920,7 @@ static void xf_check_extensions(xfContext* context) int xrender_error_base; if (XRenderQueryExtension(context->display, &xrender_event_base, - &xrender_error_base)) + &xrender_error_base)) { context->xrenderAvailable = TRUE; } @@ -1064,7 +1064,7 @@ static void xf_button_map_init(xfContext* xfc) else { WLog_ERR(TAG, "Mouse physical button %d is mapped to logical button %d", - physical, logical); + physical, logical); } } } @@ -1117,9 +1117,9 @@ static BOOL xf_pre_connect(freerdp* instance) settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE; PubSub_SubscribeChannelConnected(instance->context->pubSub, - (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler); + (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler); PubSub_SubscribeChannelDisconnected(instance->context->pubSub, - (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler); + (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler); if (!freerdp_client_load_addins(channels, instance->settings)) return FALSE; @@ -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,19 +1491,12 @@ 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))) + (LPTHREAD_START_ROUTINE) xf_input_thread, instance, 0, NULL))) { WLog_ERR(TAG, "async input: failed to create input thread"); exit_code = XF_EXIT_UNKNOWN; @@ -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); - + WaitForSingleObject(inputThread, INFINITE); CloseHandle(inputThread); } @@ -1594,7 +1574,7 @@ disconnect: DWORD xf_exit_code_from_disconnect_reason(DWORD reason) { if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS - && reason <= XF_EXIT_AUTH_FAILURE)) + && reason <= XF_EXIT_AUTH_FAILURE)) return reason; /* License error set */ else if (reason >= 0x100 && reason <= 0x10A) @@ -1611,26 +1591,12 @@ 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 static void xf_ZoomingChangeEventHandler(rdpContext* context, - ZoomingChangeEventArgs* e) + ZoomingChangeEventArgs* e) { xfContext* xfc = (xfContext*) context; rdpSettings* settings = context->settings; @@ -1655,7 +1621,7 @@ static void xf_ZoomingChangeEventHandler(rdpContext* context, } static void xf_PanningChangeEventHandler(rdpContext* context, - PanningChangeEventArgs* e) + PanningChangeEventArgs* e) { xfContext* xfc = (xfContext*) context; rdpSettings* settings = context->settings; @@ -1695,15 +1661,13 @@ static int xfreerdp_client_start(rdpContext* context) if (!settings->ServerHostname) { WLog_ERR(TAG, - "error: server hostname was not specified with /v:[:port]"); + "error: server hostname was not specified with /v:[:port]"); return -1; } - xfc->disconnect = FALSE; - if (!(xfc->thread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) xf_client_thread, - context->instance, 0, NULL))) + (LPTHREAD_START_ROUTINE) xf_client_thread, + context->instance, 0, NULL))) { WLog_ERR(TAG, "failed to create client thread"); return -1; @@ -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) { @@ -1759,12 +1711,12 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) instance->LogonErrorInfo = xf_logon_error_info; settings = instance->settings; PubSub_SubscribeTerminate(context->pubSub, - (pTerminateEventHandler) xf_TerminateEventHandler); + (pTerminateEventHandler) xf_TerminateEventHandler); #ifdef WITH_XRENDER PubSub_SubscribeZoomingChange(context->pubSub, - (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler); + (pZoomingChangeEventHandler) xf_ZoomingChangeEventHandler); PubSub_SubscribePanningChange(context->pubSub, - (pPanningChangeEventHandler) xf_PanningChangeEventHandler); + (pPanningChangeEventHandler) xf_PanningChangeEventHandler); #endif xfc->UseXThreads = TRUE; //xfc->debug = TRUE; @@ -1784,7 +1736,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) { WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); WLog_ERR(TAG, - "Please check that the $DISPLAY environment variable is properly set."); + "Please check that the $DISPLAY environment variable is properly set."); goto fail_open_display; } @@ -1799,39 +1751,39 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False); xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False); xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP", - False); + False); xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False); xfc->_NET_WM_STATE = XInternAtom(xfc->display, "_NET_WM_STATE", False); xfc->_NET_WM_STATE_FULLSCREEN = XInternAtom(xfc->display, - "_NET_WM_STATE_FULLSCREEN", False); + "_NET_WM_STATE_FULLSCREEN", False); xfc->_NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(xfc->display, - "_NET_WM_STATE_MAXIMIZED_HORZ", False); + "_NET_WM_STATE_MAXIMIZED_HORZ", False); xfc->_NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(xfc->display, - "_NET_WM_STATE_MAXIMIZED_VERT", False); + "_NET_WM_STATE_MAXIMIZED_VERT", False); xfc->_NET_WM_FULLSCREEN_MONITORS = XInternAtom(xfc->display, - "_NET_WM_FULLSCREEN_MONITORS", False); + "_NET_WM_FULLSCREEN_MONITORS", False); xfc->_NET_WM_NAME = XInternAtom(xfc->display, "_NET_WM_NAME", False); xfc->_NET_WM_PID = XInternAtom(xfc->display, "_NET_WM_PID", False); xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE", - False); + False); xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display, - "_NET_WM_WINDOW_TYPE_NORMAL", False); + "_NET_WM_WINDOW_TYPE_NORMAL", False); xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display, - "_NET_WM_WINDOW_TYPE_DIALOG", False); + "_NET_WM_WINDOW_TYPE_DIALOG", False); xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display, - "_NET_WM_WINDOW_TYPE_POPUP", False); + "_NET_WM_WINDOW_TYPE_POPUP", False); xfc->_NET_WM_WINDOW_TYPE_UTILITY = XInternAtom(xfc->display, - "_NET_WM_WINDOW_TYPE_UTILITY", False); + "_NET_WM_WINDOW_TYPE_UTILITY", False); xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = XInternAtom(xfc->display, - "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); + "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); xfc->_NET_WM_STATE_SKIP_TASKBAR = XInternAtom(xfc->display, - "_NET_WM_STATE_SKIP_TASKBAR", False); + "_NET_WM_STATE_SKIP_TASKBAR", False); xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display, - "_NET_WM_STATE_SKIP_PAGER", False); + "_NET_WM_STATE_SKIP_PAGER", False); xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE", - False); + False); xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display, - "_NET_MOVERESIZE_WINDOW", False); + "_NET_MOVERESIZE_WINDOW", False); xfc->UTF8_STRING = XInternAtom(xfc->display, "UTF8_STRING", FALSE); xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False); xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False); @@ -1844,7 +1796,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) xfc->invert = (ImageByteOrder(xfc->display) == MSBFirst) ? FALSE : TRUE; xfc->complex_regions = TRUE; xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds, - WINPR_FD_READ); + WINPR_FD_READ); if (!xfc->x11event) { diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index a18fd6a57..1750ec412 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -94,7 +94,7 @@ void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled) } void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, - UINT16 command) + UINT16 command) { RAIL_SYSCOMMAND_ORDER syscommand; syscommand.windowId = windowId; @@ -154,14 +154,14 @@ void xf_rail_end_local_move(xfContext* xfc, xfAppWindow* appWindow) windowMove.left = appWindow->x; windowMove.top = appWindow->y; windowMove.right = windowMove.left + - appWindow->width; /* In the update to RDP the position is one past the window */ + appWindow->width; /* In the update to RDP the position is one past the window */ windowMove.bottom = windowMove.top + appWindow->height; xfc->rail->ClientWindowMove(xfc->rail, &windowMove); /* * Simulate button up at new position to end the local move (per RDP spec) */ XQueryPointer(xfc->display, appWindow->handle, - &root_window, &child_window, &x, &y, &child_x, &child_y, &mask); + &root_window, &child_window, &x, &y, &child_x, &child_y, &mask); /* only send the mouse coordinates if not a keyboard move or size */ if ((appWindow->local_move.direction != _NET_WM_MOVERESIZE_MOVE_KEYBOARD) && @@ -198,7 +198,7 @@ void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion) for (index = 0; index < count; index++) { appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*) pKeys[index]); + (void*) pKeys[index]); if (appWindow) { @@ -220,8 +220,8 @@ void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion) if (appWindow) { xf_UpdateWindowArea(xfc, appWindow, updateRect.left, updateRect.top, - updateRect.right - updateRect.left, - updateRect.bottom - updateRect.top); + updateRect.right - updateRect.left, + updateRect.bottom - updateRect.top); } } } @@ -231,7 +231,7 @@ void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion) } void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright, - UINT32 ubottom) + UINT32 ubottom) { REGION16 invalidRegion; RECTANGLE_16 invalidRect; @@ -248,7 +248,7 @@ void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright, /* RemoteApp Core Protocol Extension */ static BOOL xf_rail_window_common(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) + WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) { xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context; @@ -285,7 +285,7 @@ static BOOL xf_rail_window_common(rdpContext* context, } } else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, - windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) + windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) { WLog_ERR(TAG, "failed to convert window title"); /* error handled below */ @@ -306,13 +306,13 @@ static BOOL xf_rail_window_common(rdpContext* context, } HashTable_Add(xfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId, - (void*) appWindow); + (void*) appWindow); xf_AppWindowInit(xfc, appWindow); } else { appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*)(UINT_PTR) orderInfo->windowId); + (void*)(UINT_PTR) orderInfo->windowId); } if (!appWindow) @@ -373,7 +373,7 @@ static BOOL xf_rail_window_common(rdpContext* context, } } else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, - windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) + windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) { WLog_ERR(TAG, "failed to convert window title"); return FALSE; @@ -414,13 +414,13 @@ static BOOL xf_rail_window_common(rdpContext* context, if (appWindow->numWindowRects) { appWindow->windowRects = (RECTANGLE_16*) calloc(appWindow->numWindowRects, - sizeof(RECTANGLE_16)); + sizeof(RECTANGLE_16)); if (!appWindow->windowRects) return FALSE; CopyMemory(appWindow->windowRects, windowState->windowRects, - appWindow->numWindowRects * sizeof(RECTANGLE_16)); + appWindow->numWindowRects * sizeof(RECTANGLE_16)); } } @@ -443,13 +443,13 @@ static BOOL xf_rail_window_common(rdpContext* context, if (appWindow->numVisibilityRects) { appWindow->visibilityRects = (RECTANGLE_16*) calloc( - appWindow->numVisibilityRects, sizeof(RECTANGLE_16)); + appWindow->numVisibilityRects, sizeof(RECTANGLE_16)); if (!appWindow->visibilityRects) return FALSE; CopyMemory(appWindow->visibilityRects, windowState->visibilityRects, - appWindow->numVisibilityRects * sizeof(RECTANGLE_16)); + appWindow->numVisibilityRects * sizeof(RECTANGLE_16)); } } @@ -473,9 +473,9 @@ static BOOL xf_rail_window_common(rdpContext* context, if (position_or_size_updated) { UINT32 visibilityRectsOffsetX = (appWindow->visibleOffsetX - - (appWindow->clientOffsetX - appWindow->windowClientDeltaX)); + (appWindow->clientOffsetX - appWindow->windowClientDeltaX)); UINT32 visibilityRectsOffsetY = (appWindow->visibleOffsetY - - (appWindow->clientOffsetY - appWindow->windowClientDeltaY)); + (appWindow->clientOffsetY - appWindow->windowClientDeltaY)); /* * The rail server like to set the window to a small size when it is minimized even though it is hidden @@ -491,18 +491,18 @@ static BOOL xf_rail_window_common(rdpContext* context, appWindow->height == appWindow->windowHeight) { xf_UpdateWindowArea(xfc, appWindow, 0, 0, appWindow->windowWidth, - appWindow->windowHeight); + appWindow->windowHeight); } else { xf_MoveWindow(xfc, appWindow, appWindow->windowOffsetX, - appWindow->windowOffsetY, - appWindow->windowWidth, appWindow->windowHeight); + appWindow->windowOffsetY, + appWindow->windowWidth, appWindow->windowHeight); } xf_SetWindowVisibilityRects(xfc, appWindow, visibilityRectsOffsetX, - visibilityRectsOffsetY, appWindow->visibilityRects, - appWindow->numVisibilityRects); + visibilityRectsOffsetY, appWindow->visibilityRects, + appWindow->numVisibilityRects); } } @@ -515,12 +515,12 @@ static BOOL xf_rail_window_common(rdpContext* context, } static BOOL xf_rail_window_delete(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo) + WINDOW_ORDER_INFO* orderInfo) { xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context; appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*)(UINT_PTR) orderInfo->windowId); + (void*)(UINT_PTR) orderInfo->windowId); if (!appWindow) return TRUE; @@ -531,13 +531,13 @@ static BOOL xf_rail_window_delete(rdpContext* context, } static BOOL xf_rail_window_icon(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* windowIcon) + WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* windowIcon) { BOOL bigIcon; xfAppWindow* railWindow; xfContext* xfc = (xfContext*) context; railWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*)(UINT_PTR) orderInfo->windowId); + (void*)(UINT_PTR) orderInfo->windowId); if (!railWindow) return FALSE; @@ -547,13 +547,13 @@ static BOOL xf_rail_window_icon(rdpContext* context, } static BOOL xf_rail_window_cached_icon(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* windowCachedIcon) + WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* windowCachedIcon) { return TRUE; } static BOOL xf_rail_notify_icon_common(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) + WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) { if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) { @@ -583,31 +583,31 @@ static BOOL xf_rail_notify_icon_common(rdpContext* context, } static BOOL xf_rail_notify_icon_create(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) + WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) { return xf_rail_notify_icon_common(context, orderInfo, notifyIconState); } static BOOL xf_rail_notify_icon_update(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) + WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState) { return xf_rail_notify_icon_common(context, orderInfo, notifyIconState); } static BOOL xf_rail_notify_icon_delete(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo) + WINDOW_ORDER_INFO* orderInfo) { return TRUE; } static BOOL xf_rail_monitored_desktop(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitoredDesktop) + WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitoredDesktop) { return TRUE; } static BOOL xf_rail_non_monitored_desktop(rdpContext* context, - WINDOW_ORDER_INFO* orderInfo) + WINDOW_ORDER_INFO* orderInfo) { xfContext* xfc = (xfContext*) context; xf_rail_disable_remoteapp_mode(xfc); @@ -637,15 +637,15 @@ void xf_rail_register_update_callbacks(rdpUpdate* update) * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_execute_result(RailClientContext* context, - RAIL_EXEC_RESULT_ORDER* execResult) + RAIL_EXEC_RESULT_ORDER* execResult) { xfContext* xfc = (xfContext*) context->custom; if (execResult->execResult != RAIL_EXEC_S_OK) { WLog_ERR(TAG, "RAIL exec error: execResult=%s NtError=0x%X\n", - error_code_names[execResult->execResult], execResult->rawResult); - xfc->disconnect = TRUE; + error_code_names[execResult->execResult], execResult->rawResult); + freerdp_abort_connect(xfc->context.instance); } else { @@ -661,7 +661,7 @@ static UINT xf_rail_server_execute_result(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_system_param(RailClientContext* context, - RAIL_SYSPARAM_ORDER* sysparam) + RAIL_SYSPARAM_ORDER* sysparam) { return CHANNEL_RC_OK; } @@ -672,7 +672,7 @@ static UINT xf_rail_server_system_param(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_handshake(RailClientContext* context, - RAIL_HANDSHAKE_ORDER* handshake) + RAIL_HANDSHAKE_ORDER* handshake) { RAIL_EXEC_ORDER exec; RAIL_SYSPARAM_ORDER sysparam; @@ -728,7 +728,7 @@ static UINT xf_rail_server_handshake(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_handshake_ex(RailClientContext* context, - RAIL_HANDSHAKE_EX_ORDER* handshakeEx) + RAIL_HANDSHAKE_EX_ORDER* handshakeEx) { return CHANNEL_RC_OK; } @@ -739,7 +739,7 @@ static UINT xf_rail_server_handshake_ex(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_local_move_size(RailClientContext* context, - RAIL_LOCALMOVESIZE_ORDER* localMoveSize) + RAIL_LOCALMOVESIZE_ORDER* localMoveSize) { int x = 0, y = 0; int direction = 0; @@ -747,7 +747,7 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context, xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context->custom; appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*)(UINT_PTR) localMoveSize->windowId); + (void*)(UINT_PTR) localMoveSize->windowId); if (!appWindow) return ERROR_INTERNAL_ERROR; @@ -805,8 +805,8 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context, case RAIL_WMSZ_MOVE: direction = _NET_WM_MOVERESIZE_MOVE; XTranslateCoordinates(xfc->display, appWindow->handle, - RootWindowOfScreen(xfc->screen), - localMoveSize->posX, localMoveSize->posY, &x, &y, &child_window); + RootWindowOfScreen(xfc->screen), + localMoveSize->posX, localMoveSize->posY, &x, &y, &child_window); break; case RAIL_WMSZ_KEYMOVE: @@ -844,21 +844,21 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_min_max_info(RailClientContext* context, - RAIL_MINMAXINFO_ORDER* minMaxInfo) + RAIL_MINMAXINFO_ORDER* minMaxInfo) { xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context->custom; appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, - (void*)(UINT_PTR) minMaxInfo->windowId); + (void*)(UINT_PTR) minMaxInfo->windowId); if (!appWindow) return ERROR_INTERNAL_ERROR; xf_SetWindowMinMaxInfo(xfc, appWindow, - minMaxInfo->maxWidth, minMaxInfo->maxHeight, - minMaxInfo->maxPosX, minMaxInfo->maxPosY, - minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight, - minMaxInfo->maxTrackWidth, minMaxInfo->maxTrackHeight); + minMaxInfo->maxWidth, minMaxInfo->maxHeight, + minMaxInfo->maxPosX, minMaxInfo->maxPosY, + minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight, + minMaxInfo->maxTrackWidth, minMaxInfo->maxTrackHeight); return CHANNEL_RC_OK; } @@ -868,7 +868,7 @@ static UINT xf_rail_server_min_max_info(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_language_bar_info(RailClientContext* context, - RAIL_LANGBAR_INFO_ORDER* langBarInfo) + RAIL_LANGBAR_INFO_ORDER* langBarInfo) { return CHANNEL_RC_OK; } @@ -879,7 +879,7 @@ static UINT xf_rail_server_language_bar_info(RailClientContext* context, * @return 0 on success, otherwise a Win32 error code */ static UINT xf_rail_server_get_appid_response(RailClientContext* context, - RAIL_GET_APPID_RESP_ORDER* getAppIdResp) + RAIL_GET_APPID_RESP_ORDER* getAppIdResp) { return CHANNEL_RC_OK; } diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 673cdc4d1..ecad9d748 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -125,7 +125,6 @@ struct xf_context xfFullscreenMonitors fullscreenMonitors; int current_desktop; BOOL remote_app; - BOOL disconnect; HANDLE mutex; BOOL UseXThreads; BOOL cursorHidden; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index c62c5dfd7..f700c9dde 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -116,7 +116,7 @@ BOOL freerdp_connect(freerdp* instance) if (status) status2 = freerdp_channels_pre_connect(instance->context->channels, - instance); + instance); if (settings->KeyboardLayout == KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002) { @@ -153,7 +153,7 @@ BOOL freerdp_connect(freerdp* instance) if (instance->settings->DumpRemoteFx) { instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile, - TRUE); + TRUE); if (instance->update->pcap_rfx) instance->update->dump_rfx = TRUE; @@ -220,7 +220,7 @@ BOOL freerdp_connect(freerdp* instance) if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES) freerdp_set_last_error(instance->context, - FREERDP_ERROR_INSUFFICIENT_PRIVILEGES); + FREERDP_ERROR_INSUFFICIENT_PRIVILEGES); SetEvent(rdp->transport->connectedEvent); freerdp_connect_finally: @@ -239,7 +239,7 @@ BOOL freerdp_abort_connect(freerdp* instance) } BOOL freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, - int* wcount) + int* wcount) { rdpRdp* rdp = instance->context->rdp; transport_get_fds(rdp->transport, rfds, rcount); @@ -278,7 +278,7 @@ BOOL freerdp_check_fds(freerdp* instance) } DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events, - DWORD count) + DWORD count) { DWORD nCount = 0; nCount += transport_get_event_handles(context->rdp->transport, events, count); @@ -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; } @@ -354,7 +372,7 @@ HANDLE freerdp_get_message_queue_event_handle(freerdp* instance, DWORD id) } int freerdp_message_queue_process_message(freerdp* instance, DWORD id, - wMessage* message) + wMessage* message) { int status = -1; @@ -391,7 +409,7 @@ int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id) } static int freerdp_send_channel_data(freerdp* instance, UINT16 channelId, - BYTE* data, int size) + BYTE* data, int size) { return rdp_send_channel_data(instance->context->rdp, channelId, data, size); } @@ -404,8 +422,16 @@ 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) + instance) != CHANNEL_RC_OK) rc = FALSE; IFCALL(instance->PostDisconnect, instance); @@ -547,7 +573,7 @@ BOOL freerdp_context_new(freerdp* instance) goto fail; PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, - sizeof(FreeRDP_Events) / sizeof(wEventType)); + sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); if (!context->metrics) @@ -721,7 +747,7 @@ void freerdp_set_last_error(rdpContext* context, UINT32 lastError) { if (lastError) WLog_ERR(TAG, "freerdp_set_last_error %s [0x%04X]", - freerdp_get_last_error_name(lastError), lastError); + freerdp_get_last_error_name(lastError), lastError); context->LastError = lastError; @@ -827,7 +853,7 @@ BOOL checkChannelErrorEvent(rdpContext* context) if (WaitForSingleObject(context->channelErrorEvent, 0) == WAIT_OBJECT_0) { WLog_ERR(TAG, "%s. Error was %lu", context->errorDescription, - context->channelErrorNum); + context->channelErrorNum); return FALSE; }