From a846022f1bbe613223bf7571a98d748536e92057 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 11 Sep 2022 11:09:32 +0800 Subject: [PATCH] Repo // Disable NSRect.zero to suppress CoreGraphics errors. --- .../ControllerModules/ctlInputMethod_Delegates.swift | 2 +- Source/Modules/UIModules/CandidateUI/ctlCandidate.swift | 2 +- .../Modules/UIModules/CandidateUI/ctlCandidateIMK.swift | 2 +- .../UIModules/CandidateUI/ctlCandidateUniversal.swift | 2 +- .../Modules/UIModules/NotifierUI/NotifierController.swift | 8 ++++---- Source/Modules/UIModules/TooltipUI/ctlTooltip.swift | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift index 1927a05d..9459b649 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift @@ -16,7 +16,7 @@ extension ctlInputMethod: KeyHandlerDelegate { /// 記錄當前輸入環境是縱排輸入還是橫排輸入。 public var isVerticalTyping: Bool { guard let client = client() else { return false } - var textFrame = NSRect.zero + var textFrame = NSRect.seniorTheBeast let attributes: [AnyHashable: Any]? = client.attributes( forCharacterIndex: 0, lineHeightRectangle: &textFrame ) diff --git a/Source/Modules/UIModules/CandidateUI/ctlCandidate.swift b/Source/Modules/UIModules/CandidateUI/ctlCandidate.swift index 1f32722a..73d81745 100644 --- a/Source/Modules/UIModules/CandidateUI/ctlCandidate.swift +++ b/Source/Modules/UIModules/CandidateUI/ctlCandidate.swift @@ -160,7 +160,7 @@ public class ctlCandidate: NSWindowController, ctlCandidateProtocol { var adjustedPoint = windowTopLeftPoint var delta = heightDelta - var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.zero + var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.seniorTheBeast for frame in NSScreen.screens.map(\.visibleFrame).filter({ !$0.contains(windowTopLeftPoint) }) { screenFrame = frame break diff --git a/Source/Modules/UIModules/CandidateUI/ctlCandidateIMK.swift b/Source/Modules/UIModules/CandidateUI/ctlCandidateIMK.swift index bae2b48d..a59fd18e 100644 --- a/Source/Modules/UIModules/CandidateUI/ctlCandidateIMK.swift +++ b/Source/Modules/UIModules/CandidateUI/ctlCandidateIMK.swift @@ -167,7 +167,7 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol { var adjustedPoint = windowTopLeftPoint var adjustedHeight = height - var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.zero + var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.seniorTheBeast for screen in NSScreen.screens { let frame = screen.visibleFrame if windowTopLeftPoint.x >= frame.minX, windowTopLeftPoint.x <= frame.maxX, diff --git a/Source/Modules/UIModules/CandidateUI/ctlCandidateUniversal.swift b/Source/Modules/UIModules/CandidateUI/ctlCandidateUniversal.swift index 0590cc3b..916d4798 100644 --- a/Source/Modules/UIModules/CandidateUI/ctlCandidateUniversal.swift +++ b/Source/Modules/UIModules/CandidateUI/ctlCandidateUniversal.swift @@ -600,7 +600,7 @@ extension ctlCandidateUniversal { pageCounterLabel.isHidden = true } - frameRect = window?.frame ?? NSRect.zero + frameRect = window?.frame ?? NSRect.seniorTheBeast let topLeftPoint = NSPoint(x: frameRect.origin.x, y: frameRect.origin.y + frameRect.size.height) frameRect.size = newSize diff --git a/Source/Modules/UIModules/NotifierUI/NotifierController.swift b/Source/Modules/UIModules/NotifierUI/NotifierController.swift index 070fc301..caafdd1a 100644 --- a/Source/Modules/UIModules/NotifierUI/NotifierController.swift +++ b/Source/Modules/UIModules/NotifierUI/NotifierController.swift @@ -90,7 +90,7 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate { } private init() { - let screenRect = NSScreen.main?.visibleFrame ?? NSRect.zero + let screenRect = NSScreen.main?.visibleFrame ?? NSRect.seniorTheBeast let contentRect = NSRect(x: 0, y: 0, width: kWindowWidth, height: kWindowHeight) var windowRect = contentRect windowRect.origin.x = screenRect.maxX - windowRect.width - 10 @@ -144,8 +144,8 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate { return } let lastLocation = NotifierController.lastLocation - let screenRect = NSScreen.main?.visibleFrame ?? NSRect.zero - var windowRect = window?.frame ?? NSRect.zero + let screenRect = NSScreen.main?.visibleFrame ?? NSRect.seniorTheBeast + var windowRect = window?.frame ?? NSRect.seniorTheBeast windowRect.origin.x = lastLocation.x windowRect.origin.y = lastLocation.y - 10 - windowRect.height @@ -157,7 +157,7 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate { } func moveIn() { - let afterRect = window?.frame ?? NSRect.zero + let afterRect = window?.frame ?? NSRect.seniorTheBeast NotifierController.lastLocation = afterRect.origin var beforeRect = afterRect beforeRect.origin.y += 10 diff --git a/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift b/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift index 23b5df9b..0ef603f5 100644 --- a/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift +++ b/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift @@ -129,7 +129,7 @@ public class ctlTooltip: NSWindowController { var adjustedPoint = windowTopLeftPoint var delta = heightDelta - var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.zero + var screenFrame = NSScreen.main?.visibleFrame ?? NSRect.seniorTheBeast for frame in NSScreen.screens.map(\.visibleFrame).filter({ !$0.contains(windowTopLeftPoint) }) { screenFrame = frame break