Repo // Enforce NSApp.activate() instead.

This commit is contained in:
ShikiSuen 2022-12-04 17:12:28 +08:00
parent 94105ccc9b
commit 63d56d8132
8 changed files with 11 additions and 12 deletions

View File

@ -112,7 +112,7 @@ public class UpdateSputnik {
alert.informativeText = NSLocalizedString("You are already using the latest version.", comment: "") alert.informativeText = NSLocalizedString("You are already using the latest version.", comment: "")
alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal() alert.runModal()
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
return return
} }
@ -131,8 +131,8 @@ public class UpdateSputnik {
alert.informativeText = content alert.informativeText = content
alert.addButton(withTitle: NSLocalizedString("Visit Website", comment: "")) alert.addButton(withTitle: NSLocalizedString("Visit Website", comment: ""))
alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) alert.addButton(withTitle: NSLocalizedString("Not Now", comment: ""))
NSApp.setActivationPolicy(.accessory)
let result = alert.runModal() let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
if result == NSApplication.ModalResponse.alertFirstButtonReturn { if result == NSApplication.ModalResponse.alertFirstButtonReturn {
if let siteInfoURLString = plist[varkUpdateInfoPageURLKey] as? String, if let siteInfoURLString = plist[varkUpdateInfoPageURLKey] as? String,
let siteURL = URL(string: siteInfoURLString) let siteURL = URL(string: siteInfoURLString)
@ -158,6 +158,6 @@ public class UpdateSputnik {
alert.informativeText = content alert.informativeText = content
alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal() alert.runModal()
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
} }

View File

@ -96,6 +96,7 @@ extension AppDelegate {
alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) alert.addButton(withTitle: NSLocalizedString("Not Now", comment: ""))
let result = alert.runModal() let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
if result == NSApplication.ModalResponse.alertFirstButtonReturn { if result == NSApplication.ModalResponse.alertFirstButtonReturn {
NSWorkspace.shared.openFile( NSWorkspace.shared.openFile(
LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder" LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder"
@ -104,7 +105,6 @@ extension AppDelegate {
isSudo: false, selfKill: true, defaultDataFolderPath: LMMgr.dataFolderPath(isDefaultFolder: true) isSudo: false, selfKill: true, defaultDataFolderPath: LMMgr.dataFolderPath(isDefaultFolder: true)
) )
} }
NSApp.setActivationPolicy(.accessory)
} }
/// ///

View File

@ -611,7 +611,7 @@ public enum LMMgr {
alert.informativeText = content alert.informativeText = content
alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal() alert.runModal()
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
return false return false
} }

View File

@ -204,11 +204,10 @@ extension SessionCtl {
} else if NSEvent.modifierFlags.contains(.option) { } else if NSEvent.modifierFlags.contains(.option) {
CtlPrefWindow.show() CtlPrefWindow.show()
} else { } else {
NSApp.setActivationPolicy(.accessory)
CtlPrefUI.shared.controller.show(preferencePane: SSPreferences.PaneIdentifier(rawValue: "General")) CtlPrefUI.shared.controller.show(preferencePane: SSPreferences.PaneIdentifier(rawValue: "General"))
CtlPrefUI.shared.controller.window?.level = .statusBar CtlPrefUI.shared.controller.window?.level = .statusBar
NSApp.activate(ignoringOtherApps: true)
} }
NSApp.activate(ignoringOtherApps: true)
} }
@objc public func showCheatSheet(_: Any? = nil) { @objc public func showCheatSheet(_: Any? = nil) {
@ -233,11 +232,11 @@ extension SessionCtl {
"Please reconfigure the cassette path to a valid one before enabling this mode.", comment: "" "Please reconfigure the cassette path to a valid one before enabling this mode.", comment: ""
) )
let result = alert.runModal() let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
if result == NSApplication.ModalResponse.alertFirstButtonReturn { if result == NSApplication.ModalResponse.alertFirstButtonReturn {
LMMgr.resetCassettePath() LMMgr.resetCassettePath()
PrefMgr.shared.cassetteEnabled = false PrefMgr.shared.cassetteEnabled = false
} }
NSApp.setActivationPolicy(.accessory)
} }
return return
} }

View File

@ -22,7 +22,7 @@ class CtlAboutWindow: NSWindowController {
sharedWindow.orderFrontRegardless() // sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true sharedWindow.titlebarAppearsTransparent = true
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
override func windowDidLoad() { override func windowDidLoad() {

View File

@ -23,7 +23,7 @@ class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewData
sharedWindow.orderFrontRegardless() // sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true sharedWindow.titlebarAppearsTransparent = true
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
override func windowDidLoad() { override func windowDidLoad() {

View File

@ -54,7 +54,7 @@ class CtlPrefWindow: NSWindowController {
sharedWindow.orderFrontRegardless() // sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true sharedWindow.titlebarAppearsTransparent = true
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
private var currentLanguageSelectItem: NSMenuItem? private var currentLanguageSelectItem: NSMenuItem?

View File

@ -22,7 +22,7 @@ import Cocoa
sharedWindow.orderFrontRegardless() // sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true sharedWindow.titlebarAppearsTransparent = true
NSApp.setActivationPolicy(.accessory) NSApp.activate(ignoringOtherApps: true)
} }
override func windowDidLoad() { override func windowDidLoad() {