@@ -2883,17 +2883,40 @@ void _glfwSetIMEStatusWin32(_GLFWwindow* window, int active)
28832883{
28842884 HWND hWnd = window -> win32 .handle ;
28852885 HIMC hIMC = ImmGetContext (hWnd );
2886- ImmSetOpenStatus (hIMC , active ? TRUE : FALSE);
2887- ImmReleaseContext (hWnd , hIMC );
2886+ if (active )
2887+ {
2888+ if (!hIMC )
2889+ {
2890+ hIMC = ImmCreateContext ();
2891+ ImmAssociateContext (hWnd , hIMC );
2892+ }
2893+ if (!hIMC )
2894+ {
2895+ _glfwInputErrorWin32 (GLFW_PLATFORM_ERROR , "ImmCreateContext failed" );
2896+ return ;
2897+ }
2898+ ImmSetOpenStatus (hIMC , TRUE);
2899+ ImmReleaseContext (hWnd , hIMC );
2900+ }
2901+ else if (hIMC )
2902+ {
2903+ ImmSetOpenStatus (hIMC , FALSE);
2904+ ImmReleaseContext (hWnd , hIMC );
2905+ ImmAssociateContext (hWnd , NULL );
2906+ }
28882907}
28892908
28902909int _glfwGetIMEStatusWin32 (_GLFWwindow * window )
28912910{
28922911 HWND hWnd = window -> win32 .handle ;
28932912 HIMC hIMC = ImmGetContext (hWnd );
2894- BOOL result = ImmGetOpenStatus (hIMC );
2895- ImmReleaseContext (hWnd , hIMC );
2896- return result ? GLFW_TRUE : GLFW_FALSE ;
2913+ if (hIMC )
2914+ {
2915+ BOOL result = ImmGetOpenStatus (hIMC );
2916+ ImmReleaseContext (hWnd , hIMC );
2917+ return result ? GLFW_TRUE : GLFW_FALSE ;
2918+ }
2919+ return GLFW_FALSE ;
28972920}
28982921
28992922EGLenum _glfwGetEGLPlatformWin32 (EGLint * * attribs )
0 commit comments