From 87915bf7e386edecab409e51adad0bdb8e877cea Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 7 Oct 2026 12:18:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20editorApps=20=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=20=E2=80=94=20Sublime/XStudio/VSCode=20=E7=AD=89=20AX?= =?UTF-8?q?=20=E4=B8=8D=E9=80=8F=E7=BC=96=E8=BE=91=E5=99=A8=E5=8F=AF?= =?UTF-8?q?=E6=BF=80=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 影响:之前 Sublime Text(AX 树只有 window chrome)、XStudio console 插件 (AXUnknown)、VSCode(Electron,AX 残)长按一律进 skip 分支;现在按 bundle 白名单 走 "AX 不透明" 兜底,与 HexHub 同款 app 级激活。 改动: - 新增 editorApps: Set(Sublime 4/3、TextEdit、VSCode、Atom、CotEditor、XStudio) - 长按分支新增一层 let role, let b = bundle, editorApps.contains(b) → startRec() - 日志加 "allow: editor whitelist role= (fallback)" Co-Authored-By: Claude Code --- src/xtype.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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