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:
2026-03-01 06:30:01 +01:00
parent 63f0e899ce
commit cc7b288e99
9 changed files with 75 additions and 74 deletions

View File

@@ -1,4 +1,4 @@
From 82465943223138dfa1185467400e547c59e6e1be Mon Sep 17 00:00:00 2001 From 38bbd275736251862f4b2fb433ee0a84799f0cec Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 22:39:35 +0100 Date: Sat, 28 Feb 2026 22:39:35 +0100
Subject: [PATCH 1/9] ns: integrate with macOS Zoom for cursor tracking Subject: [PATCH 1/9] ns: integrate with macOS Zoom for cursor tracking
@@ -38,8 +38,8 @@ window splits, switches (C-x o), and completion frameworks.
--- ---
etc/NEWS | 11 ++ etc/NEWS | 11 ++
src/nsterm.h | 6 + src/nsterm.h | 6 +
src/nsterm.m | 338 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/nsterm.m | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 355 insertions(+) 3 files changed, 356 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS diff --git a/etc/NEWS b/etc/NEWS
index ef36df5..80661a9 100644 index ef36df5..80661a9 100644
@@ -81,10 +81,10 @@ index 7c1ee4c..ea6e7ba 100644
} }
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index 74e4ad5..d624a76 100644 index 74e4ad5..6527750 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -1081,6 +1081,270 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) @@ -1081,6 +1081,271 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
} }
@@ -269,13 +269,14 @@ index 74e4ad5..d624a76 100644
+ if (!WINDOWP (f->selected_window)) + if (!WINDOWP (f->selected_window))
+ return; + return;
+ +
+ /* Rate-limit completion scan to 2 Hz. Completion state changes at + /* Rate-limit completion scan to 20 Hz (50 ms). UAZoomEnabled() is
+ human interaction speed; checking every 500 ms eliminates + now cached so the main cost is the overlay/child-frame scan.
+ per-redisplay FOR_EACH_FRAME overhead with no perceptible lag. */ + 50 ms is imperceptible for completion navigation while preventing
+ per-frame FOR_EACH_FRAME overhead. */
+ { + {
+ static CFAbsoluteTime last_check; + static CFAbsoluteTime last_check;
+ CFAbsoluteTime now = CFAbsoluteTimeGetCurrent (); + CFAbsoluteTime now = CFAbsoluteTimeGetCurrent ();
+ if (now - last_check < 0.5) + if (now - last_check < 0.05)
+ return; + return;
+ last_check = now; + last_check = now;
+ } + }
@@ -355,7 +356,7 @@ index 74e4ad5..d624a76 100644
static void static void
ns_update_end (struct frame *f) ns_update_end (struct frame *f)
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
@@ -1104,6 +1368,41 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) @@ -1104,6 +1369,41 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
unblock_input (); unblock_input ();
ns_updating_frame = NULL; ns_updating_frame = NULL;
@@ -397,7 +398,7 @@ index 74e4ad5..d624a76 100644
} }
static void static void
@@ -3232,6 +3531,45 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors. @@ -3232,6 +3532,45 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
/* Prevent the cursor from being drawn outside the text area. */ /* Prevent the cursor from being drawn outside the text area. */
r = NSIntersectionRect (r, ns_row_rect (w, glyph_row, TEXT_AREA)); r = NSIntersectionRect (r, ns_row_rect (w, glyph_row, TEXT_AREA));

View File

@@ -1,4 +1,4 @@
From 2320cde84ba0577f2f09f1ef43aa9949ca4f142f Mon Sep 17 00:00:00 2001 From 92f8d65bd248ac3bcc5d40b0707ffa184d3c7fa5 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 2/9] ns: add accessibility base classes and text extraction Subject: [PATCH 2/9] ns: add accessibility base classes and text extraction
@@ -188,7 +188,7 @@ index ea6e7ba..6e830de 100644
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index d624a76..7390b47 100644 index 6527750..3e97248 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch) @@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch)
@@ -199,7 +199,7 @@ index d624a76..7390b47 100644
#include "systime.h" #include "systime.h"
#include "character.h" #include "character.h"
#include "xwidget.h" #include "xwidget.h"
@@ -7194,6 +7195,430 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg @@ -7195,6 +7196,430 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
} }
#endif #endif
@@ -630,7 +630,7 @@ index d624a76..7390b47 100644
/* ========================================================================== /* ==========================================================================
EmacsView implementation EmacsView implementation
@@ -11650,6 +12075,28 @@ Convert an X font name (XLFD) to an NS font name. @@ -11651,6 +12076,28 @@ Convert an X font name (XLFD) to an NS font name.
DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic"); DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic");
DEFSYM (Qns_handle_drag_motion, "ns-handle-drag-motion"); DEFSYM (Qns_handle_drag_motion, "ns-handle-drag-motion");
@@ -659,7 +659,7 @@ index d624a76..7390b47 100644
Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier));
Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));
Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier));
@@ -11782,7 +12229,7 @@ Convert an X font name (XLFD) to an NS font name. @@ -11783,7 +12230,7 @@ Convert an X font name (XLFD) to an NS font name.
doc: /* Non-nil means to use native fullscreen on Mac OS X 10.7 and later. doc: /* Non-nil means to use native fullscreen on Mac OS X 10.7 and later.
Nil means use fullscreen the old (< 10.7) way. The old way works better with Nil means use fullscreen the old (< 10.7) way. The old way works better with
multiple monitors, but lacks tool bar. This variable is ignored on multiple monitors, but lacks tool bar. This variable is ignored on
@@ -668,7 +668,7 @@ index d624a76..7390b47 100644
ns_use_native_fullscreen = YES; ns_use_native_fullscreen = YES;
ns_last_use_native_fullscreen = ns_use_native_fullscreen; ns_last_use_native_fullscreen = ns_use_native_fullscreen;
@@ -11798,10 +12245,19 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with @@ -11799,10 +12246,19 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
This variable is ignored on Mac OS X < 10.7 and GNUstep. */); This variable is ignored on Mac OS X < 10.7 and GNUstep. */);
ns_use_srgb_colorspace = YES; ns_use_srgb_colorspace = YES;
@@ -689,7 +689,7 @@ index d624a76..7390b47 100644
ns_use_mwheel_acceleration = YES; ns_use_mwheel_acceleration = YES;
DEFVAR_LISP ("ns-mwheel-line-height", ns_mwheel_line_height, DEFVAR_LISP ("ns-mwheel-line-height", ns_mwheel_line_height,
@@ -11812,7 +12268,7 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with @@ -11813,7 +12269,7 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
DEFVAR_BOOL ("ns-use-mwheel-momentum", ns_use_mwheel_momentum, DEFVAR_BOOL ("ns-use-mwheel-momentum", ns_use_mwheel_momentum,
doc: /* Non-nil means mouse wheel scrolling uses momentum. doc: /* Non-nil means mouse wheel scrolling uses momentum.

View File

@@ -1,4 +1,4 @@
From 60df7f8141d50a3c7e257151f43a0cc0b2a325e3 Mon Sep 17 00:00:00 2001 From a9af26dc0f2762b5e53785554f110a08aad72d01 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 3/9] ns: implement buffer accessibility element (core Subject: [PATCH 3/9] ns: implement buffer accessibility element (core
@@ -22,10 +22,10 @@ line-by-line navigation, word/character announcements.
1 file changed, 1104 insertions(+) 1 file changed, 1104 insertions(+)
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index 7390b47..a144abb 100644 index 3e97248..7beedc4 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -7616,6 +7616,1110 @@ - (id)accessibilityTopLevelUIElement @@ -7617,6 +7617,1110 @@ - (id)accessibilityTopLevelUIElement
@end @end

View File

@@ -1,4 +1,4 @@
From 4ea286a9cb5f13d8854d646f891677500ed4094a Mon Sep 17 00:00:00 2001 From 593b5219ee63b32125efc0e58e9c376c949b463b Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 4/9] ns: add buffer notification dispatch and mode-line Subject: [PATCH 4/9] ns: add buffer notification dispatch and mode-line
@@ -24,10 +24,10 @@ region selection feedback, completion popups, mode-line reading.
1 file changed, 545 insertions(+) 1 file changed, 545 insertions(+)
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index a144abb..e818817 100644 index 7beedc4..ecc8c54 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -8720,6 +8720,551 @@ - (NSRect)accessibilityFrame @@ -8721,6 +8721,551 @@ - (NSRect)accessibilityFrame
@end @end

View File

@@ -1,4 +1,4 @@
From deb9e1e6d759b387246a71061194716505920684 Mon Sep 17 00:00:00 2001 From 19053ea6ef478603115e2f4288f54d44ce204bcd Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 5/9] ns: add interactive span elements for Tab navigation Subject: [PATCH 5/9] ns: add interactive span elements for Tab navigation
@@ -17,10 +17,10 @@ Tested on macOS 14. Verified: Tab-cycling through org-mode links,
1 file changed, 286 insertions(+) 1 file changed, 286 insertions(+)
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index e818817..d2a5a58 100644 index ecc8c54..5eaf480 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -9265,6 +9265,292 @@ - (NSRect)accessibilityFrame @@ -9266,6 +9266,292 @@ - (NSRect)accessibilityFrame
@end @end

View File

@@ -1,4 +1,4 @@
From d2436b4215e5480d35f88fcb5b78fb8f8e44945d Mon Sep 17 00:00:00 2001 From 7b4c8fc93674296aac802377ad223db50f79f33d Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay
@@ -51,10 +51,10 @@ index 80661a9..2b1f9e6 100644
** Re-introduced dictation, lost in Emacs v30 (macOS). ** Re-introduced dictation, lost in Emacs v30 (macOS).
We lost macOS dictation in v30 when migrating to NSTextInputClient. We lost macOS dictation in v30 when migrating to NSTextInputClient.
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index d2a5a58..c796840 100644 index 5eaf480..1577338 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -1404,6 +1404,9 @@ so the visual offset is (ov_line + 1) * line_h from @@ -1405,6 +1405,9 @@ so the visual offset is (ov_line + 1) * line_h from
if (view) if (view)
ns_zoom_track_completion (f, view); ns_zoom_track_completion (f, view);
#endif /* NS_IMPL_COCOA */ #endif /* NS_IMPL_COCOA */
@@ -64,7 +64,7 @@ index d2a5a58..c796840 100644
} }
static void static void
@@ -7619,7 +7622,6 @@ - (id)accessibilityTopLevelUIElement @@ -7620,7 +7623,6 @@ - (id)accessibilityTopLevelUIElement
@@ -72,7 +72,7 @@ index d2a5a58..c796840 100644
static BOOL static BOOL
ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point, ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point,
ptrdiff_t *out_start, ptrdiff_t *out_start,
@@ -8721,7 +8723,6 @@ - (NSRect)accessibilityFrame @@ -8722,7 +8724,6 @@ - (NSRect)accessibilityFrame
@end @end
@@ -80,7 +80,7 @@ index d2a5a58..c796840 100644
/* =================================================================== /* ===================================================================
EmacsAccessibilityBuffer (Notifications) — AX event dispatch EmacsAccessibilityBuffer (Notifications) — AX event dispatch
@@ -9266,7 +9267,6 @@ - (NSRect)accessibilityFrame @@ -9267,7 +9268,6 @@ - (NSRect)accessibilityFrame
@end @end
@@ -88,7 +88,7 @@ index d2a5a58..c796840 100644
/* =================================================================== /* ===================================================================
EmacsAccessibilityInteractiveSpan — helpers and implementation EmacsAccessibilityInteractiveSpan — helpers and implementation
=================================================================== */ =================================================================== */
@@ -9596,6 +9596,7 @@ - (void)dealloc @@ -9597,6 +9597,7 @@ - (void)dealloc
[layer release]; [layer release];
#endif #endif
@@ -96,7 +96,7 @@ index d2a5a58..c796840 100644
[[self menu] release]; [[self menu] release];
[super dealloc]; [super dealloc];
} }
@@ -10944,6 +10945,32 @@ - (void)windowDidBecomeKey /* for direct calls */ @@ -10945,6 +10946,32 @@ - (void)windowDidBecomeKey /* for direct calls */
XSETFRAME (event.frame_or_window, emacsframe); XSETFRAME (event.frame_or_window, emacsframe);
kbd_buffer_store_event (&event); kbd_buffer_store_event (&event);
ns_send_appdefined (-1); // Kick main loop ns_send_appdefined (-1); // Kick main loop
@@ -129,7 +129,7 @@ index d2a5a58..c796840 100644
} }
@@ -12181,6 +12208,332 @@ - (int) fullscreenState @@ -12182,6 +12209,332 @@ - (int) fullscreenState
return fs_state; return fs_state;
} }

View File

@@ -1,4 +1,4 @@
From 472c446d629dc95c5c71560af5de3462943ff84a Mon Sep 17 00:00:00 2001 From 44cb6c8657feb1e17afabfb1a97d341727245bdd Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100 Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 7/9] doc: add VoiceOver accessibility section to macOS Subject: [PATCH 7/9] doc: add VoiceOver accessibility section to macOS

View File

@@ -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> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 14:46:25 +0100 Date: Sat, 28 Feb 2026 14:46:25 +0100
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver 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, assign) BOOL cachedMarkActive;
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement; @property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index c796840..f1aa0a4 100644 index 1577338..71b6d2e 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/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 ---- */ /* ---- Helper: extract buffer text for accessibility ---- */
@@ -220,7 +220,7 @@ index c796840..f1aa0a4 100644
static NSString * static NSString *
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start, ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
ns_ax_visible_run **out_runs, NSUInteger *out_nruns) 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 /* Extract this visible run's text. Use
Fbuffer_substring_no_properties which correctly handles the 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. */ include garbage bytes when the run spans the gap position. */
Lisp_Object lstr = Fbuffer_substring_no_properties ( Lisp_Object lstr = Fbuffer_substring_no_properties (
make_fixnum (pos), make_fixnum (run_end)); 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; return NSZeroRect;
/* charpos_start and charpos_len are already in buffer charpos /* charpos_start and charpos_len are already in buffer charpos
@@ -238,7 +238,7 @@ index c796840..f1aa0a4 100644
charposForAccessibilityIndex which handles invisible text. */ charposForAccessibilityIndex which handles invisible text. */
ptrdiff_t cp_start = charpos_start; ptrdiff_t cp_start = charpos_start;
ptrdiff_t cp_end = cp_start + charpos_len; ptrdiff_t cp_end = cp_start + charpos_len;
@@ -7843,6 +7986,7 @@ @implementation EmacsAccessibilityBuffer @@ -7844,6 +7987,7 @@ @implementation EmacsAccessibilityBuffer
@synthesize cachedOverlayModiff; @synthesize cachedOverlayModiff;
@synthesize cachedTextStart; @synthesize cachedTextStart;
@synthesize cachedModiff; @synthesize cachedModiff;
@@ -246,7 +246,7 @@ index c796840..f1aa0a4 100644
@synthesize cachedPoint; @synthesize cachedPoint;
@synthesize cachedMarkActive; @synthesize cachedMarkActive;
@synthesize cachedCompletionAnnouncement; @synthesize cachedCompletionAnnouncement;
@@ -7940,7 +8084,7 @@ - (void)ensureTextCache @@ -7941,7 +8085,7 @@ - (void)ensureTextCache
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache"); NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
/* This method is only called from the main thread (AX getters /* This method is only called from the main thread (AX getters
dispatch_sync to main first). Reads of cachedText/cachedTextModiff 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 write section at the end needs synchronization to protect
against concurrent reads from AX server thread. */ against concurrent reads from AX server thread. */
eassert ([NSThread isMainThread]); eassert ([NSThread isMainThread]);
@@ -7952,25 +8096,16 @@ - (void)ensureTextCache @@ -7953,25 +8097,16 @@ - (void)ensureTextCache
if (!b) if (!b)
return; return;
@@ -289,7 +289,7 @@ index c796840..f1aa0a4 100644
&& cachedTextStart == BUF_BEGV (b) && cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart && pt >= cachedTextStart
&& (textLen == 0 && (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 release];
cachedText = [text retain]; cachedText = [text retain];
@@ -298,7 +298,7 @@ index c796840..f1aa0a4 100644
cachedTextStart = start; cachedTextStart = start;
if (visibleRuns) 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 /* Binary search: runs are sorted by charpos (ascending). Find the
run whose [charpos, charpos+length) range contains the target, run whose [charpos, charpos+length) range contains the target,
or the nearest run after an invisible gap. O(log n) instead of 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; NSUInteger lo = 0, hi = visibleRunCount;
while (lo < hi) while (lo < hi)
{ {
@@ -8064,7 +8199,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos @@ -8065,7 +8200,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
else else
{ {
/* Found: charpos is inside this run. Compute UTF-16 delta /* 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); NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
if (chars_in == 0 || !cachedText) if (chars_in == 0 || !cachedText)
return r->ax_start; 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. /* Convert accessibility string index to buffer charpos.
Safe to call from any thread: uses only cachedText (NSString) and Safe to call from any thread: uses only cachedText (NSString) and
@@ -329,7 +329,7 @@ index c796840..f1aa0a4 100644
@synchronized (self) @synchronized (self)
{ {
if (visibleRunCount == 0) 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; return cp;
} }
} }
@@ -338,7 +338,7 @@ index c796840..f1aa0a4 100644
if (lo > 0) if (lo > 0)
{ {
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1]; 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: deadlocking the AX server thread. This is prevented by:
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every 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 2. All dispatch_sync blocks run on the main thread where no
concurrent Lisp code can modify state between checks. concurrent Lisp code can modify state between checks.
3. block_input prevents timer events and process output from 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]; return [self lineForAXIndex:point_idx];
} }
@@ -398,7 +398,7 @@ index c796840..f1aa0a4 100644
- (NSRange)accessibilityRangeForLine:(NSInteger)line - (NSRange)accessibilityRangeForLine:(NSInteger)line
{ {
if (![NSThread isMainThread]) 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. These methods notify VoiceOver of text and selection changes.
Called from the redisplay cycle (postAccessibilityUpdates). 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 if (point > self.cachedPoint
&& point - self.cachedPoint == 1) && point - self.cachedPoint == 1)
{ {
@@ -416,7 +416,7 @@ index c796840..f1aa0a4 100644
[self invalidateTextCache]; [self invalidateTextCache];
[self ensureTextCache]; [self ensureTextCache];
if (cachedText) 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 /* Update cachedPoint here so the selection-move branch does NOT
fire for point changes caused by edits. WebKit and Chromium fire for point changes caused by edits. WebKit and Chromium
never send both ValueChanged and SelectedTextChanged for the never send both ValueChanged and SelectedTextChanged for the
@@ -425,7 +425,7 @@ index c796840..f1aa0a4 100644
self.cachedPoint = point; self.cachedPoint = point;
NSDictionary *change = @{ 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)); BOOL markActive = !NILP (BVAR (b, mark_active));
/* --- Text changed (edit) --- */ /* --- Text changed (edit) --- */
@@ -513,7 +513,7 @@ index c796840..f1aa0a4 100644
{ {
ptrdiff_t oldPoint = self.cachedPoint; ptrdiff_t oldPoint = self.cachedPoint;
BOOL oldMarkActive = self.cachedMarkActive; 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. /* 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 (), ^{ dispatch_async (dispatch_get_main_queue (), ^{
/* lwin is a Lisp_Object captured by value. This is GC-safe /* lwin is a Lisp_Object captured by value. This is GC-safe
because Lisp_Objects are tagged integers/pointers that 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 Emacs. The WINDOW_LIVE_P check below guards against the
window being deleted between capture and execution. */ window being deleted between capture and execution. */
if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin))) 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 @end
@@ -540,7 +540,7 @@ index c796840..f1aa0a4 100644
Methods are kept here (same .m file) so they access the ivars Methods are kept here (same .m file) so they access the ivars
declared in the @interface ivar block. */ declared in the @interface ivar block. */
@implementation EmacsAccessibilityBuffer (InteractiveSpans) @implementation EmacsAccessibilityBuffer (InteractiveSpans)
@@ -12224,7 +12470,7 @@ - (int) fullscreenState @@ -12225,7 +12471,7 @@ - (int) fullscreenState
if (WINDOW_LEAF_P (w)) if (WINDOW_LEAF_P (w))
{ {
@@ -549,7 +549,7 @@ index c796840..f1aa0a4 100644
EmacsAccessibilityBuffer *elem EmacsAccessibilityBuffer *elem
= [existing objectForKey:[NSValue valueWithPointer:w]]; = [existing objectForKey:[NSValue valueWithPointer:w]];
if (!elem) if (!elem)
@@ -12258,7 +12504,7 @@ - (int) fullscreenState @@ -12259,7 +12505,7 @@ - (int) fullscreenState
} }
else else
{ {
@@ -558,7 +558,7 @@ index c796840..f1aa0a4 100644
Lisp_Object child = w->contents; Lisp_Object child = w->contents;
while (!NILP (child)) while (!NILP (child))
{ {
@@ -12370,7 +12616,7 @@ - (void)postAccessibilityUpdates @@ -12371,7 +12617,7 @@ - (void)postAccessibilityUpdates
accessibilityUpdating = YES; accessibilityUpdating = YES;
/* Detect window tree change (split, delete, new buffer). Compare /* Detect window tree change (split, delete, new buffer). Compare
@@ -567,7 +567,7 @@ index c796840..f1aa0a4 100644
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe); Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
if (!EQ (curRoot, lastRootWindow)) 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 /* If tree is stale, rebuild FIRST so we don't iterate freed

View File

@@ -1,4 +1,4 @@
From c38bfe9c3328a9355fe786fea0e6bddcf2bdd54f Mon Sep 17 00:00:00 2001 From 2466072f55f562d96d189814815bf8c4084338b5 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz> From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100 Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 9/9] ns: announce child frame completion candidates for Subject: [PATCH 9/9] ns: announce child frame completion candidates for
@@ -109,10 +109,10 @@ index 2102fb9..dd98d56 100644
@end @end
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index f1aa0a4..27607c0 100644 index 71b6d2e..fd7c520 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -7352,6 +7352,112 @@ visual line index for Zoom (skip whitespace-only lines @@ -7353,6 +7353,112 @@ visual line index for Zoom (skip whitespace-only lines
return nil; return nil;
} }
@@ -225,7 +225,7 @@ index f1aa0a4..27607c0 100644
/* Build accessibility text for window W, skipping invisible text. /* Build accessibility text for window W, skipping invisible text.
Populates *OUT_START with the buffer start charpos. Populates *OUT_START with the buffer start charpos.
Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS
@@ -8096,16 +8202,25 @@ - (void)ensureTextCache @@ -8097,16 +8203,25 @@ - (void)ensureTextCache
if (!b) if (!b)
return; return;
@@ -259,7 +259,7 @@ index f1aa0a4..27607c0 100644
&& cachedTextStart == BUF_BEGV (b) && cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart && pt >= cachedTextStart
&& (textLen == 0 && (textLen == 0
@@ -8121,7 +8236,7 @@ included in the cached AX text (it is handled separately via @@ -8122,7 +8237,7 @@ included in the cached AX text (it is handled separately via
{ {
[cachedText release]; [cachedText release];
cachedText = [text retain]; cachedText = [text retain];
@@ -268,7 +268,7 @@ index f1aa0a4..27607c0 100644
cachedTextStart = start; cachedTextStart = start;
if (visibleRuns) if (visibleRuns)
@@ -9089,6 +9204,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b @@ -9090,6 +9205,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0; ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0; ptrdiff_t currentOverlayEnd = 0;
@@ -276,7 +276,7 @@ index f1aa0a4..27607c0 100644
specpdl_ref count2 = SPECPDL_INDEX (); specpdl_ref count2 = SPECPDL_INDEX ();
record_unwind_current_buffer (); record_unwind_current_buffer ();
if (b != current_buffer) if (b != current_buffer)
@@ -9247,6 +9363,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b @@ -9248,6 +9364,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
self.cachedCompletionOverlayEnd = 0; self.cachedCompletionOverlayEnd = 0;
self.cachedCompletionPoint = 0; self.cachedCompletionPoint = 0;
} }
@@ -284,7 +284,7 @@ index f1aa0a4..27607c0 100644
} }
/* ---- Notification dispatch (main entry point) ---- */ /* ---- Notification dispatch (main entry point) ---- */
@@ -9843,6 +9960,10 @@ - (void)dealloc @@ -9844,6 +9961,10 @@ - (void)dealloc
#endif #endif
[accessibilityElements release]; [accessibilityElements release];
@@ -295,7 +295,7 @@ index f1aa0a4..27607c0 100644
[[self menu] release]; [[self menu] release];
[super dealloc]; [super dealloc];
} }
@@ -11292,6 +11413,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f @@ -11293,6 +11414,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO; windowClosing = NO;
processingCompose = NO; processingCompose = NO;
@@ -305,7 +305,7 @@ index f1aa0a4..27607c0 100644
scrollbarsNeedingUpdate = 0; scrollbarsNeedingUpdate = 0;
fs_state = FULLSCREEN_NONE; fs_state = FULLSCREEN_NONE;
fs_before_fs = next_maximized = -1; fs_before_fs = next_maximized = -1;
@@ -12600,6 +12724,80 @@ - (id)accessibilityFocusedUIElement @@ -12601,6 +12725,80 @@ - (id)accessibilityFocusedUIElement
The existing elements carry cached state (modiff, point) from the The existing elements carry cached state (modiff, point) from the
previous redisplay cycle. Rebuilding first would create fresh previous redisplay cycle. Rebuilding first would create fresh
elements with current values, making change detection impossible. */ elements with current values, making change detection impossible. */
@@ -386,7 +386,7 @@ index f1aa0a4..27607c0 100644
- (void)postAccessibilityUpdates - (void)postAccessibilityUpdates
{ {
NSTRACE ("[EmacsView postAccessibilityUpdates]"); NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12610,11 +12808,59 @@ - (void)postAccessibilityUpdates @@ -12611,11 +12809,59 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting /* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us can trigger redisplay, which calls ns_update_end, which calls us