--- sourceforge.net/trunk/rdesktop/xwin.c 2002/09/26 14:04:30 203 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/11/05 11:09:26 253 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. User interface services - X Window System - Copyright (C) Matthew Chapman 1999-2001 + Copyright (C) Matthew Chapman 1999-2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -184,7 +184,7 @@ } BOOL -get_key_state(uint32 keysym, unsigned int state) +get_key_state(unsigned int state, uint32 keysym) { int modifierpos, key, keysymMask = 0; int offset; @@ -218,7 +218,7 @@ display = XOpenDisplay(NULL); if (display == NULL) { - error("Failed to open display\n"); + error("Failed to open display: %s\n", XDisplayName(NULL)); return False; } @@ -293,7 +293,7 @@ if (IM != NULL) XCloseIM(IM); - XFreeModifierMap(mod_map); + XFreeModifiermap(mod_map); if (ownbackstore) XFreePixmap(display, backstore); @@ -345,12 +345,14 @@ } input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | - StructureNotifyMask | FocusChangeMask; + VisibilityChangeMask | FocusChangeMask | LeaveWindowMask; if (sendmotion) input_mask |= PointerMotionMask; if (ownbackstore) input_mask |= ExposureMask; + if (fullscreen) + input_mask |= EnterWindowMask; if (IM != NULL) { @@ -365,15 +367,12 @@ XSelectInput(display, wnd, input_mask); XMapWindow(display, wnd); - /* wait for MapNotify */ + /* wait for VisibilityNotify */ do { - XMaskEvent(display, StructureNotifyMask, &xevent); + XMaskEvent(display, VisibilityChangeMask, &xevent); } - while (xevent.type != MapNotify); - - if (fullscreen) - XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); + while (xevent.type != VisibilityNotify); return True; } @@ -531,6 +530,15 @@ XUngrabKeyboard(display, CurrentTime); break; + case EnterNotify: + /* we only register for this event when in fullscreen mode */ + XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); + break; + + case LeaveNotify: + XUngrabKeyboard(display, CurrentTime); + break; + case Expose: XCopyArea(display, backstore, wnd, gc, xevent.xexpose.x, xevent.xexpose.y, @@ -548,7 +556,7 @@ if (xevent.xmapping.request == MappingModifier) { - XFreeModifierMap(mod_map); + XFreeModifiermap(mod_map); mod_map = XGetModifierMapping(display); } break;