Skip to content

Commit a177ac2

Browse files
authored
Merge branch 'ocornut:docking' into docking
2 parents 49da9ba + 368123a commit a177ac2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2012
-778
lines changed

backends/imgui_impl_allegro5.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Implemented features:
55
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
6-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
6+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
77
// [X] Platform: Clipboard support (from Allegro 5.1.12)
88
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
99
// Missing features:
@@ -312,6 +312,7 @@ static void ImGui_ImplAllegro5_SetClipboardText(ImGuiContext*, const char* text)
312312
#endif
313313

314314
// Not static to allow third-party code to use that if they want to (but undocumented)
315+
ImGuiKey ImGui_ImplAllegro5_KeyCodeToImGuiKey(int key_code);
315316
ImGuiKey ImGui_ImplAllegro5_KeyCodeToImGuiKey(int key_code)
316317
{
317318
switch (key_code)

backends/imgui_impl_allegro5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Implemented features:
55
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
6-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
6+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
77
// [X] Platform: Clipboard support (from Allegro 5.1.12)
88
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
99
// Missing features:

backends/imgui_impl_android.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
33

44
// Implemented features:
5-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
5+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
66
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen.
77
// Missing features:
88
// [ ] Platform: Clipboard support.

backends/imgui_impl_android.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
33

44
// Implemented features:
5-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
5+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
66
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen.
77
// Missing features:
88
// [ ] Platform: Clipboard support.

backends/imgui_impl_dx10.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame();
2727
IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
2828

2929
// Use if you want to reset your rendering device without losing Dear ImGui state.
30-
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
3130
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
31+
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
3232

3333
#endif // #ifndef IMGUI_DISABLE

backends/imgui_impl_dx11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
2626
// 2021-02-18: DirectX11: Change blending equation to preserve alpha in output buffer.
2727
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
28-
// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
28+
// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX11_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
2929
// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
3030
// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
3131
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().

backends/imgui_impl_dx11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
3030
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
3131

3232
// Use if you want to reset your rendering device without losing Dear ImGui state.
33-
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
3433
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
34+
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
3535

3636
// [BETA] Selected render state data shared with callbacks.
3737
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX11_RenderDrawData() call.

backends/imgui_impl_dx12.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// CHANGELOG
2020
// (minor and older changes stripped away, please see git history for details)
2121
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
22+
// 2024-10-23: DirectX12: Unmap() call specify written range. The range is informational and may be used by debug tools.
2223
// 2024-10-07: DirectX12: Changed default texture sampler to Clamp instead of Repeat/Wrap.
2324
// 2024-10-07: DirectX12: Expose selected render state in ImGui_ImplDX12_RenderState, which you can access in 'void* platform_io.Renderer_RenderState' during draw callbacks.
2425
// 2024-10-07: DirectX12: Compiling with '#define ImTextureID=ImU64' is unnecessary now that dear imgui defaults ImTextureID to u64 instead of void*.
@@ -293,9 +294,9 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
293294
}
294295

295296
// Upload vertex/index data into a single contiguous GPU buffer
297+
// During Map() we specify a null read range (as per DX12 API, this is informational and for tooling only)
296298
void* vtx_resource, *idx_resource;
297-
D3D12_RANGE range;
298-
memset(&range, 0, sizeof(D3D12_RANGE));
299+
D3D12_RANGE range = { 0, 0 };
299300
if (fr->VertexBuffer->Map(0, &range, &vtx_resource) != S_OK)
300301
return;
301302
if (fr->IndexBuffer->Map(0, &range, &idx_resource) != S_OK)
@@ -310,7 +311,13 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
310311
vtx_dst += draw_list->VtxBuffer.Size;
311312
idx_dst += draw_list->IdxBuffer.Size;
312313
}
314+
315+
// During Unmap() we specify the written range (as per DX12 API, this is informational and for tooling only)
316+
range.End = (SIZE_T)((intptr_t)vtx_dst - (intptr_t)vtx_resource);
317+
IM_ASSERT(range.End == draw_data->TotalVtxCount * sizeof(ImDrawVert));
313318
fr->VertexBuffer->Unmap(0, &range);
319+
range.End = (SIZE_T)((intptr_t)idx_dst - (intptr_t)idx_resource);
320+
IM_ASSERT(range.End == draw_data->TotalIdxCount * sizeof(ImDrawIdx));
314321
fr->IndexBuffer->Unmap(0, &range);
315322

316323
// Setup desired DX state

backends/imgui_impl_dx12.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
3838
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
3939

4040
// Use if you want to reset your rendering device without losing Dear ImGui state.
41-
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
4241
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
42+
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
4343

4444
// [BETA] Selected render state data shared with callbacks.
4545
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX12_RenderDrawData() call.

backends/imgui_impl_glfw.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Implemented features:
77
// [X] Platform: Clipboard support.
88
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
9-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
9+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
1010
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
1111
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
1212
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
@@ -29,6 +29,7 @@
2929
// CHANGELOG
3030
// (minor and older changes stripped away, please see git history for details)
3131
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
32+
// 2024-11-05: [Docking] Added Linux workaround for spurious mouse up events emitted while dragging and creating new viewport. (#3158, #7733, #7922)
3233
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
3334
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
3435
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
@@ -172,6 +173,8 @@ struct ImGui_ImplGlfw_Data
172173
double Time;
173174
GLFWwindow* MouseWindow;
174175
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
176+
bool MouseIgnoreButtonUpWaitForFocusLoss;
177+
bool MouseIgnoreButtonUp;
175178
ImVec2 LastValidMousePos;
176179
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
177180
bool InstalledCallbacks;
@@ -220,6 +223,7 @@ static void ImGui_ImplGlfw_ShutdownMultiViewportSupport();
220223
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
221224

222225
// Not static to allow third-party code to use that if they want to (but undocumented)
226+
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
223227
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode)
224228
{
225229
IM_UNUSED(scancode);
@@ -369,6 +373,10 @@ void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int acti
369373
if (bd->PrevUserCallbackMousebutton != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
370374
bd->PrevUserCallbackMousebutton(window, button, action, mods);
371375

376+
// Workaround for Linux: ignore mouse up events which are following an focus loss following a viewport creation
377+
if (bd->MouseIgnoreButtonUp && action == GLFW_RELEASE)
378+
return;
379+
372380
ImGui_ImplGlfw_UpdateKeyModifiers(window);
373381

374382
ImGuiIO& io = ImGui::GetIO();
@@ -453,6 +461,10 @@ void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
453461
if (bd->PrevUserCallbackWindowFocus != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
454462
bd->PrevUserCallbackWindowFocus(window, focused);
455463

464+
// Workaround for Linux: when losing focus with MouseIgnoreButtonUpWaitForFocusLoss set, we will temporarily ignore subsequent Mouse Up events
465+
bd->MouseIgnoreButtonUp = (bd->MouseIgnoreButtonUpWaitForFocusLoss && focused == 0);
466+
bd->MouseIgnoreButtonUpWaitForFocusLoss = false;
467+
456468
ImGuiIO& io = ImGui::GetIO();
457469
io.AddFocusEvent(focused != 0);
458470
}
@@ -967,6 +979,7 @@ void ImGui_ImplGlfw_NewFrame()
967979
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
968980
bd->Time = current_time;
969981

982+
bd->MouseIgnoreButtonUp = false;
970983
ImGui_ImplGlfw_UpdateMouseData();
971984
ImGui_ImplGlfw_UpdateMouseCursor();
972985

@@ -1106,6 +1119,11 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
11061119
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
11071120
viewport->PlatformUserData = vd;
11081121

1122+
// Workaround for Linux: ignore mouse up events corresponding to losing focus of the previously focused window (#7733, #3158, #7922)
1123+
#ifdef __linux__
1124+
bd->MouseIgnoreButtonUpWaitForFocusLoss = true;
1125+
#endif
1126+
11091127
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
11101128
// With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem
11111129
glfwWindowHint(GLFW_VISIBLE, false);

0 commit comments

Comments
 (0)