From d725eeaf84fcb798541e6e4328005b915dcc6cf2 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 29 Oct 2015 14:05:57 +0100 Subject: [PATCH] Simplify Win32 character message handling --- src/win32_window.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 342a5dff..f6d03898 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -317,6 +317,24 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, return 0; } + case WM_CHAR: + case WM_SYSCHAR: + case WM_UNICHAR: + { + const GLFWbool plain = (uMsg != WM_SYSCHAR); + + if (uMsg == WM_UNICHAR && wParam == UNICODE_NOCHAR) + { + // WM_UNICHAR is not sent by Windows, but is sent by some + // third-party input method engine + // Returning TRUE here announces support for this message + return TRUE; + } + + _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); + return 0; + } + case WM_KEYDOWN: case WM_SYSKEYDOWN: { @@ -329,33 +347,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; } - case WM_CHAR: - { - _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE); - return 0; - } - - case WM_SYSCHAR: - { - _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_FALSE); - return 0; - } - - case WM_UNICHAR: - { - // This message is not sent by Windows, but is sent by some - // third-party input method engines - - if (wParam == UNICODE_NOCHAR) - { - // Returning TRUE here announces support for this message - return TRUE; - } - - _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE); - return FALSE; - } - case WM_KEYUP: case WM_SYSKEYUP: {