mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-21 17:31:45 +00:00
Backends: GLFW: support for case where secondary viewport WndProc is not the same as main viewport one. (#6889)
This commit is contained in:
@@ -923,8 +923,11 @@ struct ImGui_ImplGlfw_ViewportData
|
|||||||
bool WindowOwned;
|
bool WindowOwned;
|
||||||
int IgnoreWindowPosEventFrame;
|
int IgnoreWindowPosEventFrame;
|
||||||
int IgnoreWindowSizeEventFrame;
|
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); }
|
~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
|
// GLFW hack: install hook for WM_NCHITTEST message handler
|
||||||
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
|
||||||
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
::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);
|
::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1263,6 +1265,12 @@ static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
|||||||
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
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)
|
switch (msg)
|
||||||
{
|
{
|
||||||
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
|
// 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.
|
// 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
|
// 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.
|
// 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))
|
if (viewport && (viewport->Flags & ImGuiViewportFlags_NoInputs))
|
||||||
return HTTRANSPARENT;
|
return HTTRANSPARENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return ::CallWindowProc(bd->PrevWndProc, hWnd, msg, wParam, lParam);
|
return ::CallWindowProc(prev_wndproc, hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
#endif // #ifdef _WIN32
|
#endif // #ifdef _WIN32
|
||||||
|
|
||||||
|
@@ -126,12 +126,10 @@ Docking+Viewports Branch:
|
|||||||
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
|
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.
|
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.
|
||||||
- Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit.
|
- Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
|
- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would
|
||||||
Docking+Viewports Branch:
|
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
|
||||||
- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass)
|
main and secondary viewport (may happen due to third-party hooks). (#6889)
|
||||||
on success would prevent further filter from running, namely the one that prevent
|
|
||||||
docking over a popup.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user