diff options
Diffstat (limited to 'Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp')
-rw-r--r-- | Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp b/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp index 181d88e..90208c5 100644 --- a/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp +++ b/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp @@ -49,11 +49,29 @@ void run(bool* done) BOOL result = ::GetMessageW(&msg, 0, 0, 0); if (!result || result == -1) break; - ::TranslateMessage(&msg); + + if (shouldTranslateMessage(msg)) + ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } +bool shouldTranslateMessage(const MSG& msg) +{ + // Only these four messages are actually translated by ::TranslateMessage or ::TranslateAccelerator. + // It's useless (though harmless) to call those functions for other messages, so we always allow other messages to be translated. + if (msg.message != WM_KEYDOWN && msg.message != WM_SYSKEYDOWN && msg.message != WM_KEYUP && msg.message != WM_SYSKEYUP) + return true; + + wchar_t className[256]; + if (!::GetClassNameW(msg.hwnd, className, ARRAYSIZE(className))) + return true; + + // Don't call TranslateMessage() on key events destined for a WebKit2 view, WebKit will do this if it doesn't handle the message. + // It would be nice to use some API here instead of hard-coding the window class name. + return wcscmp(className, L"WebKit2WebViewWindowClass"); +} + void sleep(double seconds) { ::Sleep(seconds * 1000); |