From b64910d7a57fbc29f7bb2ab9cfab50d4f6df1922 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 14 Dec 2022 14:45:33 +0800 Subject: [PATCH] SessionCtl // Change how updateVerticalTypingStatus() gets triggered. --- Source/Modules/SessionCtl_Core.swift | 15 ++++++--------- Source/Modules/SessionCtl_HandleDisplay.swift | 1 + Source/Modules/SessionCtl_HandleEvent.swift | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index e7275ac2..2b012dbb 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -106,14 +106,12 @@ public class SessionCtl: IMKInputController { isVerticalTyping = false return } - DispatchQueue.main.async { - var textFrame = NSRect.seniorTheBeast - let attributes: [AnyHashable: Any]? = client.attributes( - forCharacterIndex: 0, lineHeightRectangle: &textFrame - ) - let result = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false - self.isVerticalTyping = result - } + var textFrame = NSRect.seniorTheBeast + let attributes: [AnyHashable: Any]? = client.attributes( + forCharacterIndex: 0, lineHeightRectangle: &textFrame + ) + let result = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false + isVerticalTyping = result } /// InputMode 需要在每次出現內容變更的時候都連帶重設組字器與各項語言模組, @@ -213,7 +211,6 @@ extension SessionCtl { public override func activateServer(_ sender: Any!) { _ = sender // 防止格式整理工具毀掉與此對應的參數。 DispatchQueue.main.async { [self] in - defer { updateVerticalTypingStatus() } if let senderBundleID: String = (sender as? IMKTextInput)?.bundleIdentifier() { vCLog("activateServer(\(senderBundleID))") isServingIMEItself = Bundle.main.bundleIdentifier == senderBundleID diff --git a/Source/Modules/SessionCtl_HandleDisplay.swift b/Source/Modules/SessionCtl_HandleDisplay.swift index 5e0badb0..75ff6852 100644 --- a/Source/Modules/SessionCtl_HandleDisplay.swift +++ b/Source/Modules/SessionCtl_HandleDisplay.swift @@ -73,6 +73,7 @@ extension SessionCtl { public func showCandidates() { guard let client = client() else { return } + updateVerticalTypingStatus() state.isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList) /// 無論是田所選字窗還是 IMK 選字窗,在這裡都有必要重新初期化。 diff --git a/Source/Modules/SessionCtl_HandleEvent.swift b/Source/Modules/SessionCtl_HandleEvent.swift index c7d93006..2684b453 100644 --- a/Source/Modules/SessionCtl_HandleEvent.swift +++ b/Source/Modules/SessionCtl_HandleEvent.swift @@ -119,6 +119,7 @@ extension SessionCtl { // 如果是方向鍵輸入的話,就想辦法帶上標記資訊、來說明當前是縱排還是橫排。 if event.isUp || event.isDown || event.isLeft || event.isRight { + updateVerticalTypingStatus() // 檢查當前環境是否是縱排輸入。 eventToDeal = event.reinitiate(charactersIgnoringModifiers: isVerticalTyping ? "Vertical" : "Horizontal") ?? event }