patches: address all maintainer review issues

- Issue 1: Add explicit ApplicationServices import for UAZoomEnabled/
  UAZoomChangeFocus (was implicit via Carbon.h, now explicit)
- Issue 2: Rename FOR_EACH_FRAME variable 'frames' -> 'frame' (plural
  was misleading; matches Emacs convention)
- Issue 3: Move unblock_input before ObjC calls in
  postCompletionAnnouncementForBuffer: to avoid holding block_input
  during @synchronized operations
- Issue 4: Fix DEFVAR_BOOL doc and Texinfo: initial value is nil,
  not t; auto-detection sets it at startup
- Issue 5: Replace magic 10000 with NS_AX_MAX_COMPLETION_BUFFER_CHARS
  constant with explanatory comment
- Issue 6: Add comment to lineStartOffsets loop explaining it is gated
  on BUF_CHARS_MODIFF and never runs on the hot path
- Issue 8: Rewrite all 9 commit messages to GNU ChangeLog format with
  '* file (symbol): description' entries
- Issue 9: Break 81-char @interface line in nsterm.h
- Issue 10: Add WINDOWP/BUFFERP guards before dereferencing
  cf->selected_window and cw->contents in ns_zoom_find_child_frame_candidate
- Issue 11: Fix @pxref -> @xref at sentence start in macos.texi
This commit is contained in:
2026-03-01 09:44:47 +01:00
parent e0343db56c
commit 71c81abcae
9 changed files with 275 additions and 279 deletions

View File

@@ -1,26 +1,26 @@
From 6f37c729a3646dc0ac4c68825edac8f6a81cd9ec Mon Sep 17 00:00:00 2001
From 0e8d5540c8993b2e91c437d20e47e7abeb12543f Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 5/8] ns: integrate accessibility with EmacsView and redisplay
Wire the accessibility infrastructure into EmacsView and the
Wire the accessibility element tree into EmacsView and hook it into
the redisplay cycle.
* src/nsterm.m (ns_update_end): Call [view postAccessibilityUpdates].
* etc/NEWS: Document VoiceOver accessibility support.
* src/nsterm.m (ns_update_end): Call -[EmacsView postAccessibilityUpdates].
(EmacsApp ns_update_accessibility_state): New method; query
AXIsProcessTrustedWithOptions and UAZoomEnabled to set
ns_accessibility_enabled automatically.
(EmacsApp ns_accessibility_did_change:): New method; handle
com.apple.accessibility.api distributed notification.
(EmacsView dealloc): Release accessibilityElements.
(EmacsView windowDidBecomeKey): Post accessibility focus notification.
(EmacsView windowDidBecomeKey:): Post accessibility focus notification.
(ns_ax_collect_windows): New function.
(EmacsView rebuildAccessibilityTree, invalidateAccessibilityTree)
(accessibilityChildren, accessibilityFocusedUIElement)
(postAccessibilityUpdates, accessibilityBoundsForRange:)
(accessibilityParameterizedAttributeNames)
(accessibilityAttributeValue:forParameter:): New methods.
* etc/NEWS: Document VoiceOver accessibility support.
Tested on macOS 14 with VoiceOver. End-to-end: buffer
navigation, cursor tracking, window switching, completions, evil-mode
block cursor, org-mode folded headings, indirect buffers.
Known limitations documented in patch 6 Texinfo node.
---
etc/NEWS | 13 ++
src/nsterm.m | 430 +++++++++++++++++++++++++++++++++++++++++++++++++--
@@ -51,10 +51,10 @@ index 80661a9..2b1f9e6 100644
** Re-introduced dictation, lost in Emacs v30 (macOS).
We lost macOS dictation in v30 when migrating to NSTextInputClient.
diff --git a/src/nsterm.m b/src/nsterm.m
index 8c26e27..70c7521 100644
index 992a5ce..d9b8ecd 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1258,7 +1258,7 @@ If a completion candidate is selected (overlay or child frame),
@@ -1275,7 +1275,7 @@ If a completion candidate is selected (overlay or child frame),
static void
ns_zoom_track_completion (struct frame *f, EmacsView *view)
{
@@ -63,7 +63,7 @@ index 8c26e27..70c7521 100644
return;
if (!WINDOWP (f->selected_window))
return;
@@ -1375,7 +1375,8 @@ so the visual offset is (ov_line + 1) * line_h from
@@ -1392,7 +1392,8 @@ so the visual offset is (ov_line + 1) * line_h from
(zoomCursorUpdated is NO). */
#if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \
&& MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
@@ -73,7 +73,7 @@ index 8c26e27..70c7521 100644
&& !NSIsEmptyRect (view->lastCursorRect))
{
NSRect r = view->lastCursorRect;
@@ -1402,6 +1403,9 @@ so the visual offset is (ov_line + 1) * line_h from
@@ -1419,6 +1420,9 @@ so the visual offset is (ov_line + 1) * line_h from
if (view)
ns_zoom_track_completion (f, view);
#endif /* NS_IMPL_COCOA */
@@ -83,7 +83,7 @@ index 8c26e27..70c7521 100644
}
static void
@@ -3549,7 +3553,7 @@ EmacsView pixels (AppKit, flipped, top-left origin)
@@ -3566,7 +3570,7 @@ EmacsView pixels (AppKit, flipped, top-left origin)
#if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \
&& MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
@@ -92,7 +92,7 @@ index 8c26e27..70c7521 100644
{
NSRect windowRect = [view convertRect:r toView:nil];
NSRect screenRect
@@ -6714,9 +6718,56 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
@@ -6731,9 +6735,56 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
}
#endif
@@ -149,7 +149,7 @@ index 8c26e27..70c7521 100644
- (void)antialiasThresholdDidChange:(NSNotification *)notification
{
#ifdef NS_IMPL_COCOA
@@ -7617,7 +7668,6 @@ - (id)accessibilityTopLevelUIElement
@@ -7634,7 +7685,6 @@ - (id)accessibilityTopLevelUIElement
@@ -157,7 +157,7 @@ index 8c26e27..70c7521 100644
static BOOL
ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point,
ptrdiff_t *out_start,
@@ -8738,7 +8788,6 @@ - (NSRect)accessibilityFrame
@@ -8759,7 +8809,6 @@ - (NSRect)accessibilityFrame
@end
@@ -165,7 +165,7 @@ index 8c26e27..70c7521 100644
/* ===================================================================
EmacsAccessibilityBuffer (Notifications) — AX event dispatch
@@ -9283,7 +9332,6 @@ - (NSRect)accessibilityFrame
@@ -9305,7 +9354,6 @@ - (NSRect)accessibilityFrame
@end
@@ -173,7 +173,7 @@ index 8c26e27..70c7521 100644
/* ===================================================================
EmacsAccessibilityInteractiveSpan — helpers and implementation
=================================================================== */
@@ -9613,6 +9661,7 @@ - (void)dealloc
@@ -9635,6 +9683,7 @@ - (void)dealloc
[layer release];
#endif
@@ -181,7 +181,7 @@ index 8c26e27..70c7521 100644
[[self menu] release];
[super dealloc];
}
@@ -10961,6 +11010,32 @@ - (void)windowDidBecomeKey /* for direct calls */
@@ -10983,6 +11032,32 @@ - (void)windowDidBecomeKey /* for direct calls */
XSETFRAME (event.frame_or_window, emacsframe);
kbd_buffer_store_event (&event);
ns_send_appdefined (-1); // Kick main loop
@@ -214,7 +214,7 @@ index 8c26e27..70c7521 100644
}
@@ -12198,6 +12273,332 @@ - (int) fullscreenState
@@ -12220,6 +12295,332 @@ - (int) fullscreenState
return fs_state;
}
@@ -547,7 +547,7 @@ index 8c26e27..70c7521 100644
@end /* EmacsView */
@@ -14198,12 +14599,17 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
@@ -14220,12 +14621,17 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
ns_use_srgb_colorspace = YES;
DEFVAR_BOOL ("ns-accessibility-enabled", ns_accessibility_enabled,