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

ConfigWindowsMoveFromTitleBarOnly flag prevents dragging windows across vertically arranged displays. #7299

Closed
lailoken opened this issue Feb 7, 2024 · 6 comments

Comments

@lailoken
Copy link

lailoken commented Feb 7, 2024

Version/Branch of Dear ImGui:

Version 1.90

Back-ends:

imgui_impl_dx11.cpp

Compiler, OS:

Windows 11 + MSVC 2017

Full config/build information:

Dear ImGui 1.90.0 (19000)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 4, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: IMGUI_DISABLE_OBSOLETE_KEYIO
define: _WIN32
define: _WIN64
define: _MSC_VER=1938
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00004441
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
 DpiEnableScaleViewports
io.ConfigViewportsNoDecoration
io.ConfigDockingWithShift
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 9 fonts, Flags: 0x00000000, TexSize: 2048,2048
io.DisplaySize: 1912.00,1332.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 3.00,3.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,2.00
style.FrameRounding: 0.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 6.00,3.00
style.ItemInnerSpacing: 3.00,3.00

Details:

When I have a displays arranged vertically (one above another), I am unable to drag windows from a lower display to a higher display.

I have found that this is due to the following line:

io.ConfigWindowsMoveFromTitleBarOnly = true;

And when I set that to false it works again.
(Also, when it is true, dragging a window down into a lower display works well until the window is about halfway into the lower display, when it suddenly jumps the entire window onto the lower display)

I also notice that toggling: ConfigViewportsNoDecoration to false (showing windows default decoration) fixes it.

Screenshots/Video:

image

Minimal, Complete and Verifiable Example code:

No response

@ocornut
Copy link
Owner

ocornut commented Feb 7, 2024

Just in case, can you report the coordinates of all monitors as reported in Metrics->Viewport?

@lailoken
Copy link
Author

lailoken commented Feb 7, 2024

I've tried with monitor both below and above my main (3) display, same problem:

image

image

@ocornut
Copy link
Owner

ocornut commented Feb 7, 2024

I currently don't have multiple monitors to test with, but I guess this is causing the issue:

            else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
            {
                // Lost windows (e.g. a monitor disconnected) will naturally moved to the fallback/dummy monitor aka the main viewport.
                const ImGuiPlatformMonitor* monitor = GetViewportPlatformMonitor(window->Viewport);
                visibility_rect.Min = monitor->WorkPos + visibility_padding;
                visibility_rect.Max = monitor->WorkPos + monitor->WorkSize - visibility_padding;
                ClampWindowPos(window, visibility_rect);
            }
static inline void ClampWindowPos(ImGuiWindow* window, const ImRect& visibility_rect)
{
    ImGuiContext& g = *GImGui;
    ImVec2 size_for_clamping = window->Size;
    if (g.IO.ConfigWindowsMoveFromTitleBarOnly && (!(window->Flags & ImGuiWindowFlags_NoTitleBar) || window->DockNodeAsHost))
        size_for_clamping.y = ImGui::GetFrameHeight(); // Not using window->TitleBarHeight() as DockNodeAsHost will report 0.0f here.
    window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max);
}

Our way of clamping position use monitor boundaries. Problem is that we can have rectangular boundaries encompassing all monitors area, so we may need to do thing differently while moving a window vs when not moving it.
While moving we could use the bounding box of all monitors.

@ocornut
Copy link
Owner

ocornut commented Feb 7, 2024

Actually same as #3071

@lailoken
Copy link
Author

lailoken commented Feb 7, 2024

I'll follow the other ticket. (missed it)

ocornut added a commit that referenced this issue Feb 9, 2024
@ocornut
Copy link
Owner

ocornut commented Feb 9, 2024

Should be fixed with 30ba3c3 !

@ocornut ocornut closed this as completed Feb 9, 2024
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

2 participants