Submit X11 shift key handling patch by Derek Fawcus

<dfawcus@employees.org>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@31025 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2010-07-25 19:39:18 +00:00
parent 23e8b5aadc
commit 621d682b3d
2 changed files with 53 additions and 19 deletions

View file

@ -1,4 +1,15 @@
2010-07-06 Eric Wasylishen <ewasylishen@gmail.com>
2010-07-25 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerEvent.m:
Treat Shift modifiers in the same manner as other modifiers.
This fixes the value of the shift bit (NSShiftKeyMask) in
the modifierFlags passed to a -flagsChanged: method call.
Without it the shift bit is inverted, as explained in
the source comments, as X reports the modifier bits in
force before the key was pressed/released.
Patch by Derek Fawcus <dfawcus@employees.org>.
2010-07-25 Eric Wasylishen <ewasylishen@gmail.com>
* Source/win32/WIN32Server.m:
When ordering out a window, use the SWP_NOACTIVATE flag on SetWindowPos
@ -7,7 +18,7 @@
This fixes the bug where when a tooltip disappeared, it would deactivate
the window the tooltip was over.
2010-07-06 Eric Wasylishen <ewasylishen@gmail.com>
2010-07-07 Eric Wasylishen <ewasylishen@gmail.com>
* Source/win32/WIN32Server.m:
* Source/win32/w32_movesize.m:

View file

@ -71,6 +71,7 @@
// NumLock's mask (it depends on the keyboard mapping)
static unsigned int _num_lock_mask;
// Modifier state
static char _shift_pressed = 0;
static char _control_pressed = 0;
static char _command_pressed = 0;
static char _alt_pressed = 0;
@ -1198,6 +1199,17 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
NSDebugLLog(@"NSEvent", @"%d KeymapNotify\n",
xEvent.xkeymap.window);
// Check if shift is pressed
_shift_pressed = 0;
if (check_modifier (&xEvent, XK_Shift_L))
{
_shift_pressed |= 1;
}
if (check_modifier (&xEvent, XK_Shift_R))
{
_shift_pressed |= 2;
}
// Check if control is pressed
_control_pressed = 0;
if ((_control_keysyms[0] != NoSymbol)
@ -1969,8 +1981,6 @@ keysym_is_X_modifier (KeySym keysym)
switch (keysym)
{
case XK_Num_Lock:
case XK_Shift_L:
case XK_Shift_R:
case XK_Caps_Lock:
case XK_Shift_Lock:
return YES;
@ -1993,6 +2003,7 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType,
NSEvent *event = nil;
NSEventType originalType;
gswindow_device_t *window;
int shift_key = 0;
int control_key = 0;
int command_key = 0;
int alt_key = 0;
@ -2033,7 +2044,15 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType,
XLookupKeysym((XKeyEvent *)xEvent, 0) : keysym;
if (modKeysym != NoSymbol)
{
if (modKeysym == _control_keysyms[0])
if (modKeysym == XK_Shift_L)
{
shift_key = 1;
}
else if (modKeysym == XK_Shift_R)
{
shift_key = 2;
}
else if (modKeysym == _control_keysyms[0])
{
control_key = 1;
}
@ -2068,11 +2087,13 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType,
}
originalType = eventType;
if (control_key || command_key || alt_key || help_key)
if (shift_key || control_key || command_key || alt_key || help_key)
{
eventType = NSFlagsChanged;
if (xEvent->xkey.type == KeyPress)
{
if (shift_key)
_shift_pressed |= shift_key;
if (control_key)
_control_pressed |= control_key;
if (command_key)
@ -2084,6 +2105,8 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType,
}
else if (xEvent->xkey.type == KeyRelease)
{
if (shift_key)
_shift_pressed &= ~shift_key;
if (control_key)
_control_pressed &= ~control_key;
if (command_key)
@ -2374,7 +2397,7 @@ process_modifier_flags(unsigned int state)
{
unsigned int eventModifierFlags = 0;
if (state & ShiftMask)
if (_shift_pressed != 0)
eventModifierFlags = eventModifierFlags | NSShiftKeyMask;
if (state & LockMask)