Skip to content

Multi-viewport: window constrained to main viewport moves if it goes outside of viewport  #7985

Closed
@EmilDohne

Description

Version/Branch of Dear ImGui:

Version 1.90.5, Branch: docking

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

No response

Details:

My Issue/Question:

I noticed that my window, which is constrained to the main viewport, created in a Multi-viewport environment "moves" (stays in place) when I move the main viewport window. It only does this if the window is partially outside of the main viewport. I did this constraining using a hack I found on here by setting the next window viewport (see the code example).

I'm not sure if this is the best way to go about it and I'm also happy to accept a solution that constrains the window to the main viewport and doesnt let it go outside in the first place as that would actually be the preferred behaviour.

Thanks in advance! Let me know if anything is unclear :)

Screenshots/Video:

devenv_ZPnUHWqqX0

Minimal, Complete and Verifiable Example code:

ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID); // Disable this widget from popping out
ImGuiWindowFlags window_flags = 
    ImGuiWindowFlags_NoCollapse 
    | ImGuiWindowFlags_NoBringToFrontOnFocus
    | ImGuiWindowFlags_NoDocking;
ImGui::Begin((std::string(ICON_FA_GRIP_LINES) + " Layer Stack").c_str(), nullptr, window_flags);
// Left out for brevity
ImGui::End();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions