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:
2026-03-01 07:11:00 +01:00
parent 19cc43dbbb
commit c4975c3fe4
9 changed files with 83 additions and 86 deletions

View File

@@ -1,4 +1,4 @@
From 2dabc7e44d316fa29e64958383fbac230f0f6870 Mon Sep 17 00:00:00 2001
From 85259296769fe8e30d3fa2d8a7626729023c8691 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
@@ -109,10 +109,10 @@ index 2102fb9..dd98d56 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index 5654283..69644d5 100644
index 3e005e0..d61a634 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7401,6 +7401,112 @@ visual line index for Zoom (skip whitespace-only lines
@@ -7398,6 +7398,112 @@ visual line index for Zoom (skip whitespace-only lines
return nil;
}
@@ -225,7 +225,7 @@ index 5654283..69644d5 100644
/* Build accessibility text for window W, skipping invisible text.
Populates *OUT_START with the buffer start charpos.
Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS
@@ -8145,16 +8251,25 @@ - (void)ensureTextCache
@@ -8142,16 +8248,25 @@ - (void)ensureTextCache
if (!b)
return;
@@ -259,7 +259,7 @@ index 5654283..69644d5 100644
&& cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart
&& (textLen == 0
@@ -8170,7 +8285,7 @@ included in the cached AX text (it is handled separately via
@@ -8167,7 +8282,7 @@ included in the cached AX text (it is handled separately via
{
[cachedText release];
cachedText = [text retain];
@@ -268,7 +268,7 @@ index 5654283..69644d5 100644
cachedTextStart = start;
if (visibleRuns)
@@ -9138,6 +9253,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
@@ -9135,6 +9250,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0;
@@ -276,7 +276,7 @@ index 5654283..69644d5 100644
specpdl_ref count2 = SPECPDL_INDEX ();
record_unwind_current_buffer ();
if (b != current_buffer)
@@ -9296,6 +9412,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
@@ -9293,6 +9409,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
self.cachedCompletionOverlayEnd = 0;
self.cachedCompletionPoint = 0;
}
@@ -284,7 +284,7 @@ index 5654283..69644d5 100644
}
/* ---- Notification dispatch (main entry point) ---- */
@@ -9892,6 +10009,10 @@ - (void)dealloc
@@ -9889,6 +10006,10 @@ - (void)dealloc
#endif
[accessibilityElements release];
@@ -295,7 +295,7 @@ index 5654283..69644d5 100644
[[self menu] release];
[super dealloc];
}
@@ -11341,6 +11462,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
@@ -11338,6 +11459,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO;
processingCompose = NO;
@@ -305,7 +305,7 @@ index 5654283..69644d5 100644
scrollbarsNeedingUpdate = 0;
fs_state = FULLSCREEN_NONE;
fs_before_fs = next_maximized = -1;
@@ -12649,6 +12773,80 @@ - (id)accessibilityFocusedUIElement
@@ -12646,6 +12770,80 @@ - (id)accessibilityFocusedUIElement
The existing elements carry cached state (modiff, point) from the
previous redisplay cycle. Rebuilding first would create fresh
elements with current values, making change detection impossible. */
@@ -386,7 +386,7 @@ index 5654283..69644d5 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12659,11 +12857,59 @@ - (void)postAccessibilityUpdates
@@ -12656,11 +12854,59 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us