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:
@@ -1,4 +1,4 @@
|
||||
From 314e2a5f406a8eb0e6909be6e07fe7e8ddd1c440 Mon Sep 17 00:00:00 2001
|
||||
From a979f430547512c252320e76683a288872f4f2ff Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sukany <martin@sukany.cz>
|
||||
Date: Sat, 28 Feb 2026 14:46:25 +0100
|
||||
Subject: [PATCH 08/11] ns: announce overlay completion candidates for
|
||||
@@ -62,10 +62,10 @@ index 6e830de..2102fb9 100644
|
||||
@property (nonatomic, assign) BOOL cachedMarkActive;
|
||||
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 9de92fb..7c44e9c 100644
|
||||
index 92a0dde..aaeed33 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -7154,11 +7154,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7174,11 +7174,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* ---- Helper: extract buffer text for accessibility ---- */
|
||||
|
||||
@@ -221,7 +221,7 @@ index 9de92fb..7c44e9c 100644
|
||||
static NSString *
|
||||
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
||||
@@ -7229,7 +7372,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7249,7 +7392,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* Extract this visible run's text. Use
|
||||
Fbuffer_substring_no_properties which correctly handles the
|
||||
@@ -230,7 +230,7 @@ index 9de92fb..7c44e9c 100644
|
||||
include garbage bytes when the run spans the gap position. */
|
||||
Lisp_Object lstr = Fbuffer_substring_no_properties (
|
||||
make_fixnum (pos), make_fixnum (run_end));
|
||||
@@ -7310,7 +7453,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||
@@ -7330,7 +7473,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||
return NSZeroRect;
|
||||
|
||||
/* charpos_start and charpos_len are already in buffer charpos
|
||||
@@ -239,7 +239,7 @@ index 9de92fb..7c44e9c 100644
|
||||
charposForAccessibilityIndex which handles invisible text. */
|
||||
ptrdiff_t cp_start = charpos_start;
|
||||
ptrdiff_t cp_end = cp_start + charpos_len;
|
||||
@@ -7789,6 +7932,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@@ -7809,6 +7952,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@synthesize cachedOverlayModiff;
|
||||
@synthesize cachedTextStart;
|
||||
@synthesize cachedModiff;
|
||||
@@ -247,7 +247,7 @@ index 9de92fb..7c44e9c 100644
|
||||
@synthesize cachedPoint;
|
||||
@synthesize cachedMarkActive;
|
||||
@synthesize cachedCompletionAnnouncement;
|
||||
@@ -7886,7 +8030,7 @@ - (void)ensureTextCache
|
||||
@@ -7906,7 +8050,7 @@ - (void)ensureTextCache
|
||||
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
|
||||
/* This method is only called from the main thread (AX getters
|
||||
dispatch_sync to main first). Reads of cachedText/cachedTextModiff
|
||||
@@ -256,7 +256,7 @@ index 9de92fb..7c44e9c 100644
|
||||
write section at the end needs synchronization to protect
|
||||
against concurrent reads from AX server thread. */
|
||||
eassert ([NSThread isMainThread]);
|
||||
@@ -7899,16 +8043,15 @@ - (void)ensureTextCache
|
||||
@@ -7919,16 +8063,15 @@ - (void)ensureTextCache
|
||||
return;
|
||||
|
||||
ptrdiff_t modiff = BUF_MODIFF (b);
|
||||
@@ -279,7 +279,7 @@ index 9de92fb..7c44e9c 100644
|
||||
&& cachedTextStart == BUF_BEGV (b)
|
||||
&& pt >= cachedTextStart
|
||||
&& (textLen == 0
|
||||
@@ -7925,7 +8068,6 @@ - (void)ensureTextCache
|
||||
@@ -7945,7 +8088,6 @@ - (void)ensureTextCache
|
||||
[cachedText release];
|
||||
cachedText = [text retain];
|
||||
cachedTextModiff = modiff;
|
||||
@@ -287,7 +287,7 @@ index 9de92fb..7c44e9c 100644
|
||||
cachedTextStart = start;
|
||||
|
||||
if (visibleRuns)
|
||||
@@ -7990,7 +8132,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8010,7 +8152,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
/* Binary search: runs are sorted by charpos (ascending). Find the
|
||||
run whose [charpos, charpos+length) range contains the target,
|
||||
or the nearest run after an invisible gap. O(log n) instead of
|
||||
@@ -296,7 +296,7 @@ index 9de92fb..7c44e9c 100644
|
||||
NSUInteger lo = 0, hi = visibleRunCount;
|
||||
while (lo < hi)
|
||||
{
|
||||
@@ -8003,7 +8145,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8023,7 +8165,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
else
|
||||
{
|
||||
/* Found: charpos is inside this run. Compute UTF-16 delta
|
||||
@@ -305,7 +305,7 @@ index 9de92fb..7c44e9c 100644
|
||||
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
||||
if (chars_in == 0 || !cachedText)
|
||||
return r->ax_start;
|
||||
@@ -8028,10 +8170,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8048,10 +8190,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
|
||||
/* Convert accessibility string index to buffer charpos.
|
||||
Safe to call from any thread: uses only cachedText (NSString) and
|
||||
@@ -318,7 +318,7 @@ index 9de92fb..7c44e9c 100644
|
||||
@synchronized (self)
|
||||
{
|
||||
if (visibleRunCount == 0)
|
||||
@@ -8065,7 +8207,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8085,7 +8227,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +327,7 @@ index 9de92fb..7c44e9c 100644
|
||||
if (lo > 0)
|
||||
{
|
||||
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
||||
@@ -8087,7 +8229,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8107,7 +8249,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
deadlocking the AX server thread. This is prevented by:
|
||||
|
||||
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
|
||||
@@ -336,7 +336,7 @@ index 9de92fb..7c44e9c 100644
|
||||
2. All dispatch_sync blocks run on the main thread where no
|
||||
concurrent Lisp code can modify state between checks.
|
||||
3. block_input prevents timer events and process output from
|
||||
@@ -8441,6 +8583,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
@@ -8461,6 +8603,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
return [self lineForAXIndex:point_idx];
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ index 9de92fb..7c44e9c 100644
|
||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
||||
{
|
||||
if (![NSThread isMainThread])
|
||||
@@ -8663,7 +8849,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -8683,7 +8869,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -396,7 +396,7 @@ index 9de92fb..7c44e9c 100644
|
||||
|
||||
These methods notify VoiceOver of text and selection changes.
|
||||
Called from the redisplay cycle (postAccessibilityUpdates).
|
||||
@@ -8678,7 +8864,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8698,7 +8884,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
if (point > self.cachedPoint
|
||||
&& point - self.cachedPoint == 1)
|
||||
{
|
||||
@@ -405,7 +405,7 @@ index 9de92fb..7c44e9c 100644
|
||||
[self invalidateTextCache];
|
||||
[self ensureTextCache];
|
||||
if (cachedText)
|
||||
@@ -8697,7 +8883,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8717,7 +8903,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
/* Update cachedPoint here so the selection-move branch does NOT
|
||||
fire for point changes caused by edits. WebKit and Chromium
|
||||
never send both ValueChanged and SelectedTextChanged for the
|
||||
@@ -414,7 +414,7 @@ index 9de92fb..7c44e9c 100644
|
||||
self.cachedPoint = point;
|
||||
|
||||
NSDictionary *change = @{
|
||||
@@ -9030,16 +9216,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
@@ -9050,16 +9236,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
BOOL markActive = !NILP (BVAR (b, mark_active));
|
||||
|
||||
/* --- Text changed (edit) --- */
|
||||
@@ -502,7 +502,7 @@ index 9de92fb..7c44e9c 100644
|
||||
{
|
||||
ptrdiff_t oldPoint = self.cachedPoint;
|
||||
BOOL oldMarkActive = self.cachedMarkActive;
|
||||
@@ -9207,7 +9460,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -9227,7 +9480,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -511,7 +511,7 @@ index 9de92fb..7c44e9c 100644
|
||||
=================================================================== */
|
||||
|
||||
/* Scan visible range of window W for interactive spans.
|
||||
@@ -9415,7 +9668,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9435,7 +9688,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
dispatch_async (dispatch_get_main_queue (), ^{
|
||||
/* lwin is a Lisp_Object captured by value. This is GC-safe
|
||||
because Lisp_Objects are tagged integers/pointers that
|
||||
@@ -520,7 +520,7 @@ index 9de92fb..7c44e9c 100644
|
||||
Emacs. The WINDOW_LIVE_P check below guards against the
|
||||
window being deleted between capture and execution. */
|
||||
if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin)))
|
||||
@@ -9441,7 +9694,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9461,7 +9714,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
|
||||
@end
|
||||
|
||||
@@ -529,7 +529,7 @@ index 9de92fb..7c44e9c 100644
|
||||
Methods are kept here (same .m file) so they access the ivars
|
||||
declared in the @interface ivar block. */
|
||||
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
||||
@@ -12166,7 +12419,7 @@ - (int) fullscreenState
|
||||
@@ -12186,7 +12439,7 @@ - (int) fullscreenState
|
||||
|
||||
if (WINDOW_LEAF_P (w))
|
||||
{
|
||||
@@ -538,7 +538,7 @@ index 9de92fb..7c44e9c 100644
|
||||
EmacsAccessibilityBuffer *elem
|
||||
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
||||
if (!elem)
|
||||
@@ -12200,7 +12453,7 @@ - (int) fullscreenState
|
||||
@@ -12220,7 +12473,7 @@ - (int) fullscreenState
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -547,7 +547,7 @@ index 9de92fb..7c44e9c 100644
|
||||
Lisp_Object child = w->contents;
|
||||
while (!NILP (child))
|
||||
{
|
||||
@@ -12312,7 +12565,7 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12332,7 +12585,7 @@ - (void)postAccessibilityUpdates
|
||||
accessibilityUpdating = YES;
|
||||
|
||||
/* Detect window tree change (split, delete, new buffer). Compare
|
||||
@@ -556,7 +556,7 @@ index 9de92fb..7c44e9c 100644
|
||||
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
||||
if (!EQ (curRoot, lastRootWindow))
|
||||
{
|
||||
@@ -12321,12 +12574,12 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12341,12 +12594,12 @@ - (void)postAccessibilityUpdates
|
||||
}
|
||||
|
||||
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
||||
|
||||
Reference in New Issue
Block a user