Fix null check logic for screen detection

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-13 04:15:24 +00:00
parent 553c3431c7
commit 83e4db24fe

View File

@@ -105,10 +105,14 @@ public partial class ViewerWindow
}
// Get the screen bounds where the window is currently located
var screen = WinForms.Screen.FromHandle(new WindowInteropHelper(this).Handle) ?? WinForms.Screen.PrimaryScreen;
// Screen.FromHandle never returns null, but PrimaryScreen can be null in edge cases
var screen = WinForms.Screen.FromHandle(new WindowInteropHelper(this).Handle);
if (screen == null)
screen = WinForms.Screen.PrimaryScreen;
if (screen == null)
{
// Fallback to default screen bounds if no screen is available
// Edge case: no screen available (e.g., no monitors connected)
Debug.WriteLine("Unable to get screen bounds for fullscreen mode");
return;
}