From 83e4db24fe730532348657a0ec2ded90a042e2e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Feb 2026 04:15:24 +0000 Subject: [PATCH] Fix null check logic for screen detection Co-authored-by: emako <24737061+emako@users.noreply.github.com> --- QuickLook/ViewerWindow.Actions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/QuickLook/ViewerWindow.Actions.cs b/QuickLook/ViewerWindow.Actions.cs index 6fc9ced..713f7e1 100644 --- a/QuickLook/ViewerWindow.Actions.cs +++ b/QuickLook/ViewerWindow.Actions.cs @@ -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; }