patches: auto-detect Zoom/VoiceOver; single variable gates both

Changes:
- EmacsApp gets ns_update_accessibility_state and
  ns_accessibility_did_change: methods (patch 0005)
- At startup: UAZoomEnabled() + AXIsProcessTrustedWithOptions()
  determine initial ns_accessibility_enabled state
- com.apple.accessibility.api distributed notification updates it
  whenever any AT connects or disconnects
- All Zoom call sites (UAZoomChangeFocus) now gated by
  ns_accessibility_enabled in addition to ns_zoom_enabled_p()
- ns-accessibility-enabled docstring updated to describe auto-detect

Result: zero config needed; zero overhead when no AT is active;
single variable overrides auto-detection when needed.
This commit is contained in:
2026-03-01 06:39:37 +01:00
parent cc7b288e99
commit 636545c2a5
9 changed files with 163 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
From 2466072f55f562d96d189814815bf8c4084338b5 Mon Sep 17 00:00:00 2001
From 2dabc7e44d316fa29e64958383fbac230f0f6870 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 16:01:29 +0100
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
@@ -109,10 +109,10 @@ index 2102fb9..dd98d56 100644
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index 71b6d2e..fd7c520 100644
index 5654283..69644d5 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7353,6 +7353,112 @@ visual line index for Zoom (skip whitespace-only lines
@@ -7401,6 +7401,112 @@ visual line index for Zoom (skip whitespace-only lines
return nil;
}
@@ -225,7 +225,7 @@ index 71b6d2e..fd7c520 100644
/* Build accessibility text for window W, skipping invisible text.
Populates *OUT_START with the buffer start charpos.
Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS
@@ -8097,16 +8203,25 @@ - (void)ensureTextCache
@@ -8145,16 +8251,25 @@ - (void)ensureTextCache
if (!b)
return;
@@ -259,7 +259,7 @@ index 71b6d2e..fd7c520 100644
&& cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart
&& (textLen == 0
@@ -8122,7 +8237,7 @@ included in the cached AX text (it is handled separately via
@@ -8170,7 +8285,7 @@ included in the cached AX text (it is handled separately via
{
[cachedText release];
cachedText = [text retain];
@@ -268,7 +268,7 @@ index 71b6d2e..fd7c520 100644
cachedTextStart = start;
if (visibleRuns)
@@ -9090,6 +9205,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
@@ -9138,6 +9253,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
ptrdiff_t currentOverlayStart = 0;
ptrdiff_t currentOverlayEnd = 0;
@@ -276,7 +276,7 @@ index 71b6d2e..fd7c520 100644
specpdl_ref count2 = SPECPDL_INDEX ();
record_unwind_current_buffer ();
if (b != current_buffer)
@@ -9248,6 +9364,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
@@ -9296,6 +9412,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
self.cachedCompletionOverlayEnd = 0;
self.cachedCompletionPoint = 0;
}
@@ -284,7 +284,7 @@ index 71b6d2e..fd7c520 100644
}
/* ---- Notification dispatch (main entry point) ---- */
@@ -9844,6 +9961,10 @@ - (void)dealloc
@@ -9892,6 +10009,10 @@ - (void)dealloc
#endif
[accessibilityElements release];
@@ -295,7 +295,7 @@ index 71b6d2e..fd7c520 100644
[[self menu] release];
[super dealloc];
}
@@ -11293,6 +11414,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
@@ -11341,6 +11462,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
windowClosing = NO;
processingCompose = NO;
@@ -305,7 +305,7 @@ index 71b6d2e..fd7c520 100644
scrollbarsNeedingUpdate = 0;
fs_state = FULLSCREEN_NONE;
fs_before_fs = next_maximized = -1;
@@ -12601,6 +12725,80 @@ - (id)accessibilityFocusedUIElement
@@ -12649,6 +12773,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. */
@@ -386,7 +386,7 @@ index 71b6d2e..fd7c520 100644
- (void)postAccessibilityUpdates
{
NSTRACE ("[EmacsView postAccessibilityUpdates]");
@@ -12611,11 +12809,59 @@ - (void)postAccessibilityUpdates
@@ -12659,11 +12857,59 @@ - (void)postAccessibilityUpdates
/* Re-entrance guard: VoiceOver callbacks during notification posting
can trigger redisplay, which calls ns_update_end, which calls us