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 1c8bbd32afe8d5686c8c875feb399a20ea656d72 Mon Sep 17 00:00:00 2001
From 92aec64d791200f54fcd756b5a07581a6c15d0cb Mon Sep 17 00:00:00 2001
From: Daneel <daneel@sukany.cz>
Date: Mon, 2 Mar 2026 18:39:46 +0100
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver
Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver
Completion frameworks such as Vertico, Ivy, and Icomplete render
candidates via overlay before-string/after-string properties. Without
@@ -34,7 +34,7 @@ index 5746e9e9bd..21a93bc799 100644
@property (nonatomic, assign) BOOL cachedMarkActive;
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
diff --git a/src/nsterm.m b/src/nsterm.m
index 062066d4e5..5e6ab11295 100644
index 8a1bfd9eb1..7fa28222b6 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7263,11 +7263,154 @@ Accessibility virtual elements (macOS / Cocoa only)
@@ -193,7 +193,7 @@ index 062066d4e5..5e6ab11295 100644
static NSString *
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
@@ -7338,7 +7481,7 @@ Accessibility virtual elements (macOS / Cocoa only)
@@ -7340,7 +7483,7 @@ Accessibility virtual elements (macOS / Cocoa only)
/* Extract this visible run's text. Use
Fbuffer_substring_no_properties which correctly handles the
@@ -202,7 +202,7 @@ index 062066d4e5..5e6ab11295 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));
@@ -7419,7 +7562,7 @@ Mode lines using icon fonts (e.g. nerd-font icons)
@@ -7421,7 +7564,7 @@ Mode lines using icon fonts (e.g. nerd-font icons)
return NSZeroRect;
/* charpos_start and charpos_len are already in buffer charpos
@@ -211,7 +211,7 @@ index 062066d4e5..5e6ab11295 100644
charposForAccessibilityIndex which handles invisible text. */
ptrdiff_t cp_start = charpos_start;
ptrdiff_t cp_end = cp_start + charpos_len;
@@ -7894,6 +8037,7 @@ @implementation EmacsAccessibilityBuffer
@@ -7896,6 +8039,7 @@ @implementation EmacsAccessibilityBuffer
@synthesize cachedOverlayModiff;
@synthesize cachedTextStart;
@synthesize cachedModiff;
@@ -219,7 +219,7 @@ index 062066d4e5..5e6ab11295 100644
@synthesize cachedPoint;
@synthesize cachedMarkActive;
@synthesize cachedCompletionAnnouncement;
@@ -7991,7 +8135,7 @@ - (void)ensureTextCache
@@ -7993,7 +8137,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
@@ -228,7 +228,7 @@ index 062066d4e5..5e6ab11295 100644
write section at the end needs synchronization to protect
against concurrent reads from AX server thread. */
eassert ([NSThread isMainThread]);
@@ -8003,25 +8147,16 @@ - (void)ensureTextCache
@@ -8005,25 +8149,16 @@ - (void)ensureTextCache
if (!b)
return;
@@ -262,7 +262,7 @@ index 062066d4e5..5e6ab11295 100644
&& cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart
&& (textLen == 0
@@ -8037,7 +8172,7 @@ included in the cached AX text (it is handled separately via
@@ -8039,7 +8174,7 @@ included in the cached AX text (it is handled separately via
{
[cachedText release];
cachedText = [text retain];
@@ -271,7 +271,7 @@ index 062066d4e5..5e6ab11295 100644
cachedTextStart = start;
if (visibleRuns)
@@ -8106,7 +8241,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
@@ -8108,7 +8243,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
@@ -280,7 +280,7 @@ index 062066d4e5..5e6ab11295 100644
NSUInteger lo = 0, hi = visibleRunCount;
while (lo < hi)
{
@@ -8155,10 +8290,10 @@ by run length (visible window), not total buffer size. */
@@ -8157,10 +8292,10 @@ by run length (visible window), not total buffer size. */
/* Convert accessibility string index to buffer charpos.
Safe to call from any thread: uses only cachedText (NSString) and
@@ -293,7 +293,7 @@ index 062066d4e5..5e6ab11295 100644
@synchronized (self)
{
if (visibleRunCount == 0)
@@ -8200,7 +8335,7 @@ the slow path (composed character sequence walk), which is
@@ -8202,7 +8337,7 @@ the slow path (composed character sequence walk), which is
return cp;
}
}
@@ -302,7 +302,7 @@ index 062066d4e5..5e6ab11295 100644
if (lo > 0)
{
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
@@ -8222,7 +8357,7 @@ the slow path (composed character sequence walk), which is
@@ -8224,7 +8359,7 @@ the slow path (composed character sequence walk), which is
deadlocking the AX server thread. This is prevented by:
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
@@ -311,7 +311,7 @@ index 062066d4e5..5e6ab11295 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
@@ -8568,6 +8703,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
@@ -8570,6 +8705,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
return [self lineForAXIndex:point_idx];
}
@@ -362,7 +362,7 @@ index 062066d4e5..5e6ab11295 100644
- (NSRange)accessibilityRangeForLine:(NSInteger)line
{
if (![NSThread isMainThread])
@@ -8790,7 +8969,7 @@ - (NSRect)accessibilityFrame
@@ -8792,7 +8971,7 @@ - (NSRect)accessibilityFrame
/* ===================================================================
@@ -371,7 +371,7 @@ index 062066d4e5..5e6ab11295 100644
These methods notify VoiceOver of text and selection changes.
Called from the redisplay cycle (postAccessibilityUpdates).
@@ -8805,7 +8984,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
@@ -8807,7 +8986,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
if (point > self.cachedPoint
&& point - self.cachedPoint == 1)
{
@@ -380,7 +380,7 @@ index 062066d4e5..5e6ab11295 100644
[self invalidateTextCache];
[self ensureTextCache];
if (cachedText)
@@ -8824,7 +9003,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
@@ -8826,7 +9005,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
@@ -389,7 +389,7 @@ index 062066d4e5..5e6ab11295 100644
self.cachedPoint = point;
NSDictionary *change = @{
@@ -9216,16 +9395,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
@@ -9220,16 +9399,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
BOOL markActive = !NILP (BVAR (b, mark_active));
/* --- Text changed (edit) --- */
@@ -477,7 +477,7 @@ index 062066d4e5..5e6ab11295 100644
{
ptrdiff_t oldPoint = self.cachedPoint;
BOOL oldMarkActive = self.cachedMarkActive;
@@ -12350,7 +12596,7 @@ - (int) fullscreenState
@@ -12358,7 +12604,7 @@ - (int) fullscreenState
if (WINDOW_LEAF_P (w))
{
@@ -486,7 +486,7 @@ index 062066d4e5..5e6ab11295 100644
EmacsAccessibilityBuffer *elem
= [existing objectForKey:[NSValue valueWithPointer:w]];
if (!elem)
@@ -12384,7 +12630,7 @@ - (int) fullscreenState
@@ -12392,7 +12638,7 @@ - (int) fullscreenState
}
else
{
@@ -495,7 +495,7 @@ index 062066d4e5..5e6ab11295 100644
Lisp_Object child = w->contents;
while (!NILP (child))
{
@@ -12496,7 +12742,7 @@ - (void)postAccessibilityUpdates
@@ -12504,7 +12750,7 @@ - (void)postAccessibilityUpdates
accessibilityUpdating = YES;
/* Detect window tree change (split, delete, new buffer). Compare
@@ -504,7 +504,7 @@ index 062066d4e5..5e6ab11295 100644
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
if (!EQ (curRoot, lastRootWindow))
{
@@ -12505,12 +12751,12 @@ - (void)postAccessibilityUpdates
@@ -12513,12 +12759,12 @@ - (void)postAccessibilityUpdates
}
/* If tree is stale, rebuild FIRST so we don't iterate freed