can't grabkeyboard on focusin unless mouse is in window, can't grabkeyboard on enternotiy unless window is focused, cache them, other grabkeyboard fixes
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@256 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
717c7c27c3
commit
14c59b0d93
30
xwin.c
30
xwin.c
@ -31,6 +31,8 @@ extern BOOL fullscreen;
|
|||||||
extern BOOL grab_keyboard;
|
extern BOOL grab_keyboard;
|
||||||
extern char title[];
|
extern char title[];
|
||||||
BOOL enable_compose = False;
|
BOOL enable_compose = False;
|
||||||
|
BOOL focused;
|
||||||
|
BOOL mouse_in_wnd;
|
||||||
|
|
||||||
Display *display;
|
Display *display;
|
||||||
static int x_socket;
|
static int x_socket;
|
||||||
@ -345,14 +347,16 @@ ui_create_window(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
VisibilityChangeMask | FocusChangeMask | LeaveWindowMask;
|
VisibilityChangeMask | FocusChangeMask;
|
||||||
|
|
||||||
if (sendmotion)
|
if (sendmotion)
|
||||||
input_mask |= PointerMotionMask;
|
input_mask |= PointerMotionMask;
|
||||||
if (ownbackstore)
|
if (ownbackstore)
|
||||||
input_mask |= ExposureMask;
|
input_mask |= ExposureMask;
|
||||||
if (fullscreen)
|
if (fullscreen || grab_keyboard)
|
||||||
input_mask |= EnterWindowMask;
|
input_mask |= EnterWindowMask;
|
||||||
|
if (grab_keyboard)
|
||||||
|
input_mask |= LeaveWindowMask;
|
||||||
|
|
||||||
if (IM != NULL)
|
if (IM != NULL)
|
||||||
{
|
{
|
||||||
@ -374,6 +378,9 @@ ui_create_window(void)
|
|||||||
}
|
}
|
||||||
while (xevent.type != VisibilityNotify);
|
while (xevent.type != VisibilityNotify);
|
||||||
|
|
||||||
|
focused = False;
|
||||||
|
mouse_in_wnd = False;
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,24 +525,41 @@ xwin_process_events(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
if (xevent.xfocus.mode == NotifyGrab)
|
||||||
|
break;
|
||||||
|
focused = True;
|
||||||
XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
|
XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
|
||||||
reset_modifier_keys(state);
|
reset_modifier_keys(state);
|
||||||
if (grab_keyboard)
|
if (grab_keyboard && mouse_in_wnd)
|
||||||
XGrabKeyboard(display, wnd, True,
|
XGrabKeyboard(display, wnd, True,
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
if (xevent.xfocus.mode == NotifyUngrab)
|
||||||
|
break;
|
||||||
|
focused = False;
|
||||||
if (xevent.xfocus.mode == NotifyWhileGrabbed)
|
if (xevent.xfocus.mode == NotifyWhileGrabbed)
|
||||||
XUngrabKeyboard(display, CurrentTime);
|
XUngrabKeyboard(display, CurrentTime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EnterNotify:
|
case EnterNotify:
|
||||||
/* we only register for this event when in fullscreen mode */
|
/* we only register for this event when in fullscreen mode */
|
||||||
|
/* or grab_keyboard */
|
||||||
|
mouse_in_wnd = True;
|
||||||
|
if (fullscreen)
|
||||||
|
{
|
||||||
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
if (focused)
|
||||||
|
XGrabKeyboard(display, wnd, True,
|
||||||
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
|
break;
|
||||||
|
|
||||||
case LeaveNotify:
|
case LeaveNotify:
|
||||||
|
/* we only register for this event when grab_keyboard */
|
||||||
|
mouse_in_wnd = False;
|
||||||
XUngrabKeyboard(display, CurrentTime);
|
XUngrabKeyboard(display, CurrentTime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user