Viewports: added opaque void* PlatformIconData storage in viewport and ImGuiWindowClass to allow passing icon information to a custom backend or hook. (#2715)

This commit is contained in:
ocornut
2026-04-09 23:39:09 +02:00
parent bbcc83e999
commit d55608a5bb
3 changed files with 10 additions and 0 deletions

View File

@@ -66,6 +66,12 @@ Other Changes:
- Metal: avoid redundant vertex buffer bind in SetupRenderState, which leads
to validation issue. (#9343) [@Hunam6]
Docking+Viewports Branch:
- Viewports:
- Added opaque `void* PlatformIconData` storage in viewport and ImGuiWindowClass
to allow passing icon information to a custom backend or hook. (#2715)
-----------------------------------------------------------------------
VERSION 1.92.7 (Released 2026-04-02)

View File

@@ -17377,6 +17377,8 @@ void ImGui::WindowSyncOwnedViewport(ImGuiWindow* window, ImGuiWindow* parent_win
window->Viewport->Flags = viewport_flags;
window->Viewport->PlatformIconData = window->WindowClass.PlatformIconData;
// Update parent viewport ID
// (the !IsFallbackWindow test mimic the one done in WindowSelectViewport())
if (window->WindowClass.ParentViewportId != (ImGuiID)-1)

View File

@@ -2809,6 +2809,7 @@ struct ImGuiWindowClass
ImGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
bool DockingAlwaysTabBar; // Set to true to enforce single floating windows of this class always having their own docking node (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window. // FIXME-DOCK: Move to DockNodeFlags override?
void* PlatformIconData; // [EXPERIMENTAL] Pass opaque data for Platform backend to handle.
ImGuiWindowClass() { memset((void*)this, 0, sizeof(*this)); ParentViewportId = (ImGuiID)-1; DockingAllowUnclassed = true; }
};
@@ -4121,6 +4122,7 @@ struct ImGuiViewport
// The library never uses those fields, they are merely storage to facilitate backend implementation.
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
void* PlatformIconData; // void* to hold custom data structure for the OS / platform to specify an icon. Currently unused for exposed to allow experiments.
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND for Win32 backend, Uint32 WindowID for SDL, GLFWWindow* for GLFW), for FindViewportByPlatformHandle().
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (always HWND on Win32 platform, unused for other platforms).
bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.