summaryrefslogtreecommitdiffstats
path: root/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-06-02 12:07:03 +0100
committerBen Murdoch <benm@google.com>2011-06-10 10:47:21 +0100
commit2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch)
treee4964fbd1cb70599f7718ff03e50ea1dab33890b /Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp
parent87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff)
downloadexternal_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp')
-rw-r--r--Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp20
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);