--- sourceforge.net/trunk/rdesktop/xwin.c 2002/08/29 14:18:24 103 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/09/12 09:38:31 119 @@ -247,7 +247,7 @@ } } -static BOOL +BOOL get_key_state(int keysym) { int keysymMask = 0, modifierpos, key; @@ -517,6 +517,7 @@ XFreePixmap(display, pixmap); } +/* Process all events in Xlib queue */ static void xwin_process_events() { @@ -530,15 +531,6 @@ char str[256]; Status status; - /* Refresh keyboard mapping if it has changed. This is important for - Xvnc, since it allocates keycodes dynamically */ - if (XCheckTypedEvent(display, MappingNotify, &xevent)) - { - if (xevent.xmapping.request == MappingKeyboard - || xevent.xmapping.request == MappingModifier) - XRefreshKeyboardMapping(&xevent.xmapping); - } - while (XCheckMaskEvent(display, ~0, &xevent)) { if (enable_compose && (XFilterEvent(&xevent, None) == True)) @@ -574,32 +566,20 @@ str, sizeof(str), &keysym, NULL); } - if (keysym == XK_Break) /* toggle full screen */ - { - if (get_key_state(XK_Alt_L) || get_key_state(XK_Alt_R)) - { - toggle_fullscreen(); - break; - } - } - ksname = get_ksname(keysym); DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); - if (inhibit_key(keysym)) - { - DEBUG_KBD(("Inhibiting key\n")); + if (handle_special_keys(keysym, ev_time, True)) break; - } tr = xkeymap_translate_key(keysym, xevent.xkey.keycode, xevent.xkey.state); - ensure_remote_modifiers(ev_time, tr); - if (tr.scancode == 0) break; + ensure_remote_modifiers(ev_time, tr); + rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); break; case KeyRelease: @@ -610,7 +590,7 @@ DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, ksname)); - if (inhibit_key(keysym)) + if (handle_special_keys(keysym, ev_time, False)) break; tr = xkeymap_translate_key(keysym, @@ -663,6 +643,15 @@ xevent.xexpose.height, xevent.xexpose.x, xevent.xexpose.y); break; + + case MappingNotify: + /* Refresh keyboard mapping if it has changed. This is important for + Xvnc, since it allocates keycodes dynamically */ + if (xevent.xmapping.request == MappingKeyboard + || xevent.xmapping.request == MappingModifier) + XRefreshKeyboardMapping(&xevent.xmapping); + break; + } } } @@ -672,11 +661,15 @@ { int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; fd_set rfds; + XEvent xevent; FD_ZERO(&rfds); while (True) { + /* Process any events already in queue */ + xwin_process_events(); + FD_ZERO(&rfds); FD_SET(rdp_socket, &rfds); if (display != NULL) @@ -695,7 +688,11 @@ } if (FD_ISSET(x_socket, &rfds)) - xwin_process_events(); + { + /* Move new events from socket to queue */ + XPeekEvent(display, &xevent); + continue; + } if (FD_ISSET(rdp_socket, &rfds)) return;