diff --git a/src/xtype.swift b/src/xtype.swift index d37dbe8..98e6747 100644 --- a/src/xtype.swift +++ b/src/xtype.swift @@ -754,6 +754,19 @@ func appAtCursor(_ pt: CGPoint) -> (pid: pid_t, bundle: String?) { // ---------- 微信过滤 + AX 输入框判定 ---------- let textRoles: Set = ["AXTextField", "AXTextArea", "AXComboBox", "AXSearchField"] +// AX 树暴露不出编辑器(如 Sublime)或只给 AXUnknown(XStudio console 插件)的 app: +// 角色查得到但不是 textRoles 时,本应 skip,这里走白名单按"AX 不透明"兜底放行 +// (按 AXWebArea 走不进文本子域、Safari Web 文本输入不在同列,单独处理见下) +let editorApps: Set = [ + "com.sublimetext.4", // Sublime Text 4(AX 树只有 window chrome) + "com.sublimetext.3", + "com.apple.TextEdit", // macOS 内置 + "com.microsoft.VSCode", // VS Code(Electron,AX 树通常残) + "com.github.atom", + "com.coteditor.CotEditor", + "com.xstudio.ui", // XStudio(AXUnknown,console 插件是 Chromium webview) +] + func frontmostIsWeChat(_ bundle: String?) -> Bool { bundle?.hasPrefix(weChatPrefix) == true } @@ -836,6 +849,11 @@ Thread.detachNewThread { } if let role, textRoles.contains(role) { startRec() + } else if let role, let b = bundle, editorApps.contains(b) { + // AX 树不暴露编辑器小部件(Sublime)或只给 AXUnknown(XStudio console 插件), + // 按白名单当 AX 不透明走 app 级兜底激活 + log("allow: editor whitelist \(b) role=\(role) (fallback)") + startRec() } else if let role { log("skip: role=\(role)") state.v = .dead