patches: reduce completion tracking rate-limit from 500ms to 50ms
500ms (2 Hz) was too aggressive — Zoom focus stopped updating during keyboard navigation in Vertico/Corfu lists. 50ms (20 Hz) tracks fast arrow-key navigation while still avoiding per-frame overhead. UAZoomEnabled() is already cached so the main cost is the overlay scan, which is cheap.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From ba3ea125d91b9e2379ce1da3b000a0896255ac50 Mon Sep 17 00:00:00 2001
|
||||
From 03bc19846230e9df6545948e6a431fdb7bdce031 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sukany <martin@sukany.cz>
|
||||
Date: Sat, 28 Feb 2026 14:46:25 +0100
|
||||
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver
|
||||
@@ -61,10 +61,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 c796840..f1aa0a4 100644
|
||||
index 1577338..71b6d2e 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -7208,11 +7208,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7209,11 +7209,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* ---- Helper: extract buffer text for accessibility ---- */
|
||||
|
||||
@@ -220,7 +220,7 @@ index c796840..f1aa0a4 100644
|
||||
static NSString *
|
||||
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
||||
@@ -7283,7 +7426,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7284,7 +7427,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* Extract this visible run's text. Use
|
||||
Fbuffer_substring_no_properties which correctly handles the
|
||||
@@ -229,7 +229,7 @@ index c796840..f1aa0a4 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));
|
||||
@@ -7364,7 +7507,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||
@@ -7365,7 +7508,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
|
||||
@@ -238,7 +238,7 @@ index c796840..f1aa0a4 100644
|
||||
charposForAccessibilityIndex which handles invisible text. */
|
||||
ptrdiff_t cp_start = charpos_start;
|
||||
ptrdiff_t cp_end = cp_start + charpos_len;
|
||||
@@ -7843,6 +7986,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@@ -7844,6 +7987,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@synthesize cachedOverlayModiff;
|
||||
@synthesize cachedTextStart;
|
||||
@synthesize cachedModiff;
|
||||
@@ -246,7 +246,7 @@ index c796840..f1aa0a4 100644
|
||||
@synthesize cachedPoint;
|
||||
@synthesize cachedMarkActive;
|
||||
@synthesize cachedCompletionAnnouncement;
|
||||
@@ -7940,7 +8084,7 @@ - (void)ensureTextCache
|
||||
@@ -7941,7 +8085,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
|
||||
@@ -255,7 +255,7 @@ index c796840..f1aa0a4 100644
|
||||
write section at the end needs synchronization to protect
|
||||
against concurrent reads from AX server thread. */
|
||||
eassert ([NSThread isMainThread]);
|
||||
@@ -7952,25 +8096,16 @@ - (void)ensureTextCache
|
||||
@@ -7953,25 +8097,16 @@ - (void)ensureTextCache
|
||||
if (!b)
|
||||
return;
|
||||
|
||||
@@ -289,7 +289,7 @@ index c796840..f1aa0a4 100644
|
||||
&& cachedTextStart == BUF_BEGV (b)
|
||||
&& pt >= cachedTextStart
|
||||
&& (textLen == 0
|
||||
@@ -7986,7 +8121,7 @@ included in the cached AX text (it is handled separately via
|
||||
@@ -7987,7 +8122,7 @@ included in the cached AX text (it is handled separately via
|
||||
{
|
||||
[cachedText release];
|
||||
cachedText = [text retain];
|
||||
@@ -298,7 +298,7 @@ index c796840..f1aa0a4 100644
|
||||
cachedTextStart = start;
|
||||
|
||||
if (visibleRuns)
|
||||
@@ -8051,7 +8186,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8052,7 +8187,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
|
||||
@@ -307,7 +307,7 @@ index c796840..f1aa0a4 100644
|
||||
NSUInteger lo = 0, hi = visibleRunCount;
|
||||
while (lo < hi)
|
||||
{
|
||||
@@ -8064,7 +8199,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8065,7 +8200,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
else
|
||||
{
|
||||
/* Found: charpos is inside this run. Compute UTF-16 delta
|
||||
@@ -316,7 +316,7 @@ index c796840..f1aa0a4 100644
|
||||
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
||||
if (chars_in == 0 || !cachedText)
|
||||
return r->ax_start;
|
||||
@@ -8089,10 +8224,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8090,10 +8225,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
|
||||
/* Convert accessibility string index to buffer charpos.
|
||||
Safe to call from any thread: uses only cachedText (NSString) and
|
||||
@@ -329,7 +329,7 @@ index c796840..f1aa0a4 100644
|
||||
@synchronized (self)
|
||||
{
|
||||
if (visibleRunCount == 0)
|
||||
@@ -8126,7 +8261,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8127,7 +8262,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ index c796840..f1aa0a4 100644
|
||||
if (lo > 0)
|
||||
{
|
||||
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
||||
@@ -8148,7 +8283,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8149,7 +8284,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
|
||||
@@ -347,7 +347,7 @@ index c796840..f1aa0a4 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
|
||||
@@ -8502,6 +8637,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
@@ -8503,6 +8638,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
return [self lineForAXIndex:point_idx];
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ index c796840..f1aa0a4 100644
|
||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
||||
{
|
||||
if (![NSThread isMainThread])
|
||||
@@ -8724,7 +8903,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -8725,7 +8904,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -407,7 +407,7 @@ index c796840..f1aa0a4 100644
|
||||
|
||||
These methods notify VoiceOver of text and selection changes.
|
||||
Called from the redisplay cycle (postAccessibilityUpdates).
|
||||
@@ -8739,7 +8918,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8740,7 +8919,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
if (point > self.cachedPoint
|
||||
&& point - self.cachedPoint == 1)
|
||||
{
|
||||
@@ -416,7 +416,7 @@ index c796840..f1aa0a4 100644
|
||||
[self invalidateTextCache];
|
||||
[self ensureTextCache];
|
||||
if (cachedText)
|
||||
@@ -8758,7 +8937,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8759,7 +8938,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
|
||||
@@ -425,7 +425,7 @@ index c796840..f1aa0a4 100644
|
||||
self.cachedPoint = point;
|
||||
|
||||
NSDictionary *change = @{
|
||||
@@ -9091,16 +9270,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
@@ -9092,16 +9271,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
BOOL markActive = !NILP (BVAR (b, mark_active));
|
||||
|
||||
/* --- Text changed (edit) --- */
|
||||
@@ -513,7 +513,7 @@ index c796840..f1aa0a4 100644
|
||||
{
|
||||
ptrdiff_t oldPoint = self.cachedPoint;
|
||||
BOOL oldMarkActive = self.cachedMarkActive;
|
||||
@@ -9268,7 +9514,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -9269,7 +9515,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -522,7 +522,7 @@ index c796840..f1aa0a4 100644
|
||||
=================================================================== */
|
||||
|
||||
/* Scan visible range of window W for interactive spans.
|
||||
@@ -9476,7 +9722,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9477,7 +9723,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
|
||||
@@ -531,7 +531,7 @@ index c796840..f1aa0a4 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)))
|
||||
@@ -9502,7 +9748,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9503,7 +9749,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
|
||||
@end
|
||||
|
||||
@@ -540,7 +540,7 @@ index c796840..f1aa0a4 100644
|
||||
Methods are kept here (same .m file) so they access the ivars
|
||||
declared in the @interface ivar block. */
|
||||
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
||||
@@ -12224,7 +12470,7 @@ - (int) fullscreenState
|
||||
@@ -12225,7 +12471,7 @@ - (int) fullscreenState
|
||||
|
||||
if (WINDOW_LEAF_P (w))
|
||||
{
|
||||
@@ -549,7 +549,7 @@ index c796840..f1aa0a4 100644
|
||||
EmacsAccessibilityBuffer *elem
|
||||
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
||||
if (!elem)
|
||||
@@ -12258,7 +12504,7 @@ - (int) fullscreenState
|
||||
@@ -12259,7 +12505,7 @@ - (int) fullscreenState
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -558,7 +558,7 @@ index c796840..f1aa0a4 100644
|
||||
Lisp_Object child = w->contents;
|
||||
while (!NILP (child))
|
||||
{
|
||||
@@ -12370,7 +12616,7 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12371,7 +12617,7 @@ - (void)postAccessibilityUpdates
|
||||
accessibilityUpdating = YES;
|
||||
|
||||
/* Detect window tree change (split, delete, new buffer). Compare
|
||||
@@ -567,7 +567,7 @@ index c796840..f1aa0a4 100644
|
||||
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
||||
if (!EQ (curRoot, lastRootWindow))
|
||||
{
|
||||
@@ -12379,12 +12625,12 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12380,12 +12626,12 @@ - (void)postAccessibilityUpdates
|
||||
}
|
||||
|
||||
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
||||
|
||||
Reference in New Issue
Block a user