diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index da3cacc..841c235 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -562,8 +562,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele toastWindowCtrl = ToastWindowController(windowNibName: "ToastWindowController") toastWindowCtrl.message = message toastWindowCtrl.showWindow(self) - NSApp.activate(ignoringOtherApps: true) - toastWindowCtrl.window?.makeKeyAndOrderFront(self) + //NSApp.activate(ignoringOtherApps: true) + //toastWindowCtrl.window?.makeKeyAndOrderFront(self) toastWindowCtrl.fadeInHud() } } diff --git a/ShadowsocksX-NG/ToastWindowController.swift b/ShadowsocksX-NG/ToastWindowController.swift index f63aeb7..b688721 100644 --- a/ShadowsocksX-NG/ToastWindowController.swift +++ b/ShadowsocksX-NG/ToastWindowController.swift @@ -34,10 +34,11 @@ class ToastWindowController: NSWindowController { if let win = self.window { win.isOpaque = false win.backgroundColor = .clear - win.level = Int(CGWindowLevelForKey(.utilityWindow)) + 1000 win.styleMask = .borderless win.hidesOnDeactivate = false win.collectionBehavior = .canJoinAllSpaces + win.level = Int(CGWindowLevelForKey(.floatingWindow)) + win.orderFrontRegardless() } let viewLayer: CALayer = CALayer() @@ -83,8 +84,6 @@ class ToastWindowController: NSWindowController { fadingOut = false - self.window?.orderFrontRegardless() - CATransaction.begin() CATransaction.setAnimationDuration(kHudFadeInDuration) CATransaction.setCompletionBlock { self.didFadeIn() } @@ -113,7 +112,7 @@ class ToastWindowController: NSWindowController { func didFadeOut() -> Void { if fadingOut { - self.window?.orderOut(nil) + self.window?.orderOut(self) } fadingOut = false }