patches: 0008 - GroupRole + focus restore + overlayZoom reset
- NSAccessibilityGroupRole (no window announcement, focus tracking OK) - FocusedUIElementChanged on parent when corfu closes - overlayZoomActive = NO reset each parent cycle (handles C-g + frame delete)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
From ee7441e38dc428f86c36045648bac2c487768f48 Mon Sep 17 00:00:00 2001
|
From 95ae88dbcddc8d1af54777bcf95bb9c545383445 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 2/2] ns: announce child frame completion candidates for
|
Subject: [PATCH 2/2] ns: announce child frame completion candidates for
|
||||||
@@ -16,25 +16,25 @@ find the selected candidate. Reuse ns_ax_face_is_selected from
|
|||||||
the overlay patch to identify "current", "selected", and
|
the overlay patch to identify "current", "selected", and
|
||||||
"selection" faces.
|
"selection" faces.
|
||||||
|
|
||||||
Safety measures:
|
Safety:
|
||||||
- Use record_unwind_current_buffer / set_buffer_internal_1 to
|
- record_unwind_current_buffer / set_buffer_internal_1 to switch to
|
||||||
temporarily switch to the child frame buffer before calling
|
the child frame buffer for Fbuffer_substring_no_properties.
|
||||||
Fbuffer_substring_no_properties (which operates on current_buffer).
|
- Re-entrance guard (accessibilityUpdating) before child frame dispatch.
|
||||||
All return paths call unbind_to to restore the original buffer.
|
- BUF_MODIFF gating prevents redundant scans.
|
||||||
- The re-entrance guard (accessibilityUpdating) MUST come before the
|
- WINDOWP, BUFFERP validation for partially initialized frames.
|
||||||
child frame dispatch, because Lisp calls in the scan function can
|
- Buffer size limit (10000 chars) skips non-completion child frames.
|
||||||
trigger redisplay.
|
|
||||||
- BUF_MODIFF gating prevents redundant scans on every redisplay tick
|
|
||||||
and provides a secondary re-entrance guard.
|
|
||||||
- Frame state validation (WINDOWP, BUFFERP) handles partially
|
|
||||||
initialized child frames during creation.
|
|
||||||
- Buffer size limit (10000 chars) skips non-completion child frames
|
|
||||||
such as eldoc documentation or which-key popups.
|
|
||||||
|
|
||||||
Remove the child frame window from the accessibility tree via
|
Accessibility:
|
||||||
setAccessibilityElement:NO to prevent VoiceOver's blocking
|
- Set the child frame window's accessibilityRole to Group. Groups
|
||||||
"X window" announcement. Our candidate announcements go to NSApp
|
don't trigger VoiceOver's window-appeared announcement but still
|
||||||
(not the window element) and are unaffected.
|
participate in focus tracking (unlike setAccessibilityElement:NO
|
||||||
|
which breaks focus return).
|
||||||
|
- Post FocusedUIElementChangedNotification on the parent frame when
|
||||||
|
no candidate is found, to restore VoiceOver focus after close.
|
||||||
|
- Reset overlayZoomActive at the start of each parent frame
|
||||||
|
accessibility cycle. The overlay or child frame handler re-sets
|
||||||
|
it if a candidate is active; otherwise Zoom returns to the text
|
||||||
|
cursor (handles C-g and frame destruction gracefully).
|
||||||
|
|
||||||
Zoom tracking stores the candidate rect in the PARENT frame's
|
Zoom tracking stores the candidate rect in the PARENT frame's
|
||||||
overlayZoomRect (via child view -> screen -> parent view coordinate
|
overlayZoomRect (via child view -> screen -> parent view coordinate
|
||||||
@@ -45,11 +45,11 @@ on the candidate instead of the text cursor.
|
|||||||
* src/nsterm.m (ns_ax_selected_child_frame_text): New function.
|
* src/nsterm.m (ns_ax_selected_child_frame_text): New function.
|
||||||
(EmacsView announceChildFrameCompletion): New method.
|
(EmacsView announceChildFrameCompletion): New method.
|
||||||
(EmacsView postAccessibilityUpdates): Dispatch to child frame
|
(EmacsView postAccessibilityUpdates): Dispatch to child frame
|
||||||
handler for FRAME_PARENT_FRAME frames, under re-entrance guard.
|
handler, reset overlayZoomActive each cycle.
|
||||||
---
|
---
|
||||||
src/nsterm.h | 1 +
|
src/nsterm.h | 1 +
|
||||||
src/nsterm.m | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
src/nsterm.m | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||||
2 files changed, 231 insertions(+), 1 deletion(-)
|
2 files changed, 248 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
diff --git a/src/nsterm.h b/src/nsterm.h
|
diff --git a/src/nsterm.h b/src/nsterm.h
|
||||||
index 5c15639..21b2823 100644
|
index 5c15639..21b2823 100644
|
||||||
@@ -64,7 +64,7 @@ index 5c15639..21b2823 100644
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
index d13c5c7..3735f01 100644
|
index d13c5c7..2b7a386 100644
|
||||||
--- a/src/nsterm.m
|
--- a/src/nsterm.m
|
||||||
+++ b/src/nsterm.m
|
+++ b/src/nsterm.m
|
||||||
@@ -7066,6 +7066,110 @@ ns_ax_selected_overlay_text (struct buffer *b,
|
@@ -7066,6 +7066,110 @@ ns_ax_selected_overlay_text (struct buffer *b,
|
||||||
@@ -228,12 +228,18 @@ index d13c5c7..3735f01 100644
|
|||||||
+
|
+
|
||||||
+ if (!candidate)
|
+ if (!candidate)
|
||||||
+ {
|
+ {
|
||||||
+ /* No selected candidate --- clear parent Zoom override. */
|
+ /* No selected candidate --- clear parent Zoom override
|
||||||
|
+ and restore VoiceOver focus to the parent frame. */
|
||||||
+ if (parent)
|
+ if (parent)
|
||||||
+ {
|
+ {
|
||||||
+ EmacsView *parentView = FRAME_NS_VIEW (parent);
|
+ EmacsView *parentView = FRAME_NS_VIEW (parent);
|
||||||
+ if (parentView)
|
+ if (parentView)
|
||||||
|
+ {
|
||||||
+ parentView->overlayZoomActive = NO;
|
+ parentView->overlayZoomActive = NO;
|
||||||
|
+ ns_ax_post_notification (
|
||||||
|
+ parentView,
|
||||||
|
+ NSAccessibilityFocusedUIElementChangedNotification);
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
@@ -245,12 +251,6 @@ index d13c5c7..3735f01 100644
|
|||||||
+ xfree (lastCandidate);
|
+ xfree (lastCandidate);
|
||||||
+ lastCandidate = xstrdup (cstr);
|
+ lastCandidate = xstrdup (cstr);
|
||||||
+
|
+
|
||||||
+ /* Suppress VoiceOver's automatic "X window" announcement for
|
|
||||||
+ 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 = @{
|
+ NSDictionary *annInfo = @{
|
||||||
+ NSAccessibilityAnnouncementKey: candidate,
|
+ NSAccessibilityAnnouncementKey: candidate,
|
||||||
+ NSAccessibilityPriorityKey:
|
+ NSAccessibilityPriorityKey:
|
||||||
@@ -298,7 +298,7 @@ index d13c5c7..3735f01 100644
|
|||||||
- (void)postAccessibilityUpdates
|
- (void)postAccessibilityUpdates
|
||||||
{
|
{
|
||||||
NSTRACE ("[EmacsView postAccessibilityUpdates]");
|
NSTRACE ("[EmacsView postAccessibilityUpdates]");
|
||||||
@@ -12309,11 +12526,23 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
@@ -12309,11 +12526,40 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
||||||
|
|
||||||
/* 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
|
||||||
@@ -312,13 +312,30 @@ index d13c5c7..3735f01 100644
|
|||||||
|
|
||||||
+ /* Child frame completion popup (Corfu, Company-box, etc.).
|
+ /* Child frame completion popup (Corfu, Company-box, etc.).
|
||||||
+ Child frames don't participate in the accessibility tree;
|
+ Child frames don't participate in the accessibility tree;
|
||||||
+ announce the selected candidate directly. */
|
+ announce the selected candidate directly.
|
||||||
|
+
|
||||||
|
+ Suppress VoiceOver's "X window" announcement by setting
|
||||||
|
+ the window's accessibility role to Group. Groups don't
|
||||||
|
+ trigger window-appeared announcements but still participate
|
||||||
|
+ in focus tracking. Do this BEFORE the scan so VoiceOver
|
||||||
|
+ processes the role change before any window announcement. */
|
||||||
+ if (FRAME_PARENT_FRAME (emacsframe))
|
+ if (FRAME_PARENT_FRAME (emacsframe))
|
||||||
+ {
|
+ {
|
||||||
|
+ /* Set role to Group instead of Window. Groups don't
|
||||||
|
+ trigger VoiceOver's window-appeared announcement but
|
||||||
|
+ still participate in focus tracking. */
|
||||||
|
+ [[self window]
|
||||||
|
+ setAccessibilityRole:NSAccessibilityGroupRole];
|
||||||
+ [self announceChildFrameCompletion];
|
+ [self announceChildFrameCompletion];
|
||||||
+ accessibilityUpdating = NO;
|
+ accessibilityUpdating = NO;
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Reset overlay Zoom each cycle. The overlay branch or child
|
||||||
|
+ frame handler will set it again if a candidate is active.
|
||||||
|
+ This ensures Zoom returns to the text cursor when completion
|
||||||
|
+ ends (including C-g with no buffer text change). */
|
||||||
|
+ overlayZoomActive = NO;
|
||||||
+
|
+
|
||||||
/* Detect window tree change (split, delete, new buffer). Compare
|
/* Detect window tree change (split, delete, new buffer). Compare
|
||||||
FRAME_ROOT_WINDOW --- if it changed, the tree structure changed. */
|
FRAME_ROOT_WINDOW --- if it changed, the tree structure changed. */
|
||||||
|
|||||||
Reference in New Issue
Block a user