From f1e223725fadf7f04bdad39f4d600560a8316b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C3=85strand?= Date: Mon, 29 Jul 2002 20:16:22 +0000 Subject: [PATCH] Applied patch from Bob Bell for -K option git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@75 423420c4-83ab-492f-b58f-81f9feb106b5 --- rdesktop.c | 8 +++++++- xwin.c | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/rdesktop.c b/rdesktop.c index e651bd8..bcb2997 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -43,6 +43,7 @@ BOOL licence = True; BOOL encryption = True; BOOL desktop_save = True; BOOL fullscreen = False; +BOOL grab_keyboard = True; /* Display usage information */ static void @@ -63,6 +64,7 @@ usage(char *program) printf(" -m: do not send motion events\n"); printf(" -l: do not request licence\n"); printf(" -t: rdp tcp port\n\n"); + printf(" -K: keep window manager key bindings\n"); } /* Client program */ @@ -89,7 +91,7 @@ main(int argc, char *argv[]) domain[0] = password[0] = shell[0] = directory[0] = 0; strcpy(keymapname, "us"); - while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:t:fbemlh?")) != -1) + while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:t:fbemlKh?")) != -1) { switch (c) { @@ -159,6 +161,10 @@ main(int argc, char *argv[]) tcp_port_rdp = strtol(optarg, NULL, 10); break; + case 'K': + grab_keyboard = False; + break; + case 'h': case '?': default: diff --git a/xwin.c b/xwin.c index ac16117..13ea288 100644 --- a/xwin.c +++ b/xwin.c @@ -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 @@ ui_create_window(char *title) 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 @@ xwin_process_events() 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: