Skip to content

Commit

Permalink
Backends: GLFW, Input: Use Unicode version of WndProc for get correct…
Browse files Browse the repository at this point in the history
… input for text in utf-8 code page. (#7174)

Similar to #6785, #6782, #5725, #5961 for for GLFW backend.
  • Loading branch information
kimidaisuki22 authored and ocornut committed Dec 29, 2023
1 parent 4a24264 commit 240ab58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backends/imgui_impl_glfw.cpp
Expand Up @@ -493,7 +493,7 @@ static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wPara
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
break;
}
return ::CallWindowProc(bd->GlfwWndProc, hWnd, msg, wParam, lParam);
return ::CallWindowProcW(bd->GlfwWndProc, hWnd, msg, wParam, lParam);
}
#endif

Expand Down Expand Up @@ -617,9 +617,9 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw

// Windows: register a WndProc hook so we can intercept some messages.
#ifdef _WIN32
bd->GlfwWndProc = (WNDPROC)::GetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
bd->GlfwWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
IM_ASSERT(bd->GlfwWndProc != nullptr);
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
#endif

bd->ClientApi = client_api;
Expand Down Expand Up @@ -659,7 +659,7 @@ void ImGui_ImplGlfw_Shutdown()
// Windows: register a WndProc hook so we can intercept some messages.
#ifdef _WIN32
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);
bd->GlfwWndProc = nullptr;
#endif

Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Expand Up @@ -92,6 +92,8 @@ Other changes:
on a codebase where another copy of the library is used.
- Backends: GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante]
- Backends: GLFW: Fixed Windows specific hooks to use Unicode version of WndProc even when
compiling in MBCS mode. (#7174) [@kimidaisuki22]
- Backends: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs
vkDestroyCommandPool(). (#7075) [@FoonTheRaccoon]
- Examples: GLFW+Emscripten: Fixed examples not consistently resizing according to host canvas.
Expand Down

0 comments on commit 240ab58

Please sign in to comment.