From 01ecb577472e2bf24c9e9de8fdcb17fe30276dcc Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 10 Jun 2002 23:02:19 +0000 Subject: [PATCH] Authors: David Hammerton , Peter Hunnisett - Fix TranslateMessage return code. - Make GetKeyState work properly for apps that test 0x80 instead of 0x8000. --- windows/message.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/windows/message.c b/windows/message.c index 856bbb10d03..dc8b530e91d 100644 --- a/windows/message.c +++ b/windows/message.c @@ -633,8 +633,10 @@ SHORT WINAPI GetKeyState(INT vkey) INT retval; if (vkey >= 'a' && vkey <= 'z') vkey += 'A' - 'a'; - retval = ((WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) | (QueueKeyStateTable[vkey] & 0x01); - /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */ + retval = ((WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) | + (QueueKeyStateTable[vkey] & 0x80) | + (QueueKeyStateTable[vkey] & 0x01); + TRACE("key (0x%x) -> %x\n", vkey, retval); return retval; } @@ -938,18 +940,28 @@ static const struct accent_char accent_chars[] = * ditto replacing WM_* with WM_SYS* * This produces WM_CHAR messages only for keys mapped to ASCII characters * by the keyboard driver. + * + * If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the + * return value is nonzero, regardless of the translation. + * */ BOOL WINAPI TranslateMessage( const MSG *msg ) { static int dead_char; UINT message; WCHAR wp[2]; + BOOL rc = FALSE; if (msg->message >= WM_KEYFIRST && msg->message <= WM_KEYLAST) + { TRACE_(key)("(%s, %04X, %08lX)\n", SPY_GetMsgName(msg->message, msg->hwnd), msg->wParam, msg->lParam ); - if ((msg->message != WM_KEYDOWN) && (msg->message != WM_SYSKEYDOWN)) return FALSE; + /* Return code must be TRUE no matter what! */ + rc = TRUE; + } + + if ((msg->message != WM_KEYDOWN) && (msg->message != WM_SYSKEYDOWN)) return rc; TRACE_(key)("Translating key %s (%04x), scancode %02x\n", SPY_GetVKeyName(msg->wParam), msg->wParam, LOBYTE(HIWORD(msg->lParam))); @@ -983,7 +995,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg ) } TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message, msg->hwnd)); PostMessageW( msg->hwnd, message, wp[0], msg->lParam ); - return TRUE; + break; case -1: message = (msg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR; @@ -992,7 +1004,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg ) PostMessageW( msg->hwnd, message, wp[0], msg->lParam ); return TRUE; } - return FALSE; + return rc; }