From 1cf9f198e0fc396b27562031aa8b29ba7fef71ad Mon Sep 17 00:00:00 2001 From: awulf Date: Wed, 21 Apr 2021 13:09:54 +0930 Subject: [PATCH] Work around apple bug, where PDFs in WKWebView brings up an invisible window --- TouchVisualizer/Visualizer.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TouchVisualizer/Visualizer.swift b/TouchVisualizer/Visualizer.swift index 42dc423..722557a 100644 --- a/TouchVisualizer/Visualizer.swift +++ b/TouchVisualizer/Visualizer.swift @@ -143,6 +143,12 @@ extension Visualizer { var topWindow = UIApplication.shared.keyWindow! for window in UIApplication.shared.windows { + // Case where webview brings up a fake empty keyboard when displaing a PDF on iPad and keeping it up until a keyboard is actually needed/used + // Affects iOS 12, 13, 14 + if String(describing: type(of: window)) == "UIRemoteKeyboardWindow" && window.subviews.first?.subviews.first?.frame.size.height == 0 { + continue + } + if window.isHidden == false && window.windowLevel > topWindow.windowLevel { topWindow = window }