diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp index 3bafa5d1..d61d96a4 100644 --- a/backends/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -923,8 +923,11 @@ struct ImGui_ImplGlfw_ViewportData bool WindowOwned; int IgnoreWindowPosEventFrame; int IgnoreWindowSizeEventFrame; +#ifdef _WIN32 + WNDPROC PrevWndProc; +#endif - ImGui_ImplGlfw_ViewportData() { Window = nullptr; WindowOwned = false; IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; } + ImGui_ImplGlfw_ViewportData() { memset(this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; } ~ImGui_ImplGlfw_ViewportData() { IM_ASSERT(Window == nullptr); } }; @@ -1059,9 +1062,8 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport) // GLFW hack: install hook for WM_NCHITTEST message handler #if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32) - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); ::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport); - IM_ASSERT(bd->PrevWndProc == (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC)); + vd->PrevWndProc = (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC); ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc); #endif @@ -1263,6 +1265,12 @@ static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo() static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); + WNDPROC prev_wndproc = bd->PrevWndProc; + ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT"); + if (viewport != NULL) + if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData) + prev_wndproc = vd->PrevWndProc; + switch (msg) { // GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen. @@ -1284,14 +1292,13 @@ static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wPara // The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging. // If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in // your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system. - ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT"); if (viewport && (viewport->Flags & ImGuiViewportFlags_NoInputs)) return HTTRANSPARENT; break; } #endif } - return ::CallWindowProc(bd->PrevWndProc, hWnd, msg, wParam, lParam); + return ::CallWindowProc(prev_wndproc, hWnd, msg, wParam, lParam); } #endif // #ifdef _WIN32 diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e3b5ef52..9f6255db 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -126,12 +126,10 @@ Docking+Viewports Branch: - Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit. - Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode. - Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit. - -Docking+Viewports Branch: - -- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) - on success would prevent further filter from running, namely the one that prevent - docking over a popup. +- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would + prevent further filter from running, namely the one that prevent docking over a popup. +- Backends: GLFW: Fixed an assertion in situation where the WndProc handler is different between + main and secondary viewport (may happen due to third-party hooks). (#6889) -----------------------------------------------------------------------