patches: 0008 - setAccessibilityElement:NO (suppress window announcement)

This commit is contained in:
2026-02-28 16:34:41 +01:00
parent 2dc4182856
commit 5a58e3b925

View File

@@ -1,4 +1,4 @@
From a06955c951aaad2330add250f815c34d60128948 Mon Sep 17 00:00:00 2001
From ee7441e38dc428f86c36045648bac2c487768f48 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
@@ -31,14 +31,15 @@ Safety measures:
- Buffer size limit (10000 chars) skips non-completion child frames
such as eldoc documentation or which-key popups.
Suppress VoiceOver's automatic "X window" announcement by setting
the child frame's accessibility subrole to FloatingWindow (popovers
and floating windows don't trigger window-appeared announcements).
Remove the child frame window from the accessibility tree via
setAccessibilityElement:NO to prevent VoiceOver's blocking
"X window" announcement. Our candidate announcements go to NSApp
(not the window element) and are unaffected.
Zoom tracking stores the candidate rect in the PARENT frame's
overlayZoomRect (via screen coordinate conversion), so that the
parent's draw_window_cursor focuses Zoom on the candidate instead
of the text cursor. Cleared when no candidate is found.
overlayZoomRect (via child view -> screen -> parent view coordinate
conversion), so that the parent's draw_window_cursor focuses Zoom
on the candidate instead of the text cursor.
* src/nsterm.h (EmacsView): Add announceChildFrameCompletion.
* src/nsterm.m (ns_ax_selected_child_frame_text): New function.
@@ -63,7 +64,7 @@ index 5c15639..21b2823 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index d13c5c7..ea2a914 100644
index d13c5c7..3735f01 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7066,6 +7066,110 @@ ns_ax_selected_overlay_text (struct buffer *b,
@@ -245,10 +246,10 @@ index d13c5c7..ea2a914 100644
+ lastCandidate = xstrdup (cstr);
+
+ /* Suppress VoiceOver's automatic "X window" announcement for
+ the child frame. Completion popups are semantically popovers,
+ not windows. Setting the subrole once is idempotent. */
+ [[self window]
+ setAccessibilitySubrole:NSAccessibilityFloatingWindowSubrole];
+ the child frame by removing it from the accessibility tree.
+ Our candidate announcement goes to NSApp (not this window),
+ so it still reaches VoiceOver. Idempotent. */
+ [[self window] setAccessibilityElement:NO];
+
+ NSDictionary *annInfo = @{
+ NSAccessibilityAnnouncementKey: candidate,