From 78ec0f46b76740f0c16c0d3b63a86b46afead55d Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 22 Mar 2021 16:17:07 -0700 Subject: [PATCH] Disable keyboard shortcut for active not-initiated scheduled checks This ports #1036 over to 2.x. Looks like I forgot to port half of it. --- Sparkle/SPUStandardUserDriver.m | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index c483a6d2..03277944 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -78,7 +78,7 @@ #pragma mark Update Alert Focus -- (void)setUpFocusForActiveUpdateAlert +- (void)setUpFocusForActiveUpdateAlertWithUserInitiation:(BOOL)userInitiated { // Make sure the window is loaded in any case [self.activeUpdateAlert window]; @@ -96,10 +96,14 @@ } // Only show the update alert if the app is active; otherwise, we'll wait until it is. - if ([NSApp isActive]) + if ([NSApp isActive]) { + if (!userInitiated) { + [self.activeUpdateAlert disableKeyboardShortcutForInstallButton]; + } [self.activeUpdateAlert.window makeKeyAndOrderFront:self]; - else + } else { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp]; + } } - (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification @@ -110,7 +114,7 @@ #pragma mark Update Found -- (void)showUpdateFoundWithAlertHandler:(SUUpdateAlert *(^)(SPUStandardUserDriver *, SUHost *, id))alertHandler +- (void)showUpdateFoundWithAlertHandler:(SUUpdateAlert *(^)(SPUStandardUserDriver *, SUHost *, id))alertHandler userInitiated:(BOOL)userInitiated { id versionDisplayer = nil; if ([self.delegate respondsToSelector:@selector(standardUserDriverRequestsVersionDisplayer)]) { @@ -121,10 +125,10 @@ SUHost *host = self.host; self.activeUpdateAlert = alertHandler(weakSelf, host, versionDisplayer); - [self setUpFocusForActiveUpdateAlert]; + [self setUpFocusForActiveUpdateAlertWithUserInitiation:userInitiated]; } -- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply +- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply { assert(NSThread.isMainThread); @@ -133,10 +137,10 @@ reply(choice); weakSelf.activeUpdateAlert = nil; }]; - }]; + } userInitiated:userInitiated]; } -- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply +- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply { assert(NSThread.isMainThread); @@ -145,10 +149,10 @@ reply(choice); weakSelf.activeUpdateAlert = nil; }]; - }]; + } userInitiated:userInitiated]; } -- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply +- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply { assert(NSThread.isMainThread); @@ -157,10 +161,10 @@ reply(choice); weakSelf.activeUpdateAlert = nil; }]; - }]; + } userInitiated:userInitiated]; } -- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply +- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply { assert(NSThread.isMainThread); @@ -169,7 +173,7 @@ reply(choice); weakSelf.activeUpdateAlert = nil; }]; - }]; + } userInitiated:userInitiated]; } - (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData