From 06ed617a632dcee4f6c27864550b32f7552eb160 Mon Sep 17 00:00:00 2001 From: hatimhtm <106043141+hatimhtm@users.noreply.github.com> Date: Sat, 21 Mar 2026 10:44:21 +0000 Subject: [PATCH] perf: Optimize isActiveAppFullscreen using .contains(where:) Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- Click2Minimize/AppDelegate.swift | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Click2Minimize/AppDelegate.swift b/Click2Minimize/AppDelegate.swift index 55a4109..3dd872f 100644 --- a/Click2Minimize/AppDelegate.swift +++ b/Click2Minimize/AppDelegate.swift @@ -240,17 +240,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { } private func isActiveAppFullscreen() -> Bool { - // Get the list of windows for the active application - let windows = NSApplication.shared.windows.filter { $0.isVisible && $0.isKeyWindow } - - // Check if any window is in fullscreen mode - for window in windows { - if window.styleMask.contains(.fullSizeContentView) { - return true - } - } - - return false + // Check if any visible, key window is in fullscreen mode + return NSApplication.shared.windows.contains(where: { + $0.isVisible && $0.isKeyWindow && $0.styleMask.contains(.fullSizeContentView) + }) } // Define a struct to hold the dock item information