diff --git a/TODO.txt b/TODO.txt index 3fff67ed4..69f88df71 100644 --- a/TODO.txt +++ b/TODO.txt @@ -262,6 +262,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - viewport: platform: introduce getfocus/setfocus api, so e.g. focus flags can be honored, imgui-side ctrl-tab can focus os window, OS alt-tab can focus imgui window etc. - viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for. - viewport: vulkan renderer implementation. + - viewport: fallback calculation of hovered window is very currently wrong without ImGuiBackendFlags_HasMouseHoveredViewport. typically affect half-overlapping viewported menus. - viewport: need to clarify how to use GetMousePos() from a user point of view. - inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors. diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index db6f99d65..2201bb769 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -504,7 +504,9 @@ void ImGui_ImplDX10_NewFrame() } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataDx10 @@ -581,11 +583,7 @@ static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) ID3D10Texture2D* pBackBuffer = NULL; data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0); data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - if (pBackBuffer == NULL) - { - fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() can't created buffers.\n"); - return; - } + if (pBackBuffer == NULL) { fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() failed creating buffers.\n"); return; } g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView); pBackBuffer->Release(); } diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 9f5b38249..d9308e040 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -512,7 +512,9 @@ void ImGui_ImplDX11_NewFrame() } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataDx11 @@ -589,11 +591,7 @@ static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) ID3D11Texture2D* pBackBuffer = NULL; data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0); data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - if (pBackBuffer == NULL) - { - fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() can't created buffers.\n"); - return; - } + if (pBackBuffer == NULL) { fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() failed creating buffers.\n"); return; } g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView); pBackBuffer->Release(); } diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index 9ae3a0d3f..76d17b855 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -637,7 +637,9 @@ void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list) } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataDx12 diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index 0c74aa2ca..cd04bc485 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -317,9 +317,11 @@ void ImGui_ImplGlfw_NewFrame() ImGui::NewFrame(); } -// -------------------------------------------------------------------------------------------------------- -// Platform Windows -// -------------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------------- +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. +//-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataGlfw { diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index f4d848a8a..e43b20efa 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -211,7 +211,9 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects() } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- static void ImGui_ImplOpenGL2_RenderWindow(ImGuiViewport* viewport, void*) diff --git a/examples/imgui_impl_opengl3.cpp b/examples/imgui_impl_opengl3.cpp index 99012c83e..5217408ff 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/examples/imgui_impl_opengl3.cpp @@ -330,7 +330,9 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects() } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*) diff --git a/examples/imgui_impl_sdl2.cpp b/examples/imgui_impl_sdl2.cpp index 6b25e9064..089761bb2 100644 --- a/examples/imgui_impl_sdl2.cpp +++ b/examples/imgui_impl_sdl2.cpp @@ -276,7 +276,9 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataSDL2 diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index 4824b0b1c..9f46f04bb 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -1059,7 +1059,10 @@ void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, I } //-------------------------------------------------------------------------------------------------------- -// Platform Interface (Optional, for multi-viewport support) +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. +//-------------------------------------------------------------------------------------------------------- // FIXME-PLATFORM: Vulkan support unfinished //-------------------------------------------------------------------------------------------------------- diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index b90b7a267..b4412d0ed 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -390,7 +390,9 @@ static void ImGui_ImplWin32_SetImeInputPos(ImGuiViewport* viewport, ImVec2 pos) #endif //-------------------------------------------------------------------------------------------------------- -// Platform Windows +// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT +// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- struct ImGuiViewportDataWin32 diff --git a/imgui.cpp b/imgui.cpp index cbdc1fe1b..064b1937f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3357,7 +3357,11 @@ static void ImGui::UpdateMovingWindow() { UpdateTryMergeWindowIntoHostViewport(moving_window, g.MouseRefViewport); - // Clear the NoInput flag set by the Viewport system + // Patch the mouse viewport so that we don't hover under the moved window during the mouse released frame + if (!IsDragDropPayloadBeingAccepted()) + g.MouseRefViewport = moving_window->Viewport; + + // Clear the NoInput window flag set by the Viewport system moving_window->Viewport->Flags &= ~ImGuiViewportFlags_NoInputs; ClearActiveID();