Skip to content

Commit 06c2c9f

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdl2.cpp # backends/imgui_impl_sdl3.cpp
2 parents b811c42 + 43caca0 commit 06c2c9f

8 files changed

+90
-60
lines changed

backends/imgui_impl_sdl2.cpp

+27-20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
// (minor and older changes stripped away, please see git history for details)
2828
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
2929
// 2025-04-09: [Docking] Revert update monitors and work areas information every frame. Only do it on Windows. (#8415, #8558)
30+
// 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
3031
// 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
3132
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
3233
// 2025-02-26: Only start SDL_CaptureMouse() when mouse is being dragged, to mitigate issues with e.g.Linux debuggers not claiming capture back. (#6410, #3650)
@@ -161,6 +162,7 @@ struct ImGui_ImplSDL2_Data
161162
SDL_Cursor* MouseLastCursor;
162163
int MouseLastLeaveFrame;
163164
bool MouseCanUseGlobalState;
165+
bool MouseCanUseCapture;
164166
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
165167

166168
// Gamepad handling
@@ -521,39 +523,41 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
521523
IMGUI_CHECKVERSION();
522524
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
523525

524-
// Check and store if we are on a SDL backend that supports global mouse position
525-
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
526-
bool mouse_can_use_global_state = false;
527-
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
528-
const char* sdl_backend = SDL_GetCurrentVideoDriver();
529-
const char* global_mouse_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
530-
for (int n = 0; n < IM_ARRAYSIZE(global_mouse_whitelist); n++)
531-
if (strncmp(sdl_backend, global_mouse_whitelist[n], strlen(global_mouse_whitelist[n])) == 0)
532-
mouse_can_use_global_state = true;
533-
#endif
534-
535526
// Setup backend capabilities flags
536527
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
537528
io.BackendPlatformUserData = (void*)bd;
538529
io.BackendPlatformName = "imgui_impl_sdl2";
539530
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
540531
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
541-
if (mouse_can_use_global_state)
542-
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
532+
// (ImGuiBackendFlags_PlatformHasViewports may be set just below)
543533

544534
bd->Window = window;
545535
bd->WindowID = SDL_GetWindowID(window);
546536
bd->Renderer = renderer;
547537

548538
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
549539
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
550-
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
551540
#ifndef __APPLE__
552541
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
553542
#else
554543
bd->MouseCanReportHoveredViewport = false;
555544
#endif
556545

546+
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
547+
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
548+
bd->MouseCanUseGlobalState = false;
549+
bd->MouseCanUseCapture = false;
550+
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
551+
const char* sdl_backend = SDL_GetCurrentVideoDriver();
552+
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
553+
for (const char* item : capture_and_global_state_whitelist)
554+
if (strncmp(sdl_backend, item, strlen(item)) == 0)
555+
bd->MouseCanUseGlobalState = bd->MouseCanUseCapture = true;
556+
#endif
557+
if (bd->MouseCanUseGlobalState)
558+
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
559+
560+
557561
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
558562
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
559563
platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
@@ -701,12 +705,15 @@ static void ImGui_ImplSDL2_UpdateMouseData()
701705
// We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below)
702706
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
703707
// - SDL_CaptureMouse() let the OS know e.g. that our drags can extend outside of parent boundaries (we want updated position) and shouldn't trigger other operations outside.
704-
// - Debuggers under Linux tends to leave captured mouse on break, which may be very inconvenient, so to migitate the issue we wait until mouse has moved to begin capture.
705-
bool want_capture = false;
706-
for (int button_n = 0; button_n < ImGuiMouseButton_COUNT && !want_capture; button_n++)
707-
if (ImGui::IsMouseDragging(button_n, 1.0f))
708-
want_capture = true;
709-
SDL_CaptureMouse(want_capture ? SDL_TRUE : SDL_FALSE);
708+
// - Debuggers under Linux tends to leave captured mouse on break, which may be very inconvenient, so to mitigate the issue we wait until mouse has moved to begin capture.
709+
if (bd->MouseCanUseCapture)
710+
{
711+
bool want_capture = false;
712+
for (int button_n = 0; button_n < ImGuiMouseButton_COUNT && !want_capture; button_n++)
713+
if (ImGui::IsMouseDragging(button_n, 1.0f))
714+
want_capture = true;
715+
SDL_CaptureMouse(want_capture ? SDL_TRUE : SDL_FALSE);
716+
}
710717

711718
SDL_Window* focused_window = SDL_GetKeyboardFocus();
712719
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL2_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));

backends/imgui_impl_sdl3.cpp

+26-20
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// (minor and older changes stripped away, please see git history for details)
2626
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
2727
// 2025-04-09: [Docking] Revert update monitors and work areas information every frame. Only do it on Windows. (#8415, #8558)
28+
// 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
2829
// 2025-03-30: Update for SDL3 api changes: Revert SDL_GetClipboardText() memory ownership change. (#8530, #7801)
2930
// 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
3031
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
@@ -120,6 +121,7 @@ struct ImGui_ImplSDL3_Data
120121
SDL_Cursor* MouseLastCursor;
121122
int MousePendingLeaveFrame;
122123
bool MouseCanUseGlobalState;
124+
bool MouseCanUseCapture;
123125
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
124126

125127
// Gamepad handling
@@ -505,39 +507,40 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
505507
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
506508
IM_UNUSED(sdl_gl_context); // Unused in this branch
507509

508-
// Check and store if we are on a SDL backend that supports global mouse position
509-
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
510-
bool mouse_can_use_global_state = false;
511-
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
512-
const char* sdl_backend = SDL_GetCurrentVideoDriver();
513-
const char* global_mouse_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
514-
for (int n = 0; n < IM_ARRAYSIZE(global_mouse_whitelist); n++)
515-
if (strncmp(sdl_backend, global_mouse_whitelist[n], strlen(global_mouse_whitelist[n])) == 0)
516-
mouse_can_use_global_state = true;
517-
#endif
518-
519510
// Setup backend capabilities flags
520511
ImGui_ImplSDL3_Data* bd = IM_NEW(ImGui_ImplSDL3_Data)();
521512
io.BackendPlatformUserData = (void*)bd;
522513
io.BackendPlatformName = "imgui_impl_sdl3";
523514
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
524515
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
525-
if (mouse_can_use_global_state)
526-
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
516+
// (ImGuiBackendFlags_PlatformHasViewports may be set just below)
527517

528518
bd->Window = window;
529519
bd->WindowID = SDL_GetWindowID(window);
530520
bd->Renderer = renderer;
531521

532522
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
533523
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
534-
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
535524
#ifndef __APPLE__
536525
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
537526
#else
538527
bd->MouseCanReportHoveredViewport = false;
539528
#endif
540529

530+
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
531+
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
532+
bd->MouseCanUseGlobalState = false;
533+
bd->MouseCanUseCapture = false;
534+
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
535+
const char* sdl_backend = SDL_GetCurrentVideoDriver();
536+
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
537+
for (const char* item : capture_and_global_state_whitelist)
538+
if (strncmp(sdl_backend, item, strlen(item)) == 0)
539+
bd->MouseCanUseGlobalState = bd->MouseCanUseCapture = true;
540+
#endif
541+
if (bd->MouseCanUseGlobalState)
542+
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
543+
541544
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
542545
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
543546
platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
@@ -664,12 +667,15 @@ static void ImGui_ImplSDL3_UpdateMouseData()
664667
// We forward mouse input when hovered or captured (via SDL_EVENT_MOUSE_MOTION) or when focused (below)
665668
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
666669
// - SDL_CaptureMouse() let the OS know e.g. that our drags can extend outside of parent boundaries (we want updated position) and shouldn't trigger other operations outside.
667-
// - Debuggers under Linux tends to leave captured mouse on break, which may be very inconvenient, so to migitate the issue we wait until mouse has moved to begin capture.
668-
bool want_capture = false;
669-
for (int button_n = 0; button_n < ImGuiMouseButton_COUNT && !want_capture; button_n++)
670-
if (ImGui::IsMouseDragging(button_n, 1.0f))
671-
want_capture = true;
672-
SDL_CaptureMouse(want_capture);
670+
// - Debuggers under Linux tends to leave captured mouse on break, which may be very inconvenient, so to mitigate the issue we wait until mouse has moved to begin capture.
671+
if (bd->MouseCanUseCapture)
672+
{
673+
bool want_capture = false;
674+
for (int button_n = 0; button_n < ImGuiMouseButton_COUNT && !want_capture; button_n++)
675+
if (ImGui::IsMouseDragging(button_n, 1.0f))
676+
want_capture = true;
677+
SDL_CaptureMouse(want_capture);
678+
}
673679

674680
SDL_Window* focused_window = SDL_GetKeyboardFocus();
675681
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL3_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));

docs/CHANGELOG.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ Other changes:
5757
one in docking (they accidentally diverged). (#8554)
5858
- TreeNode: added flags to draw tree hierarchy outlines linking parent
5959
and tree nodes: (#2920)
60-
- ImGuiTreeNodeFlags_DrawLinesNone: No lines drawn.
60+
- ImGuiTreeNodeFlags_DrawLinesNone: No lines drawn (default value in style.TreeLinesFlags).
6161
- ImGuiTreeNodeFlags_DrawLinesFull: Horizontal lines to child nodes. Vertical line drawn down to TreePop() position: cover full contents.
6262
- ImGuiTreeNodeFlags_DrawLinesToNodes: Horizontal lines to child nodes. Vertical line drawn down to bottom-most child node.
6363
- Added style.TreeLinesFlags which stores the default setting,
6464
which may be overriden in individual TreeNode() calls.
6565
- Added style.TreeLinesSize (default to 1.0f).
6666
- Added ImGuiCol_TreeLines (in default style this is the same as ImGuiCol_Border).
67-
- The feature adds a little cost as extra data needs to be stored.
67+
- Caveats:
68+
- Tree nodes may be used in many creative ways (manually positioning openable
69+
nodes in unusual ways, using indent to create tree-looking structures, etc.)
70+
and the feature may not accurately represent them in every cases.
71+
- The feature adds a little cost as extra data needs to be stored.
6872
- Nav: fixed assertion when holding gamepad FaceLeft/West button to open
6973
CTRL+Tab windowing + pressing a keyboard key. (#8525)
7074
- Error Handling: added better error report and recovery for extraneous
@@ -77,6 +81,9 @@ Other changes:
7781
- Misc: added extra operators to ImVec4 in IMGUI_DEFINE_MATH_OPERATORS block. (#8510) [@gan74]
7882
- Backends: SDL2, SDL3, OSX: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad
7983
regardless of ImGuiConfigFlags_NavEnableGamepad being set. (#8508)
84+
- Backends: SDL2, SDL3: don't attempt to call SDL_CaptureMouse() on drivers where we don't
85+
call SDL_GetGlobalMouseState(). This is specifically for Wayland but we currently use
86+
the same white-list as SDL_GetGlobalMouseState(). (#8561) [@vs49688]
8087
- Backends: SDL3: Update for SDL3 api changes: revert SDL_GetClipboardText()
8188
memory ownership change. (#8530, #7801) [@Green-Sky]
8289
- Backends: SDLGPU3: Made ImGui_ImplSDLGPU3_PrepareDrawData() reuse GPU Transfer Buffers which

imgui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22444,9 +22444,9 @@ void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int wi
2244422444
ImFormatString(buf, IM_ARRAYSIZE(buf), "[%04d] Window", window->BeginOrderWithinContext);
2244522445
//BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name);
2244622446
DebugNodeWindow(window, buf);
22447-
Indent();
22447+
TreePush(buf);
2244822448
DebugNodeWindowsListByBeginStackParent(windows + i + 1, windows_size - i - 1, window);
22449-
Unindent();
22449+
TreePop();
2245022450
}
2245122451
}
2245222452

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// Library Version
3030
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3131
#define IMGUI_VERSION "1.92.0 WIP"
32-
#define IMGUI_VERSION_NUM 19192
32+
#define IMGUI_VERSION_NUM 19193
3333
#define IMGUI_HAS_TABLE
3434
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
3535
#define IMGUI_HAS_DOCK // Docking WIP branch

imgui_demo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8382,7 +8382,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
83828382
style.TreeLinesFlags = option;
83838383
ImGui::EndCombo();
83848384
}
8385-
ImGui::SliderFloat("TreeLinesSize", &style.TreeLinesSize, 0.0f, 1.0f, "%.0f");
8385+
ImGui::SliderFloat("TreeLinesSize", &style.TreeLinesSize, 0.0f, 2.0f, "%.0f");
83868386
ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0");
83878387
ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
83888388
ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.");

imgui_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -3768,6 +3768,7 @@ namespace ImGui
37683768

37693769
// Widgets: Tree Nodes
37703770
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
3771+
IMGUI_API void TreeNodeDrawLineToChildNode(const ImVec2& target_pos);
37713772
IMGUI_API void TreePushOverrideID(ImGuiID id);
37723773
IMGUI_API bool TreeNodeGetOpen(ImGuiID storage_id);
37733774
IMGUI_API void TreeNodeSetOpen(ImGuiID storage_id, bool open);

0 commit comments

Comments
 (0)