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
This commit is contained in:
Peter Åstrand 2002-07-29 20:16:22 +00:00
parent e263b82202
commit f1e223725f
2 changed files with 29 additions and 6 deletions

View File

@ -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:

27
xwin.c
View File

@ -25,11 +25,13 @@
#define XK_MISCELLANY
#include <X11/keysymdef.h>
#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: