diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 4042d5617..f94de0289 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -83,7 +83,7 @@ static BOOL xf_event_Expose(xfInfo* xfi, XEvent* event, BOOL app) w = event->xexpose.width; h = event->xexpose.height; - if (app != TRUE) + if (!app) { XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); } @@ -399,7 +399,7 @@ static BOOL xf_event_FocusIn(xfInfo* xfi, XEvent* event, BOOL app) } xf_kbd_focus_in(xfi); - if (app != TRUE) + if (!app) xf_cliprdr_check_owner(xfi); return TRUE; @@ -466,7 +466,7 @@ static BOOL xf_event_ClientMessage(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_EnterNotify(xfInfo* xfi, XEvent* event, BOOL app) { - if (app != TRUE) + if (!app) { xfi->mouse_active = TRUE; @@ -497,7 +497,7 @@ static BOOL xf_event_EnterNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, BOOL app) { - if (app != TRUE) + if (!app) { xfi->mouse_active = FALSE; XUngrabKeyboard(xfi->display, CurrentTime); @@ -573,7 +573,7 @@ static BOOL xf_event_MapNotify(xfInfo* xfi, XEvent* event, BOOL app) rdpUpdate* update = xfi->instance->update; rdpRail* rail = ((rdpContext*) xfi->context)->rail; - if (app != TRUE) + if (!app) { if (xfi->suppress_output == TRUE) { @@ -615,7 +615,7 @@ static BOOL xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, BOOL app) xf_kbd_release_all_keypress(xfi); - if (app != TRUE) + if (!app) { if (xfi->suppress_output == FALSE) { @@ -639,7 +639,7 @@ static BOOL xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_SelectionNotify(xfInfo* xfi, XEvent* event, BOOL app) { - if (app != TRUE) + if (!app) { if (xf_cliprdr_process_selection_notify(xfi, event)) return TRUE; @@ -650,7 +650,7 @@ static BOOL xf_event_SelectionNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_SelectionRequest(xfInfo* xfi, XEvent* event, BOOL app) { - if (app != TRUE) + if (!app) { if (xf_cliprdr_process_selection_request(xfi, event)) return TRUE; @@ -661,7 +661,7 @@ static BOOL xf_event_SelectionRequest(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_SelectionClear(xfInfo* xfi, XEvent* event, BOOL app) { - if (app != TRUE) + if (!app) { if (xf_cliprdr_process_selection_clear(xfi, event)) return TRUE; @@ -683,10 +683,9 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) rdpWindow* window; window = xf_rdpWindowFromWindow(xfi, event->xproperty.window); + if (window == NULL) - { return TRUE; - } if ((((Atom)event->xproperty.atom == xfi->_NET_WM_STATE) && (event->xproperty.state != PropertyDelete)) || (((Atom)event->xproperty.atom == xfi->WM_STATE) && (event->xproperty.state != PropertyDelete))) @@ -703,7 +702,8 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) status = xf_GetWindowProperty(xfi, event->xproperty.window, xfi->_NET_WM_STATE, 12, &nitems, &bytes, &prop); - if (status != TRUE) { + if (!status) + { DEBUG_X11_LMS("No return _NET_WM_STATE, window is not maximized"); } @@ -725,7 +725,7 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) status = xf_GetWindowProperty(xfi, event->xproperty.window, xfi->WM_STATE, 1, &nitems, &bytes, &prop); - if (status != TRUE) + if (!status) { DEBUG_X11_LMS("No return WM_STATE, window is not minimized"); } @@ -763,7 +763,7 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) } - if (app != TRUE) + if (!app) { if (xf_cliprdr_process_property_notify(xfi, event)) return TRUE; @@ -774,7 +774,7 @@ static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_suppress_events(xfInfo *xfi, rdpWindow *window, XEvent*event) { - if (! xfi->remote_app) + if (!xfi->remote_app) return FALSE; switch (xfi->window->local_move.state) diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index eec8b8012..3d38c8059 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -45,7 +45,7 @@ void xf_kbd_init(xfInfo* xfi) void xf_kbd_clear(xfInfo* xfi) { - memset(xfi->pressed_keys, 0, 256 * sizeof(BOOL)); + ZeroMemory(xfi->pressed_keys, 256 * sizeof(BOOL)); } void xf_kbd_set_keypress(xfInfo* xfi, BYTE keycode, KeySym keysym) @@ -129,7 +129,7 @@ int xf_kbd_read_keyboard_state(xfInfo* xfi) Window wdummy; UINT32 state = 0; - if (xfi->remote_app != TRUE) + if (!xfi->remote_app) { XQueryPointer(xfi->display, xfi->window->handle, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state); @@ -154,6 +154,7 @@ BOOL xf_kbd_get_key_state(xfInfo* xfi, int state, int keysym) for (modifierpos = 0; modifierpos < 8; modifierpos++) { offset = xfi->modifier_map->max_keypermod * modifierpos; + for (key = 0; key < xfi->modifier_map->max_keypermod; key++) { if (xfi->modifier_map->modifiermap[offset + key] == keycode) diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 853f8f54f..5e08602ad 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -1137,10 +1137,11 @@ void* xf_update_thread(void* arg) void* xf_input_thread(void* arg) { - int status; xfInfo* xfi; HANDLE event; XEvent xevent; + int pending_status = 1; + int process_status = 1; freerdp* instance = (freerdp*) arg; xfi = ((xfContext*) instance->context)->xfi; @@ -1149,25 +1150,32 @@ void* xf_input_thread(void* arg) while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0) { - xf_lock_x11(xfi); - - status = XPending(xfi->display); - - xf_unlock_x11(xfi); - - while (status > 0) + do { - ZeroMemory(&xevent, sizeof(xevent)); - xf_lock_x11(xfi); - XNextEvent(xfi->display, &xevent); - status = xf_event_process(instance, &xevent); + pending_status = XPending(xfi->display); xf_unlock_x11(xfi); - status--; + if (pending_status) + { + xf_lock_x11(xfi); + + ZeroMemory(&xevent, sizeof(xevent)); + XNextEvent(xfi->display, &xevent); + process_status = xf_event_process(instance, &xevent); + + xf_unlock_x11(xfi); + + if (!process_status) + break; + } } + while (pending_status); + + if (!process_status) + break; } printf("Closed from X\n"); @@ -1338,9 +1346,9 @@ int xfreerdp_run(freerdp* instance) break; timeout.tv_sec = 0; - timeout.tv_usec = 0; + timeout.tv_usec = 100; - select_status = select(max_fds + 1, &rfds_set, &wfds_set, NULL, NULL); + select_status = select(max_fds + 1, &rfds_set, &wfds_set, NULL, &timeout); if (select_status == 0) {