From fdfc3297bb143bbbb86a0cc244c9ea71082d6302 Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Tue, 16 Jul 2024 16:23:53 -0400 Subject: [PATCH] Change activation policy in notification manager --- Source/gui/SNTBinaryMessageWindowController.m | 12 ------------ Source/gui/SNTDeviceMessageWindowController.m | 9 --------- Source/gui/SNTFileAccessMessageWindowController.m | 9 --------- Source/gui/SNTNotificationManager.m | 4 ++++ 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/Source/gui/SNTBinaryMessageWindowController.m b/Source/gui/SNTBinaryMessageWindowController.m index 9ece002bf..a88b75698 100644 --- a/Source/gui/SNTBinaryMessageWindowController.m +++ b/Source/gui/SNTBinaryMessageWindowController.m @@ -116,18 +116,6 @@ - (void)loadWindow { } } -- (void)showWindow:(id)sender { - // Add app to Cmd+Tab and Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyRegular; - [super showWindow:sender]; -} - -- (void)windowWillClose:(NSNotification *)notification { - // Remove app from Cmd+Tab and Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; - [super windowWillClose:notification]; -} - - (NSString *)messageHash { return self.event.fileSHA256; } diff --git a/Source/gui/SNTDeviceMessageWindowController.m b/Source/gui/SNTDeviceMessageWindowController.m index 3af4cc66a..48a013702 100644 --- a/Source/gui/SNTDeviceMessageWindowController.m +++ b/Source/gui/SNTDeviceMessageWindowController.m @@ -50,18 +50,9 @@ - (void)showWindow:(id)sender { customMsg:self.attributedCustomMessage]; self.window.delegate = self; - // Add app to Cmd+Tab and Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyRegular; - [super showWindow:sender]; } -- (void)windowWillClose:(NSNotification *)notification { - // Remove app from Cmd+Tab and Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; - [super windowWillClose:notification]; -} - - (NSAttributedString *)attributedCustomMessage { return [SNTBlockMessage formatMessage:self.customMessage]; } diff --git a/Source/gui/SNTFileAccessMessageWindowController.m b/Source/gui/SNTFileAccessMessageWindowController.m index af55265d3..8230808cc 100644 --- a/Source/gui/SNTFileAccessMessageWindowController.m +++ b/Source/gui/SNTFileAccessMessageWindowController.m @@ -66,18 +66,9 @@ - (void)showWindow:(id)sender { self.window.delegate = self; - // Make sure app doesn't appear in Cmd+Tab or Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; - [super showWindow:sender]; } -- (void)windowWillClose:(NSNotification *)notification { - // Remove app from Cmd+Tab and Dock. - NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; - [super windowWillClose:notification]; -} - - (NSAttributedString *)attributedCustomMessage { return [SNTBlockMessage attributedBlockMessageForFileAccessEvent:self.event customMessage:self.customMessage]; diff --git a/Source/gui/SNTNotificationManager.m b/Source/gui/SNTNotificationManager.m index c54052c3b..5f1b796be 100644 --- a/Source/gui/SNTNotificationManager.m +++ b/Source/gui/SNTNotificationManager.m @@ -71,6 +71,8 @@ - (void)windowDidCloseSilenceHash:(NSString *)hash { [bc resume]; [[bc remoteObjectProxy] spindown]; [bc invalidate]; + // Remove app from Cmd+Tab and Dock. + NSApp.activationPolicy = NSApplicationActivationPolicyAccessory; [NSApp hide:self]; } } @@ -125,6 +127,8 @@ - (void)queueMessage:(SNTMessageWindowController *)pendingMsg { [self.pendingNotifications addObject:pendingMsg]; if (!self.currentWindowController) { + // Add app to Cmd+Tab and Dock. + NSApp.activationPolicy = NSApplicationActivationPolicyRegular; [self showQueuedWindow]; } }