patches: announce echo area messages to VoiceOver

This commit is contained in:
2026-03-01 14:25:20 +01:00
parent 0d4d874607
commit bcb25088dd

View File

@@ -1,4 +1,4 @@
From 8d60434dd8fba2ca5f2bb25b2cc55fa046fbd1fb Mon Sep 17 00:00:00 2001 From d3955e2fa0cd7e39d5100edf5818608b3be53f20 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 8/8] ns: announce child frame completion candidates for 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 - doc/emacs/macos.texi | 6 -
etc/NEWS | 4 +- etc/NEWS | 4 +-
src/nsterm.h | 9 ++ src/nsterm.h | 9 ++
src/nsterm.m | 290 +++++++++++++++++++++++++++++++++++++++++-- src/nsterm.m | 329 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 291 insertions(+), 18 deletions(-) 4 files changed, 330 insertions(+), 18 deletions(-)
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index 6514dfc..f47929e 100644 index 6514dfc..f47929e 100644
@@ -97,7 +97,7 @@ index 21a93bc..bbce9fe 100644
@end @end
diff --git a/src/nsterm.m b/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m
index 8d44b5f..818e0a0 100644 index 8d44b5f..7b254ca 100644
--- a/src/nsterm.m --- a/src/nsterm.m
+++ b/src/nsterm.m +++ b/src/nsterm.m
@@ -7415,6 +7415,112 @@ visual line index for Zoom (skip whitespace-only lines @@ -7415,6 +7415,112 @@ visual line index for Zoom (skip whitespace-only lines
@@ -303,7 +303,53 @@ index 8d44b5f..818e0a0 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)
@@ -9931,6 +10072,10 @@ - (void)dealloc @@ -9352,6 +9493,45 @@ - (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 text changes, post an AX announcement so VoiceOver reads the
+ new message. This covers error messages, warnings, and informational
+ echoes. Skipped while minibuf_level > 0 (user is typing a command)
+ to avoid interrupting prompt reading or completion. */
+ if (MINI_WINDOW_P (w) && minibuf_level == 0)
+ {
+ ptrdiff_t echo_chars_modiff = BUF_CHARS_MODIFF (b);
+ if (echo_chars_modiff != self.cachedCharsModiff)
+ {
+ self.cachedCharsModiff = echo_chars_modiff;
+ ptrdiff_t dummy_start = 0;
+ NSUInteger nruns = 0;
+ ns_ax_visible_run *runs = NULL;
+ NSString *msg = ns_ax_buffer_text (w, &dummy_start,
+ &runs, &nruns);
+ if (runs) xfree (runs);
+ if (msg)
+ {
+ NSString *trimmed = [msg stringByTrimmingCharactersInSet:
+ [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ if ([trimmed length] > 0)
+ {
+ NSDictionary *info = @{
+ NSAccessibilityAnnouncementKey: trimmed,
+ NSAccessibilityPriorityKey:
+ @(NSAccessibilityPriorityMedium)
+ };
+ ns_ax_post_notification_with_info (
+ NSApp,
+ NSAccessibilityAnnouncementRequestedNotification,
+ info);
+ }
+ }
+ }
+ return; /* no cursor tracking for inactive minibuffer */
+ }
+
ptrdiff_t modiff = BUF_MODIFF (b);
ptrdiff_t point = BUF_PT (b);
BOOL markActive = !NILP (BVAR (b, mark_active));
@@ -9931,6 +10111,10 @@ - (void)dealloc
#endif #endif
[accessibilityElements release]; [accessibilityElements release];
@@ -314,7 +360,7 @@ index 8d44b5f..818e0a0 100644
[[self menu] release]; [[self menu] release];
[super dealloc]; [super dealloc];
} }
@@ -11380,6 +11525,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f @@ -11380,6 +11564,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO; windowClosing = NO;
processingCompose = NO; processingCompose = NO;
@@ -324,7 +370,7 @@ index 8d44b5f..818e0a0 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;
@@ -12688,6 +12836,80 @@ - (id)accessibilityFocusedUIElement @@ -12688,6 +12875,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. */
@@ -405,7 +451,7 @@ index 8d44b5f..818e0a0 100644
- (void)postAccessibilityUpdates - (void)postAccessibilityUpdates
{ {
NSTRACE ("[EmacsView postAccessibilityUpdates]"); NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12698,11 +12920,59 @@ - (void)postAccessibilityUpdates @@ -12698,11 +12959,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