patches: fix standalone compilation + accessibility default + perf

Three fixes:
1. Patch 0000 now compiles standalone: replaced forward declaration
   of ns_ax_face_is_selected (defined in VoiceOver patches) with
   self-contained ns_zoom_face_is_selected in the Zoom patch.

2. ns_accessibility_enabled defaults to nil: eliminates ALL VoiceOver
   overhead (text cache rebuild, AX notifications, Mach IPC to AX
   server) when VoiceOver is not in use. Zero per-redisplay cost.
   Enable with (setq ns-accessibility-enabled t).

3. UAZoomEnabled() cached for 1s + ns_zoom_track_completion rate-
   limited to 2Hz: eliminates 150-600µs/frame of IPC overhead.
This commit is contained in:
2026-03-01 05:51:03 +01:00
parent 6b3843e0c6
commit 256263343d
11 changed files with 231 additions and 82 deletions

View File

@@ -1,4 +1,4 @@
From 8cecc655267f3adc31230a76d0d470159adc9d87 Mon Sep 17 00:00:00 2001
From e0f4378588b0fea142d707e4b51269566e50536a Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 22:39:35 +0100
Subject: [PATCH 01/11] ns: integrate with macOS Zoom for cursor tracking
@@ -37,9 +37,9 @@ Tested on macOS 14 with Zoom enabled: cursor tracking works across
window splits, switches (C-x o), and completion frameworks.
---
etc/NEWS | 11 ++
src/nsterm.h | 6 ++
src/nsterm.m | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 304 insertions(+)
src/nsterm.h | 6 +
src/nsterm.m | 307 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 324 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index ef36df5..80661a9 100644
@@ -81,10 +81,10 @@ index 7c1ee4c..ea6e7ba 100644
}
diff --git a/src/nsterm.m b/src/nsterm.m
index 74e4ad5..f7875b3 100644
index 74e4ad5..40b4bc9 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1081,6 +1081,216 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
@@ -1081,6 +1081,236 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
}
@@ -93,10 +93,30 @@ index 74e4ad5..f7875b3 100644
+#if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \
+ && MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+/* Forward declaration --- defined in the VoiceOver section below.
+ Identifies faces like vertico-current, icomplete-selected-match,
+ ivy-current-match, corfu-current that mark the selected candidate. */
+static bool ns_ax_face_is_selected (Lisp_Object face);
+/* Identify faces that mark a selected completion candidate.
+ Matches vertico-current, corfu-current, icomplete-selected-match,
+ ivy-current-match, etc. by checking the face symbol name.
+ Defined here so the Zoom patch compiles independently of the
+ VoiceOver patches. */
+static bool
+ns_zoom_face_is_selected (Lisp_Object face)
+{
+ if (SYMBOLP (face))
+ {
+ const char *name = SSDATA (SYMBOL_NAME (face));
+ return (strstr (name, "current") != NULL
+ || strstr (name, "selected") != NULL
+ || strstr (name, "selection") != NULL);
+ }
+ if (CONSP (face))
+ {
+ Lisp_Object tail;
+ for (tail = face; CONSP (tail); tail = XCDR (tail))
+ if (ns_zoom_face_is_selected (XCAR (tail)))
+ return true;
+ }
+ return false;
+}
+
+/* Scan overlay before-string / after-string properties in the
+ selected window for a completion candidate with a "selected"
@@ -144,7 +164,7 @@ index 74e4ad5..f7875b3 100644
+ Lisp_Object face
+ = Fget_text_property (make_fixnum (line_start),
+ Qface, str);
+ if (ns_ax_face_is_selected (face))
+ if (ns_zoom_face_is_selected (face))
+ return line;
+ line++;
+ line_start = i + 1;
@@ -195,7 +215,7 @@ index 74e4ad5..f7875b3 100644
+ Lisp_Object face
+ = Fget_char_property (make_fixnum (pos), Qface,
+ cw->contents);
+ if (ns_ax_face_is_selected (face))
+ if (ns_zoom_face_is_selected (face))
+ {
+ unbind_to (count, Qnil);
+ *child_frame = cf;
@@ -301,7 +321,7 @@ index 74e4ad5..f7875b3 100644
static void
ns_update_end (struct frame *f)
/* --------------------------------------------------------------------------
@@ -1104,6 +1314,41 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
@@ -1104,6 +1334,41 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
unblock_input ();
ns_updating_frame = NULL;
@@ -343,7 +363,7 @@ index 74e4ad5..f7875b3 100644
}
static void
@@ -3232,6 +3477,45 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
@@ -3232,6 +3497,45 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
/* Prevent the cursor from being drawn outside the text area. */
r = NSIntersectionRect (r, ns_row_rect (w, glyph_row, TEXT_AREA));
@@ -389,7 +409,7 @@ index 74e4ad5..f7875b3 100644
ns_focus (f, NULL, 0);
NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
@@ -8321,6 +8605,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
@@ -8321,6 +8625,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO;
processingCompose = NO;