Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL3 backend: phantom window frame on viewport creation when NoDecoration is disabled #8328

Open
RT2Code opened this issue Jan 18, 2025 · 4 comments

Comments

@RT2Code
Copy link

RT2Code commented Jan 18, 2025

Version/Branch of Dear ImGui:

Version 1.91.7 Branch: docking

Back-ends:

imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows 11 + MSVC 22

Full config/build information:

Dear ImGui 1.91.7 (19170)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1942
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl3
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00000483
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoAutoMerge
io.ConfigViewportsNoTaskBarIcon
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 4 fonts, Flags: 0x00000000, TexSize: 512,256
io.DisplaySize: 800.00,1000.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

When the NoDecoration flag is disabled and a window is dragged outside the main viewport, the frame of the newly created window appears for one frame in the top-left corner of the screen.

Screenshots/Video:

Screen.Recording.2024-09-17.195208-1.mp4

Minimal, Complete and Verifiable Example code:

io.ConfigViewportsNoAutoMerge = false;
io.ConfigViewportsNoDecoration= false;
@RT2Code RT2Code changed the title Phantom window frame on viewport creation Phantom window frame on viewport creation when NoDecoration is disabled Jan 18, 2025
@PathogenDavid
Copy link
Contributor

I didn't have a change to test, but I suspect this happens because the SDL3 backend is missing SDL_WINDOW_HIDDEN here:

SDL_WindowFlags sdl_flags = 0;
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
sdl_flags |= SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_HIGH_PIXEL_DENSITY;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
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);

Which is used in the SDL2 backend, probably for this reason:

sdl_flags |= SDL_WINDOW_HIDDEN;

@ocornut ocornut changed the title Phantom window frame on viewport creation when NoDecoration is disabled SDL3 backend: phantom window frame on viewport creation when NoDecoration is disabled Jan 20, 2025
@ocornut
Copy link
Owner

ocornut commented Jan 20, 2025

This is really bizarre indeed, it has been missing from a526ff8...I wonder if at the time it was missing of SDL3's wip CreateWindow didn't show the window. Rémy could you confirm if that's your issue? (as I cannot repro here). Thanks David!

@RT2Code
Copy link
Author

RT2Code commented Jan 22, 2025

This issue is not visually consistent, I can see it most of the time I drag a viewport outside the main window, but not always. I tried, and it still happens with SDL_WINDOW_HIDDEN, albeit less often.

@ocornut
Copy link
Owner

ocornut commented Jan 22, 2025

I'll add the SDL_WINDOW_HIDDEN flag either way for now.

ocornut pushed a commit that referenced this issue Jan 22, 2025
…HIDDEN flag before calling SDL_ShowWindow(). (#8328

Unsure why it was missing from a526ff8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants