Backends: SDL3: rework implementation of ImGuiViewportFlags_NoTaskBarIcon. (#7989)

This commit is contained in:
RT2 2024-09-15 19:57:37 +02:00 committed by ocornut
parent 8ba7efb738
commit 1ab1e3c656
2 changed files with 7 additions and 8 deletions

View File

@ -951,10 +951,7 @@ static void ImGui_ImplSDL3_CreateWindow(ImGuiViewport* viewport)
sdl_flags |= SDL_GetWindowFlags(bd->Window);
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
#if !defined(_WIN32)
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
#endif
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
SDL_SetWindowParent(vd->Window, vd->ParentWindow);
@ -992,13 +989,14 @@ static void ImGui_ImplSDL3_ShowWindow(ImGuiViewport* viewport)
#if defined(_WIN32)
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
// SDL hack: Hide icon from task bar
// Note: SDL 3.0.0+ has a SDL_WINDOW_UTILITY flag which is supported under Windows but the way it create the window breaks our seamless transition.
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
// SDL hack: Show icon in task bar (#7989)
// Note: SDL_WINDOW_UTILITY can be used to control task bar visibility, but on Windows, it does not affect child windows.
if (!(viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon))
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;
ex_style |= WS_EX_TOOLWINDOW;
ex_style |= WS_EX_APPWINDOW;
ex_style &= ~WS_EX_TOOLWINDOW;
::ShowWindow(hwnd, SW_HIDE);
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
}
#endif

View File

@ -86,6 +86,7 @@ Docking+Viewports Branch:
mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)
- Backends: SDL3: added support for viewport->ParentViewportId field to support parenting
windows at OS level. (#7973) [@RT2code]
- Backends: SDL3: rework implementation of _NoTaskBarIcon. (#7989) [@RT2code]
-----------------------------------------------------------------------
VERSION 1.91.1 (Released 2024-09-04)