feat(window): recover off-screen position after display layout change

Persisted ImGui window position can end up off-screen when the user
disconnects a monitor or changes display resolution between sessions.
The chat log window then renders outside the visible viewport with no
drag handles available, and the only recovery path is editing the JSON
config by hand.

This commit adds two layers of safety:

- Automatic one-shot bounds check on the first draw after plugin load.
  If less than 100x40 pixels of the saved window position overlap the
  primary viewport, the window snaps to a safe default offset
  (top-left + 50px). Logged at INF level so users can verify the
  recovery happened.
- Manual "Reset Window Position" button in Settings -> Window -> Frame
  as a deliberate escape hatch when anything else slips past the
  automatic check (different DPI scaling, viewport edge cases).

Pop-outs are intentionally not part of this recovery path: they are
non-persistent (cleared on plugin reload) and therefore cannot survive
a session boundary in an off-screen state.

Tested on Linux/Wayland (KAZAMA, Plasma, 3-monitor setup): hard-cut
test with both auxiliary monitors physically disconnected between
sessions reproduces the off-screen window before the patch and
recovers cleanly with this fix in place.
This commit is contained in:
2026-05-04 12:01:43 +02:00
parent 176474ec2a
commit 7012e8c0d8
5 changed files with 92 additions and 0 deletions
+9
View File
@@ -142,6 +142,15 @@ internal sealed class Window : ISettingsTab
ImGui.Checkbox(Language.Options_SidebarTabView_Name, ref Mutable.SidebarTabView);
ImGuiUtil.HelpMarker(string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName));
ImGui.Spacing();
// Manual escape hatch for off-screen windows. The plugin already
// runs an automatic bounds check once per session, but a button
// is the user-friendly fallback after a display layout change.
if (ImGui.Button(HellionStrings.Settings_Window_ResetPosition_Name))
Plugin.ChatLogWindow.RequestPositionReset = true;
ImGuiUtil.HelpMarker(HellionStrings.Settings_Window_ResetPosition_Description);
}
}