From 0d3a727d9d6b793adb2c599b9de3e9e1a55a6d2c Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 5 Feb 2023 09:44:45 +0800 Subject: [PATCH] Repo // Enable CGShieldingWindowLevel(). - We use the max value between CGShieldingWindowLevel() and kCGPopUpMenuWindowLevel. --- .../CandidateWindow/TDKCandidates/CtlCandidateTDK.swift | 2 +- .../vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift | 2 +- .../PopupCompositionBuffer/PopupCompositionBuffer.swift | 2 +- .../vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift | 2 +- Source/Modules/SessionCtl_HandleDisplay.swift | 6 ++---- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift index 9464f660..5884b331 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/CtlCandidateTDK.swift @@ -74,7 +74,7 @@ public class CtlCandidateTDK: CtlCandidate { let panel = NSPanel( contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false ) - panel.level = NSWindow.Level(Int(kCGPopUpMenuWindowLevel) + 2) + panel.level = NSWindow.Level(Int(max(CGShieldingWindowLevel(), kCGPopUpMenuWindowLevel)) + 2) panel.hasShadow = true panel.isOpaque = false panel.backgroundColor = NSColor.clear diff --git a/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift b/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift index 2e623d58..96352b71 100644 --- a/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift +++ b/Packages/vChewing_NotifierUI/Sources/NotifierUI/NotifierUI.swift @@ -97,7 +97,7 @@ public class Notifier: NSWindowController { ) theWindow.contentView = transparentVisualEffect theWindow.isMovableByWindowBackground = true - theWindow.level = NSWindow.Level(Int(kCGPopUpMenuWindowLevel)) + theWindow.level = NSWindow.Level(Int(max(CGShieldingWindowLevel(), kCGPopUpMenuWindowLevel))) theWindow.hasShadow = true theWindow.backgroundColor = .textBackgroundColor theWindow.title = "" diff --git a/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift b/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift index 0cb5fb85..eff04bb9 100644 --- a/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift +++ b/Packages/vChewing_PopupCompositionBuffer/Sources/PopupCompositionBuffer/PopupCompositionBuffer.swift @@ -32,7 +32,7 @@ public class PopupCompositionBuffer: NSWindowController { let panel = NSPanel( contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false ) - panel.level = NSWindow.Level(Int(kCGPopUpMenuWindowLevel) + 1) + panel.level = NSWindow.Level(Int(max(CGShieldingWindowLevel(), kCGPopUpMenuWindowLevel)) + 1) panel.hasShadow = true panel.backgroundColor = NSColor.controlBackgroundColor panel.styleMask = .fullSizeContentView diff --git a/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift index 54cee25b..f4ef26c5 100644 --- a/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift +++ b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift @@ -34,7 +34,7 @@ public class TooltipUI: NSWindowController { let panel = NSPanel( contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false ) - panel.level = NSWindow.Level(Int(kCGPopUpMenuWindowLevel) + 2) + panel.level = NSWindow.Level(Int(max(CGShieldingWindowLevel(), kCGPopUpMenuWindowLevel)) + 2) panel.hasShadow = true panel.backgroundColor = NSColor.controlBackgroundColor panel.isMovable = false diff --git a/Source/Modules/SessionCtl_HandleDisplay.swift b/Source/Modules/SessionCtl_HandleDisplay.swift index cb769798..6f266226 100644 --- a/Source/Modules/SessionCtl_HandleDisplay.swift +++ b/Source/Modules/SessionCtl_HandleDisplay.swift @@ -73,7 +73,7 @@ extension SessionCtl { } public func showCandidates() { - guard let client = client() else { return } + guard client() != nil else { return } updateVerticalTypingStatus() isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList) @@ -127,9 +127,7 @@ extension SessionCtl { if #available(macOS 10.14, *) { // Spotlight 視窗會擋住 IMK 選字窗,所以需要特殊處理。 if let ctlCandidateCurrent = candidateUI as? CtlCandidateIMK { - while ctlCandidateCurrent.windowLevel() <= client.windowLevel() { - ctlCandidateCurrent.setWindowLevel(UInt64(max(0, client.windowLevel() + 1000))) - } + ctlCandidateCurrent.setWindowLevel(UInt64(CGShieldingWindowLevel() + 2)) } }