diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index e30b2acc..b3552602 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -48,19 +48,37 @@ public extension AppDelegate { func applicationDidFinishLaunching(_: Notification) { NSUserNotificationCenter.default.delegate = self + + if PrefMgr.shared.failureFlagForIMKCandidates { + DispatchQueue.main.async { + PrefMgr.shared.failureFlagForIMKCandidates = false + PrefMgr.shared.useIMKCandidateWindow = false + let userNotification = NSUserNotification() + userNotification.title = NSLocalizedString("vChewing", comment: "") + userNotification.informativeText = NSLocalizedString( + "IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments.", + comment: "" + ) + userNotification.soundName = NSUserNotificationDefaultSoundName + NSUserNotificationCenter.default.deliver(userNotification) + } + } + // 一旦發現與使用者半衰模組的觀察行為有關的崩潰標記被開啟,就清空既有的半衰記憶資料檔案。 if PrefMgr.shared.failureFlagForUOMObservation { - LMMgr.clearUserOverrideModelData(.imeModeCHS) - LMMgr.clearUserOverrideModelData(.imeModeCHT) - PrefMgr.shared.failureFlagForUOMObservation = false - let userNotification = NSUserNotification() - userNotification.title = NSLocalizedString("vChewing", comment: "") - userNotification.informativeText = NSLocalizedString( - "vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.", - comment: "" - ) - userNotification.soundName = NSUserNotificationDefaultSoundName - NSUserNotificationCenter.default.deliver(userNotification) + DispatchQueue.main.async { + LMMgr.clearUserOverrideModelData(.imeModeCHS) + LMMgr.clearUserOverrideModelData(.imeModeCHT) + PrefMgr.shared.failureFlagForUOMObservation = false + let userNotification = NSUserNotification() + userNotification.title = NSLocalizedString("vChewing", comment: "") + userNotification.informativeText = NSLocalizedString( + "vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.", + comment: "" + ) + userNotification.soundName = NSUserNotificationDefaultSoundName + NSUserNotificationCenter.default.deliver(userNotification) + } } if !PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() } diff --git a/Source/Modules/InputHandler_HandleEvent.swift b/Source/Modules/InputHandler_HandleEvent.swift index ce08ad7f..b3597a1f 100644 --- a/Source/Modules/InputHandler_HandleEvent.swift +++ b/Source/Modules/InputHandler_HandleEvent.swift @@ -52,7 +52,9 @@ extension InputHandler { let newEvent = event.reinitiate(modifierFlags: [], characters: newChar) { if #available(macOS 10.14, *) { + PrefMgr.shared.failureFlagForIMKCandidates = true imkCandidates.handleKeyboardEvent(newEvent) + PrefMgr.shared.failureFlagForIMKCandidates = false } else { imkCandidates.interpretKeyEvents([newEvent]) } @@ -119,7 +121,9 @@ extension InputHandler { return event.isShiftHold ? true : handleInput(event: event) } else { if #available(macOS 10.14, *) { + PrefMgr.shared.failureFlagForIMKCandidates = true imkC.handleKeyboardEvent(newEvent) + PrefMgr.shared.failureFlagForIMKCandidates = false } else { imkC.interpretKeyEvents([newEvent]) } diff --git a/Source/Modules/SessionCtl_HandleDisplay.swift b/Source/Modules/SessionCtl_HandleDisplay.swift index d22fc284..89ecfb5b 100644 --- a/Source/Modules/SessionCtl_HandleDisplay.swift +++ b/Source/Modules/SessionCtl_HandleDisplay.swift @@ -130,7 +130,9 @@ public extension SessionCtl { if #available(macOS 10.14, *) { // Spotlight 視窗會擋住 IMK 選字窗,所以需要特殊處理。 if let ctlCandidateCurrent = candidateUI as? CtlCandidateIMK { + PrefMgr.shared.failureFlagForIMKCandidates = true ctlCandidateCurrent.setWindowLevel(UInt64(CGShieldingWindowLevel() + 2)) + PrefMgr.shared.failureFlagForIMKCandidates = false } } diff --git a/Source/Modules/UIModules/CandidateUI/IMKCandidatesImpl.swift b/Source/Modules/UIModules/CandidateUI/IMKCandidatesImpl.swift index a1a751eb..25ee05be 100644 --- a/Source/Modules/UIModules/CandidateUI/IMKCandidatesImpl.swift +++ b/Source/Modules/UIModules/CandidateUI/IMKCandidatesImpl.swift @@ -44,7 +44,11 @@ public class CtlCandidateIMK: IMKCandidates, CtlCandidateProtocol { public var candidateFont = NSFont.systemFont(ofSize: 16) { didSet { - if #available(macOS 10.14, *) { setFontSize(candidateFont.pointSize) } + if #available(macOS 10.14, *) { + PrefMgr.shared.failureFlagForIMKCandidates = true + setFontSize(candidateFont.pointSize) + PrefMgr.shared.failureFlagForIMKCandidates = false + } var attributes = attributes() // FB11300759: Set "NSAttributedString.Key.font" doesn't work. attributes?[NSAttributedString.Key.font] = candidateFont diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index 656efba7..e04abef0 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -1,4 +1,5 @@ "vChewing" = "vChewing"; +"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments."; "Do you want to enable the popup composition buffer for this client?" = "Do you want to enable the popup composition buffer for this client?"; "Some client apps may have different compatibility issues in IMKTextInput implementation." = "Some client apps may have different compatibility issues in IMKTextInput implementation."; "Yes" = "Yes"; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index 656efba7..e04abef0 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -1,4 +1,5 @@ "vChewing" = "vChewing"; +"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments."; "Do you want to enable the popup composition buffer for this client?" = "Do you want to enable the popup composition buffer for this client?"; "Some client apps may have different compatibility issues in IMKTextInput implementation." = "Some client apps may have different compatibility issues in IMKTextInput implementation."; "Yes" = "Yes"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 8cc07412..9da8633e 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -1,4 +1,5 @@ "vChewing" = "威注音入力アプリ"; +"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 文字候補ウィンドウの利用できるようのために、システム内部の必要のある API の強引的アクセスが必要ですが、前回のその利用で威注音入力アプリが崩れました。故に今は IMK 文字候補ウィンドウを OFF にしました。IMK 文字候補ウィンドウはあくまで実験的な機能として提供していたため、業務用にはお勧めできません。"; "Do you want to enable the popup composition buffer for this client?" = "この客体アプリに「吹き出し入力緩衝列ウィンドウ」を起用しますか?"; "Some client apps may have different compatibility issues in IMKTextInput implementation." = "それぞれの客体アプリには、それぞれの IMKTextInput 不具合はあるかもしれません。"; "Yes" = "うむ"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index e0172c2f..3ea6b3d3 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -1,4 +1,5 @@ "vChewing" = "威注音输入法"; +"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 选字窗在最近一次存取被强制曝露的必需 API 时令输入法崩溃,所以被自动停用。请勿在生产力场合使用该实验型功能。"; "Do you want to enable the popup composition buffer for this client?" = "您要對該客體啟用浮動組字窗嗎?"; "Some client apps may have different compatibility issues in IMKTextInput implementation." = "有些客體應用可能會有不同的 IMKTextInput 實作相容問題。"; "Yes" = "是"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 1a330162..55c88a30 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -1,4 +1,5 @@ "vChewing" = "威注音輸入法"; +"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 選字窗在最近一次存取被強制曝露的必需 API 時令輸入法崩潰,所以被自動停用。請勿在生產力場合使用該實驗型功能。"; "Do you want to enable the popup composition buffer for this client?" = "您要对该客体启用浮动组字窗吗?"; "Some client apps may have different compatibility issues in IMKTextInput implementation." = "有些客体应用可能会有不同的 IMKTextInput 实作相容问题。"; "Yes" = "是";