Skip to content

Fix file browser modal opening off-screen on smaller/4:3 displays#96

Open
gjforte wants to merge 1 commit into
pkhead:mainfrom
gjforte:fix/filebrowser-offscreen-small-display
Open

Fix file browser modal opening off-screen on smaller/4:3 displays#96
gjforte wants to merge 1 commit into
pkhead:mainfrom
gjforte:fix/filebrowser-offscreen-small-display

Conversation

@gjforte

@gjforte gjforte commented Jun 26, 2026

Copy link
Copy Markdown

Problem

On a smaller (e.g. 4:3 laptop) display, the Open/Save file browser fails to display and blocks the whole app: being modal, it eats all input, but its title bar and the OK/Cancel buttons are off the bottom of the screen, so there's no way to interact with or dismiss it.

Cause

The file browser popup persists its size in imgui.ini, but SetNextWindowSize clamps to the display only with ImGuiCond.FirstUseEver:

windowSize.Y = Math.Min(ImGui.GetMainViewport().WorkSize.Y - 50f, windowSize.Y);
ImGui.SetNextWindowSize(windowSize, ImGuiCond.FirstUseEver);

When the same config is reused across machines (or after moving from a larger monitor to a smaller one), the size saved on the large display is restored verbatim — FirstUseEver never re-clamps it — so the modal opens taller than the current screen with its controls off-screen.

Fix

Add SetNextWindowSizeConstraints(min, viewport.WorkSize) before BeginPopupModal every frame, so the window can never exceed the current display regardless of what's stored in imgui.ini. Position is already re-centered on appear, so that side was already fine. No behavior change on displays large enough to hold the default size.

One file changed (src/Rained/EditorGui/FileBrowser.cs).

The file browser popup persists its size in imgui.ini, but SetNextWindowSize
only clamped it to the display on FirstUseEver. When the same config is used
across machines, a size saved on a large monitor is restored verbatim on a
smaller/4:3 screen, opening the modal taller than the display with its title
bar and OK/Cancel buttons off-screen. Being modal, it then blocks all input
while appearing not to render.

Add SetNextWindowSizeConstraints(min, viewport.WorkSize) before BeginPopupModal
each frame so the window can never exceed the current display. Position was
already re-centered on appear.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant