From d55608a5bb8c8a6890957b9e216f969c9407265b Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2026 23:39:09 +0200 Subject: [PATCH] Viewports: added opaque `void* PlatformIconData` storage in viewport and ImGuiWindowClass to allow passing icon information to a custom backend or hook. (#2715) --- docs/CHANGELOG.txt | 6 ++++++ imgui.cpp | 2 ++ imgui.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 82ad85ceb..f8f75bf45 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -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) diff --git a/imgui.cpp b/imgui.cpp index 44396a7ff..5ad8ea501 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -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) diff --git a/imgui.h b/imgui.h index 36112b637..e14ef3ca0 100644 --- a/imgui.h +++ b/imgui.h @@ -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.