changeset 20705:3b9077f142b8 draft

-Codechange: [Win32] Cancel the current IME composition when the input focus changes.
author Michael Lutz <michi@icosahedron.de>
date Sun, 07 Apr 2013 17:09:46 +0200
parents 7d274a089d08
children 79930f9362c3
files src/video/win32_v.cpp src/video/win32_v.h
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -518,7 +518,20 @@
 
 	return lParam != 0 ? DefWindowProc(hwnd, WM_IME_COMPOSITION, wParam, lParam) : 0;
 }
-#endif
+
+/** Clear the current composition string. */
+static void CancelIMEComposition(HWND hwnd)
+{
+	HIMC hIMC = ImmGetContext(hwnd);
+	if (hIMC != NULL) ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
+	ImmReleaseContext(hwnd, hIMC);
+}
+
+#else
+
+static void CancelIMEComposition(HWND hwnd) {}
+
+#endif /* !defined(WINCE) || _WIN32_WCE >= 0x400 */
 
 static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
@@ -1197,3 +1210,8 @@
 {
 	return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
 }
+
+void VideoDriver_Win32::EditBoxLostFocus()
+{
+	CancelIMEComposition(_wnd.main_wnd);
+}
--- a/src/video/win32_v.h
+++ b/src/video/win32_v.h
@@ -33,6 +33,8 @@
 
 	/* virtual */ bool ClaimMousePointer();
 
+	/* virtual */ void EditBoxLostFocus();
+
 	/* virtual */ const char *GetName() const { return "win32"; }
 
 	bool MakeWindow(bool full_screen);