diff --git a/Installer/AppDelegate.swift b/Installer/AppDelegate.swift index f089c231..918cd0b1 100644 --- a/Installer/AppDelegate.swift +++ b/Installer/AppDelegate.swift @@ -8,7 +8,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import IMKUtils import InputMethodKit import SwiftExtension @@ -111,7 +111,7 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { window.center() window.orderFront(self) - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } @IBAction func agreeAndInstallAction(_: AnyObject) { @@ -179,3 +179,21 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { return output } } + +// MARK: - NSApp Activation Helper + +// This is to deal with changes brought by macOS 14. + +private extension NSApplication { + func popup() { + #if compiler(>=5.9) && canImport(AppKit, _version: "14.0") + if #available(macOS 14.0, *) { + NSApp.activate() + } else { + NSApp.activate(ignoringOtherApps: true) + } + #else + NSApp.activate(ignoringOtherApps: true) + #endif + } +} diff --git a/Installer/AppDelegate_Extension.swift b/Installer/AppDelegate_Extension.swift index c8d2de1d..e3f42e86 100644 --- a/Installer/AppDelegate_Extension.swift +++ b/Installer/AppDelegate_Extension.swift @@ -8,7 +8,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import InputMethodKit extension AppDelegate { diff --git a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift index 971eee52..b0b79248 100644 --- a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift +++ b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift @@ -5,7 +5,7 @@ // Ref: https://qiita.com/fuziki/items/b31055a69330a3ce55a5 // Modified by The vChewing Project in order to use it with AppKit. -import Cocoa +import AppKit import CocoaExtension import SwiftUI diff --git a/Packages/Jad_BookmarkManager/Sources/BookmarkManager/BookmarkManager.swift b/Packages/Jad_BookmarkManager/Sources/BookmarkManager/BookmarkManager.swift index 2797864f..abc60b64 100644 --- a/Packages/Jad_BookmarkManager/Sources/BookmarkManager/BookmarkManager.swift +++ b/Packages/Jad_BookmarkManager/Sources/BookmarkManager/BookmarkManager.swift @@ -1,7 +1,7 @@ // Ref: https://stackoverflow.com/a/61695824 // License: https://creativecommons.org/licenses/by-sa/4.0/ -import Cocoa +import AppKit public class BookmarkManager { public static let shared = BookmarkManager() diff --git a/Packages/Qwertyyb_ShiftKeyUpChecker/Sources/ShiftKeyUpChecker/ShiftKeyUpChecker.swift b/Packages/Qwertyyb_ShiftKeyUpChecker/Sources/ShiftKeyUpChecker/ShiftKeyUpChecker.swift index 82d2f3e2..9a64fc3e 100644 --- a/Packages/Qwertyyb_ShiftKeyUpChecker/Sources/ShiftKeyUpChecker/ShiftKeyUpChecker.swift +++ b/Packages/Qwertyyb_ShiftKeyUpChecker/Sources/ShiftKeyUpChecker/ShiftKeyUpChecker.swift @@ -2,8 +2,8 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) +import AppKit import Carbon -import Cocoa private extension Date { static func - (lhs: Date, rhs: Date) -> TimeInterval { diff --git a/Packages/ShapsBenkau_SwiftUIBackports/Sources/SwiftUIBackports/Internal/Environment+String.swift b/Packages/ShapsBenkau_SwiftUIBackports/Sources/SwiftUIBackports/Internal/Environment+String.swift index 8ca4c53b..1635fc45 100755 --- a/Packages/ShapsBenkau_SwiftUIBackports/Sources/SwiftUIBackports/Internal/Environment+String.swift +++ b/Packages/ShapsBenkau_SwiftUIBackports/Sources/SwiftUIBackports/Internal/Environment+String.swift @@ -99,8 +99,8 @@ private extension EnvironmentValues { @available(macOS 10.15, *) @propertyWrapper internal struct StringlyTypedEnvironment { - final class Store: ObservableObject { - var value: Value? + final class Store: ObservableObject { + var value: StoredValue? } @Environment(\.self) private var env diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SegmentedControlStyleViewController.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SegmentedControlStyleViewController.swift index e47ac695..98bc4513 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SegmentedControlStyleViewController.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SegmentedControlStyleViewController.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit extension NSToolbarItem.Identifier { static let toolbarSegmentedControlItem = Self("toolbarSegmentedControlItem") diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsPane.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsPane.swift index 2ed5b2c5..8d2dd5eb 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsPane.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsPane.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit public extension Settings { struct PaneIdentifier: Hashable, RawRepresentable, Codable { diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsStyleController.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsStyleController.swift index 59c25330..23d6b27f 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsStyleController.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsStyleController.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit protocol SettingsStyleController: AnyObject { var delegate: SettingsStyleControllerDelegate? { get set } diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsTabViewController.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsTabViewController.swift index 6ae04db5..ce64cf46 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsTabViewController.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsTabViewController.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit final class SettingsTabViewController: NSViewController, SettingsStyleControllerDelegate { private var activeTab: Int? diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsWindowController.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsWindowController.swift index 3b4ca7f7..aae5df7b 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsWindowController.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/SettingsWindowController.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit extension NSWindow.FrameAutosaveName { static let settings: NSWindow.FrameAutosaveName = "com.sindresorhus.Preferences.FrameAutosaveName" @@ -100,7 +100,15 @@ public final class SettingsWindowController: NSWindowController { showWindow(self) restoreWindowPosition() - NSApp.activate(ignoringOtherApps: true) + #if compiler(>=5.9) && canImport(AppKit, _version: "14.0") + if #available(macOS 14.0, *) { + NSApp.activate() + } else { + NSApp.activate(ignoringOtherApps: true) + } + #else + NSApp.activate(ignoringOtherApps: true) + #endif } private func restoreWindowPosition() { diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/Style.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/Style.swift index fdc7543c..d37cc819 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/Style.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/Style.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit public extension Settings { enum Style { diff --git a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/ToolbarItemStyleViewController.swift b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/ToolbarItemStyleViewController.swift index 4ec74767..9b2d41ad 100644 --- a/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/ToolbarItemStyleViewController.swift +++ b/Packages/Sindresorhus_SSPreferences/Sources/SSPreferences/ToolbarItemStyleViewController.swift @@ -2,7 +2,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit final class ToolbarItemStyleViewController: NSObject, SettingsStyleController { let toolbar: NSToolbar diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift index 67799c74..29983e22 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared import SwiftUI import SwiftUIBackports diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool_CocoaImpl.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool_CocoaImpl.swift index 7a8c07dd..1d8ab923 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool_CocoaImpl.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool_CocoaImpl.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit // MARK: - Using One Single NSAttributedString. diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CtlCandidate.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CtlCandidate.swift index 6b9a90d1..2d0d41fd 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CtlCandidate.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CtlCandidate.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared open class CtlCandidate: NSWindowController, CtlCandidateProtocol { diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift index e5571980..465cb43c 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension import Shared import SwiftExtension diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift index 4afbeb67..41cf6004 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared /// 田所選字窗的 Cocoa 版本,繪製效率不受 SwiftUI 的限制。 diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift index bfbdcb32..ee280ede 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared import SwiftUI import SwiftUIBackports diff --git a/Packages/vChewing_CandidateWindow/Tests/CandidateWindowTests/CandidatePoolTests.swift b/Packages/vChewing_CandidateWindow/Tests/CandidateWindowTests/CandidatePoolTests.swift index 7521006d..43e4e029 100644 --- a/Packages/vChewing_CandidateWindow/Tests/CandidateWindowTests/CandidatePoolTests.swift +++ b/Packages/vChewing_CandidateWindow/Tests/CandidateWindowTests/CandidatePoolTests.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import XCTest @testable import CandidateWindow diff --git a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_Misc.swift b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_Misc.swift index 9d15c989..7d913465 100644 --- a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_Misc.swift +++ b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_Misc.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import SwiftExtension // MARK: - NSSize extension @@ -238,3 +238,21 @@ public extension NSApplication { return machine == "arm64" } } + +// MARK: - NSApp Activation Helper + +// This is to deal with changes brought by macOS 14. + +public extension NSApplication { + func popup() { + #if compiler(>=5.9) && canImport(AppKit, _version: "14.0") + if #available(macOS 14.0, *) { + NSApp.activate() + } else { + NSApp.activate(ignoringOtherApps: true) + } + #else + NSApp.activate(ignoringOtherApps: true) + #endif + } +} diff --git a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSEvent.swift b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSEvent.swift index a9c92757..74bed8b4 100644 --- a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSEvent.swift +++ b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSEvent.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import IMKUtils // MARK: - NSEvent Extension - Reconstructors diff --git a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSSound.swift b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSSound.swift index 3671a679..b979066f 100644 --- a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSSound.swift +++ b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSSound.swift @@ -6,8 +6,8 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. +import AppKit import AVFoundation -import Cocoa public extension NSSound { static func buzz(fart: Bool = false) { diff --git a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowController.swift b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowController.swift index 52324ec2..a158b95b 100644 --- a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowController.swift +++ b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowController.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import InputMethodKit public extension NSWindowController { diff --git a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowPositioner.swift b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowPositioner.swift index b6d72de7..eee340f5 100644 --- a/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowPositioner.swift +++ b/Packages/vChewing_CocoaExtension/Sources/CocoaExtension/CocoaExtension_NSWindowPositioner.swift @@ -2,7 +2,7 @@ // Written by Alexis Bridoux - https://github.com/ABridoux // Ref: https://gist.github.com/ABridoux/b935c21c7ead92033d39b357fae6366b -import Cocoa +import AppKit import SwiftUI // MARK: Model diff --git a/Packages/vChewing_Megrez/Tests/MegrezTests/MegrezTests.swift b/Packages/vChewing_Megrez/Tests/MegrezTests/MegrezTests.swift index d8823f37..bcd351fb 100644 --- a/Packages/vChewing_Megrez/Tests/MegrezTests/MegrezTests.swift +++ b/Packages/vChewing_Megrez/Tests/MegrezTests/MegrezTests.swift @@ -3,7 +3,7 @@ // ==================== // This code is released under the MIT license (SPDX-License-Identifier: MIT) -import Cocoa +import AppKit import XCTest @testable import Megrez diff --git a/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift b/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift index 79eafd2a..ce00b605 100644 --- a/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift +++ b/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension public class Notifier: NSWindowController { diff --git a/Packages/vChewing_PhraseEditorUI/Sources/PhraseEditorUI/PhraseEditorUI.swift b/Packages/vChewing_PhraseEditorUI/Sources/PhraseEditorUI/PhraseEditorUI.swift index da785a6c..9d430203 100644 --- a/Packages/vChewing_PhraseEditorUI/Sources/PhraseEditorUI/PhraseEditorUI.swift +++ b/Packages/vChewing_PhraseEditorUI/Sources/PhraseEditorUI/PhraseEditorUI.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Combine import Foundation import LangModelAssembly diff --git a/Packages/vChewing_PinyinPhonaConverter/Sources/PinyinPhonaConverter/PinyinPhonaConverter.swift b/Packages/vChewing_PinyinPhonaConverter/Sources/PinyinPhonaConverter/PinyinPhonaConverter.swift index 9a05477a..2b3f34ab 100644 --- a/Packages/vChewing_PinyinPhonaConverter/Sources/PinyinPhonaConverter/PinyinPhonaConverter.swift +++ b/Packages/vChewing_PinyinPhonaConverter/Sources/PinyinPhonaConverter/PinyinPhonaConverter.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit public extension String { mutating func convertToPhonabets(newToneOne: String = "") { diff --git a/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift b/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift index 84ce37b7..1d51cce3 100644 --- a/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift +++ b/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared public class PopupCompositionBuffer: NSWindowController { diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift index 7e8e96f4..5c7f6836 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit public protocol CtlCandidateDelegate { func candidatePairs(conv: Bool) -> [(keyArray: [String], value: String)] diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/IMEStateProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/IMEStateProtocol.swift index 75d2ba28..85b88da6 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/IMEStateProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/IMEStateProtocol.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import InputMethodKit // 所有 IMEState 均遵守該協定: diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/InputSignalProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/InputSignalProtocol.swift index c382d641..ce61cf87 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/InputSignalProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/InputSignalProtocol.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension extension NSEvent: InputSignalProtocol {} diff --git a/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift index 248f122d..4d3fac87 100644 --- a/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift +++ b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension import NSAttributedTextView import Shared diff --git a/Packages/vChewing_Uninstaller/Sources/Uninstaller/Uninstaller.swift b/Packages/vChewing_Uninstaller/Sources/Uninstaller/Uninstaller.swift index a74afd93..4dfbfd9c 100644 --- a/Packages/vChewing_Uninstaller/Sources/Uninstaller/Uninstaller.swift +++ b/Packages/vChewing_Uninstaller/Sources/Uninstaller/Uninstaller.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension public enum Uninstaller { diff --git a/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift b/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift index 0424b1d2..76c78e17 100644 --- a/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift +++ b/Packages/vChewing_UpdateSputnik/Sources/UpdateSputnik/UpdateSputnik.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit public class UpdateSputnik { public static let shared: UpdateSputnik = .init() @@ -113,7 +113,7 @@ public class UpdateSputnik { alert.informativeText = NSLocalizedString("You are already using the latest version.", comment: "") alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() return } @@ -144,7 +144,7 @@ public class UpdateSputnik { } let result = alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() switch result { case .alertFirstButtonReturn: DispatchQueue.main.async { @@ -172,6 +172,24 @@ public class UpdateSputnik { alert.informativeText = content alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() + } +} + +// MARK: - NSApp Activation Helper + +// This is to deal with changes brought by macOS 14. + +private extension NSApplication { + func popup() { + #if compiler(>=5.9) && canImport(AppKit, _version: "14.0") + if #available(macOS 14.0, *) { + NSApp.activate() + } else { + NSApp.activate(ignoringOtherApps: true) + } + #else + NSApp.activate(ignoringOtherApps: true) + #endif } } diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index 96779163..43752052 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -130,7 +130,7 @@ public extension AppDelegate { } alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) let result = alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() if result == NSApplication.ModalResponse.alertFirstButtonReturn { NSWorkspace.shared.openFile( LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder" @@ -167,6 +167,6 @@ public extension AppDelegate { // New About Window @IBAction func about(_: Any) { CtlAboutWindow.show() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } } diff --git a/Source/Modules/LMMgr_Utilities.swift b/Source/Modules/LMMgr_Utilities.swift index b068899d..f07a58cf 100644 --- a/Source/Modules/LMMgr_Utilities.swift +++ b/Source/Modules/LMMgr_Utilities.swift @@ -302,7 +302,7 @@ public extension LMMgr { alert.informativeText = content alert.addButton(withTitle: NSLocalizedString("OK", comment: "")) alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } return false } diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 68753498..1a898266 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -358,7 +358,7 @@ public extension SessionCtl { break modeCheck } let result = sharedAlertForInputModeToggling.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() if result == NSApplication.ModalResponse.alertFirstButtonReturn { neta.activate() } diff --git a/Source/Modules/SessionCtl_Menu.swift b/Source/Modules/SessionCtl_Menu.swift index 8765a9e7..19821dba 100644 --- a/Source/Modules/SessionCtl_Menu.swift +++ b/Source/Modules/SessionCtl_Menu.swift @@ -225,11 +225,11 @@ public extension SessionCtl { // CtlPrefUIShared.shared.controller.window?.setPosition(vertical: .top, horizontal: .right, padding: 20) default: CtlPrefUI.show() } - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() return } CtlPrefWindow.show() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } @objc func showCheatSheet(_: Any? = nil) { @@ -241,7 +241,7 @@ public extension SessionCtl { @objc func showClientListMgr(_: Any? = nil) { CtlClientListMgr.show() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } @objc func toggleCassetteMode(_: Any? = nil) { @@ -253,7 +253,7 @@ public extension SessionCtl { let informativeText = "Please reconfigure the cassette path to a valid one before enabling this mode." alert.informativeText = informativeText.localized let result = alert.runModal() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() if result == NSApplication.ModalResponse.alertFirstButtonReturn { LMMgr.resetCassettePath() PrefMgr.shared.cassetteEnabled = false @@ -367,7 +367,7 @@ public extension SessionCtl { } @objc func selfTerminate(_: Any? = nil) { - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() NSApp.terminate(nil) } @@ -428,6 +428,6 @@ public extension SessionCtl { @objc func showAbout(_: Any? = nil) { CtlAboutWindow.show() - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } } diff --git a/Source/Modules/UIModules/PrefUI/CtlPrefUI.swift b/Source/Modules/UIModules/PrefUI/CtlPrefUI.swift index 77e60574..f0cd3b92 100644 --- a/Source/Modules/UIModules/PrefUI/CtlPrefUI.swift +++ b/Source/Modules/UIModules/PrefUI/CtlPrefUI.swift @@ -67,7 +67,7 @@ class CtlPrefUI: NSWindowController, NSWindowDelegate { sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示 sharedWindow.level = .statusBar shared.showWindow(shared) - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } private var currentLanguageSelectItem: NSMenuItem? diff --git a/Source/Modules/UIModules/PrefUITabs.swift b/Source/Modules/UIModules/PrefUITabs.swift index d78fe809..fc732244 100644 --- a/Source/Modules/UIModules/PrefUITabs.swift +++ b/Source/Modules/UIModules/PrefUITabs.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import Shared enum PrefUITabs: String, CaseIterable { diff --git a/Source/Modules/WindowControllers/CtlAboutWindow.swift b/Source/Modules/WindowControllers/CtlAboutWindow.swift index db883af2..87f43a34 100644 --- a/Source/Modules/WindowControllers/CtlAboutWindow.swift +++ b/Source/Modules/WindowControllers/CtlAboutWindow.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit class CtlAboutWindow: NSWindowController { @IBOutlet var appVersionLabel: NSTextField! @@ -23,7 +23,7 @@ class CtlAboutWindow: NSWindowController { sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true shared.showWindow(shared) - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } override func windowDidLoad() { diff --git a/Source/Modules/WindowControllers/CtlClientListMgr.swift b/Source/Modules/WindowControllers/CtlClientListMgr.swift index 34b6c341..c5f88c0f 100644 --- a/Source/Modules/WindowControllers/CtlClientListMgr.swift +++ b/Source/Modules/WindowControllers/CtlClientListMgr.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewDataSource { @IBOutlet var tblClients: NSTableView! @@ -24,7 +24,7 @@ class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewData sharedWindow.level = .statusBar sharedWindow.titlebarAppearsTransparent = true shared.showWindow(shared) - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } override func windowDidLoad() { diff --git a/Source/Modules/WindowControllers/CtlPrefWindow.swift b/Source/Modules/WindowControllers/CtlPrefWindow.swift index bf2c9143..014c6944 100644 --- a/Source/Modules/WindowControllers/CtlPrefWindow.swift +++ b/Source/Modules/WindowControllers/CtlPrefWindow.swift @@ -73,7 +73,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate { sharedWindow.level = .statusBar shared.showWindow(shared) if resetPhraseEditor { shared.initPhraseEditor() } - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } private var currentLanguageSelectItem: NSMenuItem? diff --git a/Source/Modules/WindowControllers/CtlRevLookupWindow.swift b/Source/Modules/WindowControllers/CtlRevLookupWindow.swift index ca525fac..be37568e 100644 --- a/Source/Modules/WindowControllers/CtlRevLookupWindow.swift +++ b/Source/Modules/WindowControllers/CtlRevLookupWindow.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import LangModelAssembly class CtlRevLookupWindow: NSWindowController, NSWindowDelegate { @@ -22,7 +22,7 @@ class CtlRevLookupWindow: NSWindowController, NSWindowDelegate { window.level = .statusBar window.titlebarAppearsTransparent = true shared.showWindow(shared) - NSApp.activate(ignoringOtherApps: true) + NSApp.popup() } } diff --git a/Source/Modules/main.swift b/Source/Modules/main.swift index 8afc7b52..07186e0b 100644 --- a/Source/Modules/main.swift +++ b/Source/Modules/main.swift @@ -6,7 +6,7 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. -import Cocoa +import AppKit import CocoaExtension import IMKUtils import InputMethodKit