patches: review pass 3 - move block_input to origin patches

block_input protection moved from P0008 to their respective origin
patches for independent compilability (GNU Emacs requirement):
- P0001 (ns_ax_buffer_text): now has block_input + record_unwind
- P0003 (postCompletionAnnouncementForBuffer): now has block_input
- P0004 (ns_ax_scan_interactive_spans): now has block_input

P0008 now only adds its own new functionality (child frame completion
announcements, echo area announcements) without duplicating block_input
from earlier patches.

All 9 patches apply cleanly with git am on Linux git 2.43.0.
This commit is contained in:
2026-03-02 18:55:33 +01:00
parent 6176087cfb
commit 6fd28e19a8
9 changed files with 97 additions and 105 deletions

View File

@@ -1,7 +1,7 @@
From 3daf00725fe434bfe5e820fd69e390697e9e6373 Mon Sep 17 00:00:00 2001
From a442640322cfb64956e28cc01442c75815718bb9 Mon Sep 17 00:00:00 2001
From: Daneel <daneel@sukany.cz>
Date: Mon, 2 Mar 2026 18:49:13 +0100
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
Subject: [PATCH 8/8] ns: announce child frame completion candidates for
VoiceOver
Child frame popups (Corfu, Company-mode child frames) render completion
@@ -33,8 +33,8 @@ area announcements.
doc/emacs/macos.texi | 14 +-
etc/NEWS | 18 +-
src/nsterm.h | 20 ++
src/nsterm.m | 537 +++++++++++++++++++++++++++++++++++++++----
4 files changed, 538 insertions(+), 51 deletions(-)
src/nsterm.m | 529 +++++++++++++++++++++++++++++++++++++++----
4 files changed, 530 insertions(+), 51 deletions(-)
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index 8d4a7825d8..03a657f970 100644
@@ -149,7 +149,7 @@ index 21a93bc799..bdd40b8eb7 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index 5e6ab11295..6e0575677e 100644
index 7fa28222b6..6e0575677e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1126,24 +1126,19 @@ Uses CFAbsoluteTimeGetCurrent() (~5 ns, a VDSO read) for timing. */
@@ -313,16 +313,7 @@ index 5e6ab11295..6e0575677e 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
@@ -7441,6 +7548,8 @@ visual line index for Zoom (skip whitespace-only lines
specpdl_ref count = SPECPDL_INDEX ();
record_unwind_current_buffer ();
+ record_unwind_protect_void (unblock_input);
+ block_input ();
if (b != current_buffer)
set_buffer_internal_1 (b);
@@ -8147,16 +8256,32 @@ - (void)ensureTextCache
@@ -8149,16 +8256,32 @@ - (void)ensureTextCache
if (!b)
return;
@@ -363,7 +354,7 @@ index 5e6ab11295..6e0575677e 100644
&& cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart
&& (textLen == 0
@@ -8172,7 +8297,7 @@ included in the cached AX text (it is handled separately via
@@ -8174,7 +8297,7 @@ included in the cached AX text (it is handled separately via
{
[cachedText release];
cachedText = [text retain];
@@ -372,7 +363,7 @@ index 5e6ab11295..6e0575677e 100644
cachedTextStart = start;
if (visibleRuns)
@@ -8585,6 +8710,11 @@ - (void)setAccessibilitySelectedTextRange:(NSRange)range
@@ -8587,6 +8710,11 @@ - (void)setAccessibilitySelectedTextRange:(NSRange)range
[self ensureTextCache];
@@ -384,7 +375,7 @@ index 5e6ab11295..6e0575677e 100644
specpdl_ref count = SPECPDL_INDEX ();
record_unwind_current_buffer ();
/* Ensure block_input is always matched by unblock_input even if
@@ -9040,15 +9170,23 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point
@@ -9042,15 +9170,23 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point
= @(ns_ax_text_state_change_selection_move);
moveInfo[@"AXTextSelectionDirection"] = @(direction);
moveInfo[@"AXTextChangeElement"] = self;
@@ -414,7 +405,7 @@ index 5e6ab11295..6e0575677e 100644
NSAccessibilitySelectedTextChangedNotification,
moveInfo);
@@ -9146,12 +9284,17 @@ user expectation ("w" jumps to next word and reads it). */
@@ -9148,12 +9284,17 @@ user expectation ("w" jumps to next word and reads it). */
}
}
@@ -437,22 +428,19 @@ index 5e6ab11295..6e0575677e 100644
if (cachedText
&& granularity == ns_ax_text_selection_granularity_line)
{
@@ -9214,7 +9357,14 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0;
@@ -9218,6 +9359,11 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
+ block_input ();
block_input ();
specpdl_ref count2 = SPECPDL_INDEX ();
+ /* Register unblock_input as an unwind action so that if any Lisp
+ call below signals (triggering a longjmp through unbind_to),
+ block_input is always paired with an unblock_input. The
+ unbind_to call at the end of the function unwinds this.
+ record_unwind_protect_void plus unbind_to is idempotent. */
+ record_unwind_protect_void (unblock_input);
record_unwind_protect_void (unblock_input);
record_unwind_current_buffer ();
if (b != current_buffer)
set_buffer_internal_1 (b);
@@ -9390,12 +9540,29 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
@@ -9394,12 +9540,29 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
if (!b)
return;
@@ -482,7 +470,7 @@ index 5e6ab11295..6e0575677e 100644
if (modiff != self.cachedModiff)
{
self.cachedModiff = modiff;
@@ -9409,6 +9576,7 @@ Text property changes (e.g. face updates from
@@ -9413,6 +9576,7 @@ Text property changes (e.g. face updates from
{
self.cachedCharsModiff = chars_modiff;
[self postTextChangedNotification:point];
@@ -490,7 +478,7 @@ index 5e6ab11295..6e0575677e 100644
}
}
@@ -9431,8 +9599,15 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
@@ -9435,8 +9599,15 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
displayed in the minibuffer. In normal editing buffers,
font-lock and other modes change BUF_OVERLAY_MODIFF on
every redisplay, triggering O(overlays) work per keystroke.
@@ -508,7 +496,7 @@ index 5e6ab11295..6e0575677e 100644
goto skip_overlay_scan;
int selected_line = -1;
@@ -9478,7 +9653,18 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
@@ -9482,7 +9653,18 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
self.cachedPoint = point;
self.cachedMarkActive = markActive;
@@ -528,7 +516,7 @@ index 5e6ab11295..6e0575677e 100644
NSInteger direction = ns_ax_text_selection_direction_discontiguous;
if (point > oldPoint)
direction = ns_ax_text_selection_direction_next;
@@ -9526,6 +9712,58 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
@@ -9530,6 +9712,58 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
granularity = ns_ax_text_selection_granularity_line;
}
@@ -587,7 +575,7 @@ index 5e6ab11295..6e0575677e 100644
/* Post notifications for focused and non-focused elements. */
if ([self isAccessibilityFocused])
[self postFocusedCursorNotification:point
@@ -9668,6 +9906,17 @@ - (NSRect)accessibilityFrame
@@ -9672,6 +9906,13 @@ - (NSRect)accessibilityFrame
if (vis_start >= vis_end)
return @[];
@@ -598,14 +586,10 @@ index 5e6ab11295..6e0575677e 100644
+ that could modify buffer state (e.g. invalidate vis_end).
+ record_unwind_protect_void guarantees unblock_input even if
+ a Lisp call signals. */
+ block_input ();
+ specpdl_ref blk_count = SPECPDL_INDEX ();
+ record_unwind_protect_void (unblock_input);
+
/* Symbols are interned once at startup via DEFSYM in syms_of_nsterm;
reference them directly here (GC-safe, no repeated obarray lookup). */
@@ -9788,6 +10037,7 @@ than O(chars). Fall back to pos+1 as safety net. */
block_input ();
specpdl_ref blk_count = SPECPDL_INDEX ();
record_unwind_protect_void (unblock_input);
@@ -9796,6 +10037,7 @@ than O(chars). Fall back to pos+1 as safety net. */
pos = span_end;
}
@@ -613,7 +597,7 @@ index 5e6ab11295..6e0575677e 100644
return [[spans copy] autorelease];
}
@@ -9969,6 +10219,10 @@ - (void)dealloc
@@ -9977,6 +10219,10 @@ - (void)dealloc
#endif
[accessibilityElements release];
@@ -624,7 +608,7 @@ index 5e6ab11295..6e0575677e 100644
[[self menu] release];
[super dealloc];
}
@@ -11418,6 +11672,10 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
@@ -11426,6 +11672,10 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO;
processingCompose = NO;
@@ -635,7 +619,7 @@ index 5e6ab11295..6e0575677e 100644
scrollbarsNeedingUpdate = 0;
fs_state = FULLSCREEN_NONE;
fs_before_fs = next_maximized = -1;
@@ -12726,6 +12984,154 @@ - (id)accessibilityFocusedUIElement
@@ -12734,6 +12984,154 @@ - (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. */
@@ -790,7 +774,7 @@ index 5e6ab11295..6e0575677e 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12736,11 +13142,64 @@ - (void)postAccessibilityUpdates
@@ -12744,11 +13142,64 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us