--- sourceforge.net/trunk/rdesktop/xwin.c 2002/07/27 23:09:32 70 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/07/29 20:16:22 76 @@ -25,11 +25,13 @@ #define XK_MISCELLANY #include #include "rdesktop.h" +#include "scancodes.h" extern int width; extern int height; extern BOOL sendmotion; extern BOOL fullscreen; +extern BOOL grab_keyboard; Display *display = NULL; static int x_socket; @@ -347,7 +349,9 @@ input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | - ButtonReleaseMask | EnterWindowMask | LeaveWindowMask; + ButtonReleaseMask; + if (grab_keyboard) + input_mask |= EnterWindowMask | LeaveWindowMask; if (sendmotion) input_mask |= PointerMotionMask; @@ -518,14 +522,27 @@ xevent.xmotion.y); break; + case FocusIn: + /* fall through */ case EnterNotify: - XGrabKeyboard(display, wnd, True, - GrabModeAsync, GrabModeAsync, - CurrentTime); + if (grab_keyboard) + XGrabKeyboard(display, wnd, True, + GrabModeAsync, GrabModeAsync, + CurrentTime); break; + 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); + /* fall through */ case LeaveNotify: - XUngrabKeyboard(display, CurrentTime); + if (grab_keyboard) + XUngrabKeyboard(display, CurrentTime); break; case Expose: @@ -589,8 +606,8 @@ tdata = (owncolmap ? data : translate_image(width, height, data)); bitmap = XCreatePixmap(display, wnd, width, height, depth); - image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, - height, 8, 0); + image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)tdata, + width, height, 8, 0); XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); @@ -608,8 +625,8 @@ uint8 *tdata; tdata = (owncolmap ? data : translate_image(width, height, data)); - image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, - height, 8, 0); + image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)tdata, + width, height, 8, 0); if (ownbackstore) { @@ -645,8 +662,8 @@ bitmap = XCreatePixmap(display, wnd, width, height, 1); gc = XCreateGC(display, bitmap, 0, NULL); - image = XCreateImage(display, visual, 1, ZPixmap, 0, data, width, - height, 8, scanline); + image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *)data, + width, height, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); @@ -1016,9 +1033,10 @@ if ((xyoffset & 0x80))\ {\ if (flags & TEXT2_VERTICAL) \ - y += ttext[++idx] | (ttext[++idx] << 8);\ + y += ttext[idx+1] | (ttext[idx+2] << 8);\ else\ - x += ttext[++idx] | (ttext[++idx] << 8);\ + x += ttext[idx+1] | (ttext[idx+2] << 8);\ + idx += 2;\ }\ else\ {\ @@ -1156,8 +1174,8 @@ if (data == NULL) return; - image = XCreateImage(display, visual, depth, ZPixmap, 0, data, cx, cy, - BitmapPad(display), cx * bpp / 8); + image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)data, + cx, cy, BitmapPad(display), cx * bpp / 8); if (ownbackstore) {