patches: fix VoiceOver cursor sync + echo area (base f8d9ecb restored)

This commit is contained in:
2026-03-01 14:51:58 +01:00
parent 7ddebc2579
commit b7d0188cbb
9 changed files with 43 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
From 0fc45d4df14bdc39d6c005cc2c02c745fd59ea22 Mon Sep 17 00:00:00 2001
From a238db02b1d26210a61106c804c8dd012e93fc52 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 8/8] ns: announce child frame completion candidates for
@@ -20,8 +20,8 @@ element when a child frame completion closes.
doc/emacs/macos.texi | 6 -
etc/NEWS | 4 +-
src/nsterm.h | 9 ++
src/nsterm.m | 337 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 333 insertions(+), 23 deletions(-)
src/nsterm.m | 338 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 334 insertions(+), 23 deletions(-)
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index 6514dfc..f47929e 100644
@@ -48,7 +48,7 @@ index 6514dfc..f47929e 100644
To disable the accessibility interface entirely (for instance, to
eliminate overhead on systems where assistive technology is not in
diff --git a/etc/NEWS b/etc/NEWS
index a4a525f..d26c926 100644
index 2b1f9e6..8a40850 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -4404,8 +4404,8 @@ send user data to Apple's speech recognition servers.
@@ -97,7 +97,7 @@ index 21a93bc..bbce9fe 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index 8d44b5f..251a03e 100644
index 8d44b5f..e05608f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7415,6 +7415,112 @@ visual line index for Zoom (skip whitespace-only lines
@@ -274,7 +274,7 @@ index 8d44b5f..251a03e 100644
cachedTextStart = start;
if (visibleRuns)
@@ -9060,11 +9186,14 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point
@@ -9060,11 +9186,13 @@ - (void)postFocusedCursorNotification:(ptrdiff_t)point
= @(ns_ax_text_state_change_selection_move);
moveInfo[@"AXTextSelectionDirection"] = @(direction);
moveInfo[@"AXTextChangeElement"] = self;
@@ -283,26 +283,17 @@ index 8d44b5f..251a03e 100644
- for evil block-cursor mode). Include it for word/line/
- selection so VoiceOver reads the appropriate text. */
- if (!isCharMove)
+ /* Include granularity for sequential moves so VoiceOver reads
+ the appropriate unit of text. Omit for character moves (we
+ announce the character explicitly below) and for discontiguous
+ jumps (the destination line is announced explicitly; omitting
+ granularity lets VoiceOver use default behaviour and re-anchor
+ its browse cursor to accessibilitySelectedTextRange). */
+ /* Include granularity for sequential moves so VoiceOver reads the
+ appropriate unit. Omit for character moves (announced explicitly
+ below) and for discontiguous jumps (destination line announced
+ explicitly; omitting granularity lets VoiceOver use its default
+ behaviour and re-anchor its browse cursor). */
+ if (!isCharMove
+ && direction != ns_ax_text_selection_direction_discontiguous)
moveInfo[@"AXTextSelectionGranularity"] = @(granularity);
ns_ax_post_notification_with_info (
@@ -9072,6 +9201,7 @@ derive its own speech (it would read the wrong character
NSAccessibilitySelectedTextChangedNotification,
moveInfo);
+
/* For character moves: explicit announcement of char AT point.
This is the ONLY speech source for character navigation.
Correct for evil block-cursor (cursor ON the character)
@@ -9175,6 +9305,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
@@ -9175,6 +9303,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0;
@@ -310,18 +301,20 @@ index 8d44b5f..251a03e 100644
specpdl_ref count2 = SPECPDL_INDEX ();
record_unwind_current_buffer ();
if (b != current_buffer)
@@ -9352,6 +9483,44 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
@@ -9352,6 +9481,46 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
if (!b)
return;
+ /* --- Echo area announcements ---
+ When the minibuffer is not active for user input (minibuf_level == 0)
+ and its character content changes, announce the new text to VoiceOver.
+ This surfaces error messages, informational echoes, and git/process
+ status updates. We skip the rest of the notification cycle (cursor
+ tracking etc.) because an inactive minibuffer has no meaningful cursor.
+ When minibuf_level > 0 the user is composing a command; fall through
+ to normal processing so prompt and completion announcements work. */
+ and its character content changes, announce the new message to
+ VoiceOver. This surfaces error messages, completion notices, and
+ process status updates (e.g. "Wrote file", "Git finished").
+
+ Priority High interrupts ongoing speech, which matches the urgency
+ of a status change. While minibuf_level > 0 the user is composing
+ a command; we fall through to normal cursor and completion tracking
+ in that case. */
+ if (MINI_WINDOW_P (w) && minibuf_level == 0)
+ {
+ ptrdiff_t echo_chars = BUF_CHARS_MODIFF (b);
@@ -355,23 +348,24 @@ index 8d44b5f..251a03e 100644
ptrdiff_t modiff = BUF_MODIFF (b);
ptrdiff_t point = BUF_PT (b);
BOOL markActive = !NILP (BVAR (b, mark_active));
@@ -9488,6 +9657,15 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
@@ -9488,6 +9657,16 @@ frameworks like Vertico bump BOTH BUF_MODIFF (via text property
granularity = ns_ax_text_selection_granularity_line;
}
+ /* Non-sequential jumps that cross a line boundary (e.g. ]], [[,
+ M-<, xref, imenu) are discontiguous: the cursor moved to an
+ arbitrary location, not one sequential step. Reporting direction
+ discontiguous causes VoiceOver to re-anchor its rotor browse
+ cursor to the new accessibilitySelectedTextRange instead of
+ advancing linearly from its previous position. */
+ /* Programmatic jumps that cross a line boundary (]], [[, M-<,
+ xref, imenu, …) are discontiguous: the cursor teleported to an
+ arbitrary position, not one sequential step forward/backward.
+ Reporting AXTextSelectionDirectionDiscontiguous causes VoiceOver
+ to re-anchor its rotor browse cursor at the new
+ accessibilitySelectedTextRange rather than advancing linearly
+ from its previous internal position. */
+ if (!isCtrlNP && granularity == ns_ax_text_selection_granularity_line)
+ direction = ns_ax_text_selection_direction_discontiguous;
+
/* Post notifications for focused and non-focused elements. */
if ([self isAccessibilityFocused])
[self postFocusedCursorNotification:point
@@ -9931,6 +10109,10 @@ - (void)dealloc
@@ -9931,6 +10110,10 @@ - (void)dealloc
#endif
[accessibilityElements release];
@@ -382,7 +376,7 @@ index 8d44b5f..251a03e 100644
[[self menu] release];
[super dealloc];
}
@@ -11380,6 +11562,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
@@ -11380,6 +11563,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO;
processingCompose = NO;
@@ -392,7 +386,7 @@ index 8d44b5f..251a03e 100644
scrollbarsNeedingUpdate = 0;
fs_state = FULLSCREEN_NONE;
fs_before_fs = next_maximized = -1;
@@ -12688,6 +12873,80 @@ - (id)accessibilityFocusedUIElement
@@ -12688,6 +12874,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. */
@@ -473,7 +467,7 @@ index 8d44b5f..251a03e 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12698,11 +12957,59 @@ - (void)postAccessibilityUpdates
@@ -12698,11 +12958,59 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us