--- sourceforge.net/trunk/rdesktop/xwin.c 2002/07/30 07:18:48 82 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/08/20 01:20:08 99 @@ -270,6 +270,7 @@ Screen *screen; uint16 test; int i; + XEvent xevent; x_socket = ConnectionNumber(display); screen = DefaultScreenOfDisplay(display); @@ -354,7 +355,8 @@ xkeymap_init2(); - input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask; + input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + VisibilityChangeMask | FocusChangeMask; if (grab_keyboard) input_mask |= EnterWindowMask | LeaveWindowMask; if (sendmotion) @@ -375,6 +377,18 @@ XMapWindow(display, wnd); + /* Wait for VisibilityNotify Event */ + for (;;) { + XNextEvent(display, &xevent); + if (xevent.type == VisibilityNotify) + break; + } + + /* clear the window so that cached data is not viewed upon start... */ + XSetBackground(display, gc, 0); + XSetForeground(display, gc, 0); + FILL_RECTANGLE(0, 0, width, height); + return True; } @@ -419,7 +433,7 @@ { if (enable_compose && (XFilterEvent(&xevent, None) == True)) { - DEBUG_KBD("Filtering event\n"); + DEBUG_KBD(("Filtering event\n")); continue; } @@ -445,17 +459,17 @@ else { /* Plain old XLookupString */ - DEBUG_KBD("No input context, using XLookupString\n"); + DEBUG_KBD(("No input context, using XLookupString\n")); XLookupString((XKeyEvent *) & xevent, str, sizeof(str), &keysym, NULL); } ksname = get_ksname(keysym); - DEBUG_KBD("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname); + DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); if (inhibit_key(keysym)) { - DEBUG_KBD("Inhibiting key\n"); + DEBUG_KBD(("Inhibiting key\n")); break; } @@ -474,7 +488,8 @@ sizeof(str), &keysym, NULL); ksname = get_ksname(keysym); - DEBUG_KBD("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, ksname); + DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, + ksname)); if (inhibit_key(keysym)) break; @@ -516,10 +531,12 @@ case FocusOut: /* reset keys */ - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, - KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LCTRL, 0); - rdp_send_input(ev_time, RDP_INPUT_SCANCODE, - KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LALT, 0); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT); /* fall through */ case LeaveNotify: if (grab_keyboard)