From 952eec121582f219cdb8611d275238ccc13a8f6d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 16 Aug 2022 08:20:44 +0800 Subject: [PATCH] mgrPrefs // Add fixOddPreferences() for activateServer(). --- .../ControllerModules/ctlInputMethod_Core.swift | 5 +---- Source/Modules/IMEModules/mgrPrefs.swift | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index f050521a..24744004 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -111,10 +111,7 @@ class ctlInputMethod: IMKInputController { keyHandler.clear() // 這句不要砍,因為後面 handle State.Empty() 不一定執行。 keyHandler.ensureParser() - if #available(macOS 10.13, *) { - } else { - mgrPrefs.useIMKCandidateWindow = false // 防呆。macOS 10.11 用 IMK 選字窗會崩潰。 - } + mgrPrefs.fixOddPreferences() if isASCIIMode { if mgrPrefs.disableShiftTogglingAlphanumericalMode { diff --git a/Source/Modules/IMEModules/mgrPrefs.swift b/Source/Modules/IMEModules/mgrPrefs.swift index 59c8dd3a..fe2aaa0c 100644 --- a/Source/Modules/IMEModules/mgrPrefs.swift +++ b/Source/Modules/IMEModules/mgrPrefs.swift @@ -664,6 +664,21 @@ public enum mgrPrefs { static var usingHotKeyCurrencyNumerals: Bool } +// MARK: Auto parameter fix procedures, executed everytime on ctlInputMethod.activateServer(). + +extension mgrPrefs { + static func fixOddPreferences() { + // 防呆。macOS 10.11 用 IMK 選字窗會崩潰。 + if #unavailable(macOS 10.13) { mgrPrefs.useIMKCandidateWindow = false } + if #unavailable(macOS 10.15) { + handleDefaultCandidateFontsByLangIdentifier = false + shouldAlwaysUseShiftKeyAccommodation = false + disableShiftTogglingAlphanumericalMode = false + togglingAlphanumericalModeWithLShift = false + } + } +} + // MARK: Snapshot Extension var snapshot: [String: Any]?