mirror of
https://github.com/gnustep/libs-back.git
synced 2025-05-30 17:00:52 +00:00
* Headers/win32/WIN32Server.h: Remove HOTKEY method.
* Source/win32/w32_general.m: Remove HOTKEY method. * Source/win32/WIN32Server.m: Remove call to HOTKEY method. Added function "mask_for_keystate(..)" to implement modifier mappings on Windows. Also changed process_key_event to use the new function and changed the call to ToUnicode to use a blank array instead of modifying the existing keyState array since this was returning the characters with the modifiers still applied. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@29498 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
99296fd283
commit
4c66d96e91
4 changed files with 84 additions and 31 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2010-02-07 03:37-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* Headers/win32/WIN32Server.h: Remove HOTKEY method.
|
||||||
|
* Source/win32/w32_general.m: Remove HOTKEY method.
|
||||||
|
* Source/win32/WIN32Server.m: Remove call to HOTKEY method. Added
|
||||||
|
function "mask_for_keystate(..)" to implement modifier mappings
|
||||||
|
on Windows. Also changed process_key_event to use the new function
|
||||||
|
and changed the call to ToUnicode to use a blank array instead of
|
||||||
|
modifying the existing keyState array since this was returning the
|
||||||
|
characters with the modifiers still applied.
|
||||||
|
|
||||||
2010-02-05 16:31-EST Gregory John Casamento <greg.casamento@gmail.com>
|
2010-02-05 16:31-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
* Headers/win32/WIN32Server.h: Added declaration for decodeWM_HOTKEY:...
|
* Headers/win32/WIN32Server.h: Added declaration for decodeWM_HOTKEY:...
|
||||||
|
|
|
@ -173,7 +173,6 @@ typedef struct w32serverFlags {
|
||||||
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||||
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||||
- (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
- (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||||
- (void) decodeWM_HOTKEYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -671,9 +671,6 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
break;
|
break;
|
||||||
case WM_HELP:
|
case WM_HELP:
|
||||||
break;
|
break;
|
||||||
case WM_HOTKEY:
|
|
||||||
[self decodeWM_HOTKEYParams: wParam : lParam : hwnd];
|
|
||||||
break;
|
|
||||||
//case WM_GETICON:
|
//case WM_GETICON:
|
||||||
//return [self decodeWM_GETICONParams: wParam : lParam : hwnd];
|
//return [self decodeWM_GETICONParams: wParam : lParam : hwnd];
|
||||||
//break;
|
//break;
|
||||||
|
@ -1649,6 +1646,65 @@ process_char(WPARAM wParam, unsigned *eventModifierFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int
|
||||||
|
mask_for_keystate(BYTE *keyState)
|
||||||
|
{
|
||||||
|
unsigned int eventFlags = 0;
|
||||||
|
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
NSString *firstCommand = [defs stringForKey: @"GSFirstCommandKey"];
|
||||||
|
NSString *firstControl = [defs stringForKey: @"GSFirstControlKey"];
|
||||||
|
NSString *firstAlt = [defs stringForKey: @"GSFirstAlternateKey"];
|
||||||
|
NSString *secondCommand = [defs stringForKey: @"GSSecondCommandKey"];
|
||||||
|
NSString *secondControl = [defs stringForKey: @"GSSecondControlKey"];
|
||||||
|
NSString *secondAlt = [defs stringForKey: @"GSSecondAlternateKey"];
|
||||||
|
|
||||||
|
/* AltGr is mapped to right alt + left control */
|
||||||
|
if (keyState[VK_RCONTROL] & 128) // && !((keyState[VK_LCONTROL] & 128) && (keyState[VK_RMENU] & 128)))
|
||||||
|
{
|
||||||
|
if([@"Control_R" isEqualToString: firstAlt] ||
|
||||||
|
[@"Control_R" isEqualToString: secondAlt])
|
||||||
|
eventFlags |= NSAlternateKeyMask;
|
||||||
|
else if([@"Control_R" isEqualToString: firstCommand] ||
|
||||||
|
[@"Control_R" isEqualToString: secondCommand])
|
||||||
|
eventFlags |= NSCommandKeyMask;
|
||||||
|
else
|
||||||
|
eventFlags |= NSControlKeyMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyState[VK_SHIFT] & 128)
|
||||||
|
eventFlags |= NSShiftKeyMask;
|
||||||
|
if (keyState[VK_CAPITAL] & 128)
|
||||||
|
eventFlags |= NSShiftKeyMask;
|
||||||
|
|
||||||
|
if (keyState[VK_MENU] & 128)
|
||||||
|
{
|
||||||
|
if([@"Alt_R" isEqualToString: firstControl] ||
|
||||||
|
[@"Alt_R" isEqualToString: secondControl])
|
||||||
|
eventFlags |= NSControlKeyMask;
|
||||||
|
else if([@"Alt_R" isEqualToString: firstCommand] ||
|
||||||
|
[@"Alt_R" isEqualToString: secondCommand])
|
||||||
|
eventFlags |= NSCommandKeyMask;
|
||||||
|
else
|
||||||
|
eventFlags |= NSAlternateKeyMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyState[VK_HELP] & 128)
|
||||||
|
eventFlags |= NSHelpKeyMask;
|
||||||
|
|
||||||
|
if ((keyState[VK_LCONTROL] & 128) || (keyState[VK_RWIN] & 128))
|
||||||
|
{
|
||||||
|
if([@"Control_L" isEqualToString: firstAlt] ||
|
||||||
|
[@"Control_L" isEqualToString: secondAlt])
|
||||||
|
eventFlags |= NSAlternateKeyMask;
|
||||||
|
else if([@"Control_L" isEqualToString: firstControl] ||
|
||||||
|
[@"Control_L" isEqualToString: secondControl])
|
||||||
|
eventFlags |= NSControlKeyMask;
|
||||||
|
else
|
||||||
|
eventFlags |= NSCommandKeyMask;
|
||||||
|
}
|
||||||
|
return eventFlags;
|
||||||
|
}
|
||||||
|
|
||||||
static NSEvent*
|
static NSEvent*
|
||||||
process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
NSEventType eventType)
|
NSEventType eventType)
|
||||||
|
@ -1681,21 +1737,7 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
time = ltime / 1000;
|
time = ltime / 1000;
|
||||||
|
|
||||||
GetKeyboardState(keyState);
|
GetKeyboardState(keyState);
|
||||||
eventFlags = 0;
|
eventFlags = mask_for_keystate(keyState);
|
||||||
/* AltGr is mapped to right alt + left control */
|
|
||||||
if ((keyState[VK_CONTROL] & 128) && !((keyState[VK_LCONTROL] & 128) && (keyState[VK_RMENU] & 128)))
|
|
||||||
eventFlags |= NSControlKeyMask;
|
|
||||||
if (keyState[VK_SHIFT] & 128)
|
|
||||||
eventFlags |= NSShiftKeyMask;
|
|
||||||
if (keyState[VK_CAPITAL] & 128)
|
|
||||||
eventFlags |= NSShiftKeyMask;
|
|
||||||
if (keyState[VK_MENU] & 128)
|
|
||||||
eventFlags |= NSAlternateKeyMask;
|
|
||||||
if (keyState[VK_HELP] & 128)
|
|
||||||
eventFlags |= NSHelpKeyMask;
|
|
||||||
if ((keyState[VK_LWIN] & 128) || (keyState[VK_RWIN] & 128))
|
|
||||||
eventFlags |= NSCommandKeyMask;
|
|
||||||
|
|
||||||
|
|
||||||
switch(wParam)
|
switch(wParam)
|
||||||
{
|
{
|
||||||
|
@ -1732,6 +1774,13 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
BYTE blankKeyState[256];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
// initialize blank key state array....
|
||||||
|
for(i = 0; i < 256; i++)
|
||||||
|
blankKeyState[i] = 0;
|
||||||
|
|
||||||
scan = ((lParam >> 16) & 0xFF);
|
scan = ((lParam >> 16) & 0xFF);
|
||||||
//NSLog(@"Got key code %d %d", scan, wParam);
|
//NSLog(@"Got key code %d %d", scan, wParam);
|
||||||
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
||||||
|
@ -1741,19 +1790,18 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
// A non spacing accent key was found, we still try to use the result
|
// A non spacing accent key was found, we still try to use the result
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
keys = [NSString stringWithCharacters: unicode length: result];
|
keys = [NSString stringWithCharacters: unicode length: result];
|
||||||
// Now switch modifiers off
|
|
||||||
keyState[VK_LCONTROL] = 0;
|
// Now get the characters with a blank keyboard state so that
|
||||||
keyState[VK_RCONTROL] = 0;
|
// no modifiers are applied.
|
||||||
keyState[VK_LMENU] = 0;
|
result = ToUnicode(wParam, scan, blankKeyState, unicode, 5, 0);
|
||||||
keyState[VK_RMENU] = 0;
|
|
||||||
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
|
||||||
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
{
|
{
|
||||||
// A non spacing accent key was found, we still try to use the result
|
// A non spacing accent key was found, we still try to use the result
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ukeys = [NSString stringWithCharacters: unicode length: result];
|
ukeys = [NSString stringWithCharacters: unicode length: result];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,5 @@
|
||||||
{
|
{
|
||||||
[[GSTheme theme] processCommand: (void *)wParam];
|
[[GSTheme theme] processCommand: (void *)wParam];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) decodeWM_HOTKEYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
||||||
{
|
|
||||||
[[GSTheme theme] processCommand: (void *)wParam];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue