patches: 0008 restored to confirmed working version (3e5fe81)

Pure version: direct UAZoomChangeFocus, specpdl_ref, re-entrance
guard, buffer switch + unbind_to. No window announcement suppression
(all attempts broke VoiceOver focus tracking or Zoom).
This commit is contained in:
2026-02-28 17:08:49 +01:00
parent e09b8c61f0
commit afa65a8201

View File

@@ -1,4 +1,4 @@
From 80da4658204a10b8df5305743806aa26eef10478 Mon Sep 17 00:00:00 2001
From e11d0688f119046827cd1895008d3a93e22f6d0d Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 2/2] ns: announce child frame completion candidates for
@@ -16,20 +16,25 @@ find the selected candidate. Reuse ns_ax_face_is_selected from
the overlay patch to identify "current", "selected", and
"selection" faces.
Safety:
- record_unwind_current_buffer / set_buffer_internal_1 to switch to
the child frame buffer for Fbuffer_substring_no_properties.
- Re-entrance guard (accessibilityUpdating) before child frame dispatch.
- BUF_MODIFF gating prevents redundant scans.
- WINDOWP, BUFFERP validation for partially initialized frames.
- Buffer size limit (10000 chars) skips non-completion child frames.
Clear the child frame window title to minimize VoiceOver's automatic
window-appeared announcement.
Safety measures:
- Use record_unwind_current_buffer / set_buffer_internal_1 to
temporarily switch to the child frame buffer before calling
Fbuffer_substring_no_properties (which operates on current_buffer).
All return paths call unbind_to to restore the original buffer.
- The re-entrance guard (accessibilityUpdating) MUST come before the
child frame dispatch, because Lisp calls in the scan function can
trigger redisplay.
- BUF_MODIFF gating prevents redundant scans on every redisplay tick
and provides a secondary re-entrance guard.
- Frame state validation (WINDOWP, BUFFERP) handles partially
initialized child frames during creation.
- Buffer size limit (10000 chars) skips non-completion child frames
such as eldoc documentation or which-key popups.
Announce via AnnouncementRequested to NSApp with High priority.
Use direct UAZoomChangeFocus because the child frame renders
independently --- its ns_update_end runs after the parent's
Use direct UAZoomChangeFocus (not the overlayZoomRect flag used
for minibuffer overlay completion) because the child frame renders
independently --- its ns_update_end runs after the parent frame's
draw_window_cursor, so the last Zoom call wins.
* src/nsterm.h (EmacsView): Add announceChildFrameCompletion.
@@ -39,8 +44,8 @@ draw_window_cursor, so the last Zoom call wins.
handler for FRAME_PARENT_FRAME frames, under re-entrance guard.
---
src/nsterm.h | 1 +
src/nsterm.m | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 211 insertions(+), 1 deletion(-)
src/nsterm.m | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 205 insertions(+), 1 deletion(-)
diff --git a/src/nsterm.h b/src/nsterm.h
index 5c15639..21b2823 100644
@@ -55,7 +60,7 @@ index 5c15639..21b2823 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index d13c5c7..1c94c20 100644
index d13c5c7..092bc11 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7066,6 +7066,110 @@ ns_ax_selected_overlay_text (struct buffer *b,
@@ -263,7 +268,7 @@ index d13c5c7..1c94c20 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12309,11 +12500,29 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
@@ -12309,11 +12500,23 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us
@@ -277,15 +282,9 @@ index d13c5c7..1c94c20 100644
+ /* Child frame completion popup (Corfu, Company-box, etc.).
+ Child frames don't participate in the accessibility tree;
+ announce the selected candidate directly.
+
+ Clear the window title to minimize VoiceOver's automatic
+ window-appeared announcement (says "window" instead of the
+ full frame name). The element stays in the accessibility
+ tree so focus tracking and Zoom continue to work. */
+ announce the selected candidate directly. */
+ if (FRAME_PARENT_FRAME (emacsframe))
+ {
+ [[self window] setTitle:@""];
+ [self announceChildFrameCompletion];
+ accessibilityUpdating = NO;
+ return;