Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

fix(macos): app no longer quits when the menu bar icon menu is dismissed (#233)

AnoF-Cyber8133303e9caf
diff --git a/MacOS/ProxyBridge/ProxyBridge/ProxyBridgeGUI.swift b/MacOS/ProxyBridge/ProxyBridge/ProxyBridgeGUI.swift
index 9743327..81e78e3 100644
--- a/MacOS/ProxyBridge/ProxyBridge/ProxyBridgeGUI.swift
+++ b/MacOS/ProxyBridge/ProxyBridge/ProxyBridgeGUI.swift
@@ -265,11 +265,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
}
}
- // if close-to-menu-bar is off, quitting on last window close matches the
- // windows "close = exit" behavior. when on, the window only hides so this
- // never fires.
+ // never let AppKit decide this. it counts every window, including the one
+ // behind the menu bar item, and on macOS 26 dismissing that menu looks like
+ // the last window closing, so the app quit when you clicked away from it
+ // (#233). the main window's own close decides instead, see windowWillClose.
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
- return !closeToMenuBar
+ return false
+ }
+
+ // close-to-menu-bar off: closing the main window quits, matching the windows
+ // "close = exit" behavior. when on, windowShouldClose hides the window instead
+ // so this never fires.
+ func windowWillClose(_ notification: Notification) {
+ guard let window = notification.object as? NSWindow,
+ window === AppDelegate.mainWindow,
+ !closeToMenuBar else { return }
+ NSApp.terminate(nil)
}
// the window's close button, hide to the menu bar instead of closing when enabled