patches: fix Corfu Zoom tracking — replace rate-limit with parent-frame guard
Root cause: the 50ms rate limit broke child-frame (Corfu) tracking. When the Corfu child frame redraws, its ns_update_end fires first and resets the rate-limit timer. When the parent frame's ns_update_end fires immediately after, the timer has not expired, so ns_zoom_track_completion returns early without scanning child frames. Zoom focus stays on the first candidate. Fix: remove the rate limit; add a FRAME_PARENT_FRAME(f) guard instead. Child frames have no completion children to scan; their parent's ns_update_end does the scan via FOR_EACH_FRAME. Returning early on child-frame calls avoids the redundant scan and leaves the timer problem moot. Overhead without the rate limit is ~40 Lisp evaluations per redisplay (~5-20 µs), acceptable given ns_zoom_enabled_p() already caches the UAZoomEnabled() IPC call.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From a5041ede13b2bbcea1ebcb501f8c7317c0fe998f Mon Sep 17 00:00:00 2001
|
||||
From 0e5f90b02aa9d9b9ba1fdba7d88ae54e17417fe9 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 4ad451f..5654283 100644
|
||||
index f8b7a8d..3e005e0 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -7257,11 +7257,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7254,11 +7254,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* ---- Helper: extract buffer text for accessibility ---- */
|
||||
|
||||
@@ -220,7 +220,7 @@ index 4ad451f..5654283 100644
|
||||
static NSString *
|
||||
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
||||
@@ -7332,7 +7475,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
@@ -7329,7 +7472,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 4ad451f..5654283 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));
|
||||
@@ -7413,7 +7556,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||
@@ -7410,7 +7553,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 4ad451f..5654283 100644
|
||||
charposForAccessibilityIndex which handles invisible text. */
|
||||
ptrdiff_t cp_start = charpos_start;
|
||||
ptrdiff_t cp_end = cp_start + charpos_len;
|
||||
@@ -7892,6 +8035,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@@ -7889,6 +8032,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@synthesize cachedOverlayModiff;
|
||||
@synthesize cachedTextStart;
|
||||
@synthesize cachedModiff;
|
||||
@@ -246,7 +246,7 @@ index 4ad451f..5654283 100644
|
||||
@synthesize cachedPoint;
|
||||
@synthesize cachedMarkActive;
|
||||
@synthesize cachedCompletionAnnouncement;
|
||||
@@ -7989,7 +8133,7 @@ - (void)ensureTextCache
|
||||
@@ -7986,7 +8130,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 4ad451f..5654283 100644
|
||||
write section at the end needs synchronization to protect
|
||||
against concurrent reads from AX server thread. */
|
||||
eassert ([NSThread isMainThread]);
|
||||
@@ -8001,25 +8145,16 @@ - (void)ensureTextCache
|
||||
@@ -7998,25 +8142,16 @@ - (void)ensureTextCache
|
||||
if (!b)
|
||||
return;
|
||||
|
||||
@@ -289,7 +289,7 @@ index 4ad451f..5654283 100644
|
||||
&& cachedTextStart == BUF_BEGV (b)
|
||||
&& pt >= cachedTextStart
|
||||
&& (textLen == 0
|
||||
@@ -8035,7 +8170,7 @@ included in the cached AX text (it is handled separately via
|
||||
@@ -8032,7 +8167,7 @@ included in the cached AX text (it is handled separately via
|
||||
{
|
||||
[cachedText release];
|
||||
cachedText = [text retain];
|
||||
@@ -298,7 +298,7 @@ index 4ad451f..5654283 100644
|
||||
cachedTextStart = start;
|
||||
|
||||
if (visibleRuns)
|
||||
@@ -8100,7 +8235,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8097,7 +8232,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 4ad451f..5654283 100644
|
||||
NSUInteger lo = 0, hi = visibleRunCount;
|
||||
while (lo < hi)
|
||||
{
|
||||
@@ -8113,7 +8248,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8110,7 +8245,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
else
|
||||
{
|
||||
/* Found: charpos is inside this run. Compute UTF-16 delta
|
||||
@@ -316,7 +316,7 @@ index 4ad451f..5654283 100644
|
||||
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
||||
if (chars_in == 0 || !cachedText)
|
||||
return r->ax_start;
|
||||
@@ -8138,10 +8273,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
@@ -8135,10 +8270,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 4ad451f..5654283 100644
|
||||
@synchronized (self)
|
||||
{
|
||||
if (visibleRunCount == 0)
|
||||
@@ -8175,7 +8310,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8172,7 +8307,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ index 4ad451f..5654283 100644
|
||||
if (lo > 0)
|
||||
{
|
||||
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
||||
@@ -8197,7 +8332,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
@@ -8194,7 +8329,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 4ad451f..5654283 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
|
||||
@@ -8551,6 +8686,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
@@ -8548,6 +8683,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
return [self lineForAXIndex:point_idx];
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ index 4ad451f..5654283 100644
|
||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
||||
{
|
||||
if (![NSThread isMainThread])
|
||||
@@ -8773,7 +8952,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -8770,7 +8949,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -407,7 +407,7 @@ index 4ad451f..5654283 100644
|
||||
|
||||
These methods notify VoiceOver of text and selection changes.
|
||||
Called from the redisplay cycle (postAccessibilityUpdates).
|
||||
@@ -8788,7 +8967,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8785,7 +8964,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
if (point > self.cachedPoint
|
||||
&& point - self.cachedPoint == 1)
|
||||
{
|
||||
@@ -416,7 +416,7 @@ index 4ad451f..5654283 100644
|
||||
[self invalidateTextCache];
|
||||
[self ensureTextCache];
|
||||
if (cachedText)
|
||||
@@ -8807,7 +8986,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
@@ -8804,7 +8983,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 4ad451f..5654283 100644
|
||||
self.cachedPoint = point;
|
||||
|
||||
NSDictionary *change = @{
|
||||
@@ -9140,16 +9319,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
@@ -9137,16 +9316,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
BOOL markActive = !NILP (BVAR (b, mark_active));
|
||||
|
||||
/* --- Text changed (edit) --- */
|
||||
@@ -513,7 +513,7 @@ index 4ad451f..5654283 100644
|
||||
{
|
||||
ptrdiff_t oldPoint = self.cachedPoint;
|
||||
BOOL oldMarkActive = self.cachedMarkActive;
|
||||
@@ -9317,7 +9563,7 @@ - (NSRect)accessibilityFrame
|
||||
@@ -9314,7 +9560,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -522,7 +522,7 @@ index 4ad451f..5654283 100644
|
||||
=================================================================== */
|
||||
|
||||
/* Scan visible range of window W for interactive spans.
|
||||
@@ -9525,7 +9771,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9522,7 +9768,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 4ad451f..5654283 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)))
|
||||
@@ -9551,7 +9797,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
@@ -9548,7 +9794,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
|
||||
@end
|
||||
|
||||
@@ -540,7 +540,7 @@ index 4ad451f..5654283 100644
|
||||
Methods are kept here (same .m file) so they access the ivars
|
||||
declared in the @interface ivar block. */
|
||||
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
||||
@@ -12273,7 +12519,7 @@ - (int) fullscreenState
|
||||
@@ -12270,7 +12516,7 @@ - (int) fullscreenState
|
||||
|
||||
if (WINDOW_LEAF_P (w))
|
||||
{
|
||||
@@ -549,7 +549,7 @@ index 4ad451f..5654283 100644
|
||||
EmacsAccessibilityBuffer *elem
|
||||
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
||||
if (!elem)
|
||||
@@ -12307,7 +12553,7 @@ - (int) fullscreenState
|
||||
@@ -12304,7 +12550,7 @@ - (int) fullscreenState
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -558,7 +558,7 @@ index 4ad451f..5654283 100644
|
||||
Lisp_Object child = w->contents;
|
||||
while (!NILP (child))
|
||||
{
|
||||
@@ -12419,7 +12665,7 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12416,7 +12662,7 @@ - (void)postAccessibilityUpdates
|
||||
accessibilityUpdating = YES;
|
||||
|
||||
/* Detect window tree change (split, delete, new buffer). Compare
|
||||
@@ -567,7 +567,7 @@ index 4ad451f..5654283 100644
|
||||
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
||||
if (!EQ (curRoot, lastRootWindow))
|
||||
{
|
||||
@@ -12428,12 +12674,12 @@ - (void)postAccessibilityUpdates
|
||||
@@ -12425,12 +12671,12 @@ - (void)postAccessibilityUpdates
|
||||
}
|
||||
|
||||
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
||||
|
||||
Reference in New Issue
Block a user