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:
@@ -1,4 +1,4 @@
|
|||||||
From 38bbd275736251862f4b2fb433ee0a84799f0cec Mon Sep 17 00:00:00 2001
|
From d494967af08ec3e5bb94ff50126c2994505a6d85 Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 22:39:35 +0100
|
Date: Sat, 28 Feb 2026 22:39:35 +0100
|
||||||
Subject: [PATCH 1/9] ns: integrate with macOS Zoom for cursor tracking
|
Subject: [PATCH 1/9] ns: integrate with macOS Zoom for cursor tracking
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 92f8d65bd248ac3bcc5d40b0707ffa184d3c7fa5 Mon Sep 17 00:00:00 2001
|
From 971bf8f19bec3a89144ddf2375cd17a4d95bb707 Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 2/9] ns: add accessibility base classes and text extraction
|
Subject: [PATCH 2/9] ns: add accessibility base classes and text extraction
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From a9af26dc0f2762b5e53785554f110a08aad72d01 Mon Sep 17 00:00:00 2001
|
From d49a7ef5e31a5988d6c54a04561326cff8444a2f Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 3/9] ns: implement buffer accessibility element (core
|
Subject: [PATCH 3/9] ns: implement buffer accessibility element (core
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 593b5219ee63b32125efc0e58e9c376c949b463b Mon Sep 17 00:00:00 2001
|
From 5a58044053001af12f388af2960f903427676c8f Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 4/9] ns: add buffer notification dispatch and mode-line
|
Subject: [PATCH 4/9] ns: add buffer notification dispatch and mode-line
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 19053ea6ef478603115e2f4288f54d44ce204bcd Mon Sep 17 00:00:00 2001
|
From 388628944f6ecc74806932e0ee2ad89c3df669ed Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 5/9] ns: add interactive span elements for Tab navigation
|
Subject: [PATCH 5/9] ns: add interactive span elements for Tab navigation
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 7b4c8fc93674296aac802377ad223db50f79f33d Mon Sep 17 00:00:00 2001
|
From 61a0ae5344e6f52cb21ae299133b39b2ede010d0 Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay
|
Subject: [PATCH 6/9] ns: integrate accessibility with EmacsView and redisplay
|
||||||
@@ -23,8 +23,8 @@ block cursor, org-mode folded headings, indirect buffers.
|
|||||||
Known limitations documented in patch 6 Texinfo node.
|
Known limitations documented in patch 6 Texinfo node.
|
||||||
---
|
---
|
||||||
etc/NEWS | 13 ++
|
etc/NEWS | 13 ++
|
||||||
src/nsterm.m | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
src/nsterm.m | 430 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
2 files changed, 369 insertions(+), 3 deletions(-)
|
2 files changed, 431 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
diff --git a/etc/NEWS b/etc/NEWS
|
diff --git a/etc/NEWS b/etc/NEWS
|
||||||
index 80661a9..2b1f9e6 100644
|
index 80661a9..2b1f9e6 100644
|
||||||
@@ -51,10 +51,29 @@ index 80661a9..2b1f9e6 100644
|
|||||||
** Re-introduced dictation, lost in Emacs v30 (macOS).
|
** Re-introduced dictation, lost in Emacs v30 (macOS).
|
||||||
We lost macOS dictation in v30 when migrating to NSTextInputClient.
|
We lost macOS dictation in v30 when migrating to NSTextInputClient.
|
||||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
index 5eaf480..1577338 100644
|
index 5eaf480..4ad451f 100644
|
||||||
--- a/src/nsterm.m
|
--- a/src/nsterm.m
|
||||||
+++ b/src/nsterm.m
|
+++ b/src/nsterm.m
|
||||||
@@ -1405,6 +1405,9 @@ so the visual offset is (ov_line + 1) * line_h from
|
@@ -1258,7 +1258,7 @@ If a completion candidate is selected (overlay or child frame),
|
||||||
|
static void
|
||||||
|
ns_zoom_track_completion (struct frame *f, EmacsView *view)
|
||||||
|
{
|
||||||
|
- if (!ns_zoom_enabled_p ())
|
||||||
|
+ if (!ns_accessibility_enabled || !ns_zoom_enabled_p ())
|
||||||
|
return;
|
||||||
|
if (!WINDOWP (f->selected_window))
|
||||||
|
return;
|
||||||
|
@@ -1378,7 +1378,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
|
||||||
|
- if (view && !view->zoomCursorUpdated && ns_zoom_enabled_p ()
|
||||||
|
+ if (ns_accessibility_enabled && view && !view->zoomCursorUpdated
|
||||||
|
+ && ns_zoom_enabled_p ()
|
||||||
|
&& !NSIsEmptyRect (view->lastCursorRect))
|
||||||
|
{
|
||||||
|
NSRect r = view->lastCursorRect;
|
||||||
|
@@ -1405,6 +1406,9 @@ so the visual offset is (ov_line + 1) * line_h from
|
||||||
if (view)
|
if (view)
|
||||||
ns_zoom_track_completion (f, view);
|
ns_zoom_track_completion (f, view);
|
||||||
#endif /* NS_IMPL_COCOA */
|
#endif /* NS_IMPL_COCOA */
|
||||||
@@ -64,7 +83,73 @@ index 5eaf480..1577338 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -7620,7 +7623,6 @@ - (id)accessibilityTopLevelUIElement
|
@@ -3552,7 +3556,7 @@ EmacsView pixels (AppKit, flipped, top-left origin)
|
||||||
|
|
||||||
|
#if defined (MAC_OS_X_VERSION_MIN_REQUIRED) \
|
||||||
|
&& MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
|
||||||
|
- if (ns_zoom_enabled_p ())
|
||||||
|
+ if (ns_accessibility_enabled && ns_zoom_enabled_p ())
|
||||||
|
{
|
||||||
|
NSRect windowRect = [view convertRect:r toView:nil];
|
||||||
|
NSRect screenRect
|
||||||
|
@@ -6717,9 +6721,56 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifdef NS_IMPL_COCOA
|
||||||
|
+ /* Auto-detect Zoom and VoiceOver at startup and whenever their state
|
||||||
|
+ changes. The "com.apple.accessibility.api" distributed notification
|
||||||
|
+ fires when any assistive technology connects or disconnects.
|
||||||
|
+ Both code paths set ns_accessibility_enabled so that one variable
|
||||||
|
+ gates all our accessibility overhead. */
|
||||||
|
+ [self ns_update_accessibility_state];
|
||||||
|
+ [[NSDistributedNotificationCenter defaultCenter]
|
||||||
|
+ addObserver: self
|
||||||
|
+ selector: @selector(ns_accessibility_did_change:)
|
||||||
|
+ name: @"com.apple.accessibility.api"
|
||||||
|
+ object: nil
|
||||||
|
+suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
ns_send_appdefined (-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef NS_IMPL_COCOA
|
||||||
|
+/* Set ns_accessibility_enabled based on current AT state.
|
||||||
|
+ Called at startup and from the "com.apple.accessibility.api"
|
||||||
|
+ distributed notification handler. Checks both UAZoomEnabled()
|
||||||
|
+ (Zoom) and AXIsProcessTrustedWithOptions() (VoiceOver and other
|
||||||
|
+ ATs that have connected to this process). */
|
||||||
|
+- (void) ns_update_accessibility_state
|
||||||
|
+{
|
||||||
|
+ NSTRACE ("[EmacsApp ns_update_accessibility_state]");
|
||||||
|
+ BOOL zoom_on = UAZoomEnabled ();
|
||||||
|
+ NSDictionary *opts = @{(__bridge id) kAXTrustedCheckOptionPrompt: @NO};
|
||||||
|
+ BOOL at_on = AXIsProcessTrustedWithOptions ((__bridge CFDictionaryRef) opts);
|
||||||
|
+ BOOL new_state = zoom_on || at_on;
|
||||||
|
+ if ((BOOL) ns_accessibility_enabled != new_state)
|
||||||
|
+ {
|
||||||
|
+ ns_accessibility_enabled = new_state;
|
||||||
|
+ /* Reset the UAZoomEnabled cache so ns_zoom_enabled_p() reflects
|
||||||
|
+ the new Zoom state on its next call. */
|
||||||
|
+ ns_zoom_cache_time = 0;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Handler for the "com.apple.accessibility.api" distributed notification,
|
||||||
|
+ posted by macOS when any AT (VoiceOver, Switch Control, etc.) starts
|
||||||
|
+ or stops. */
|
||||||
|
+- (void) ns_accessibility_did_change: (NSNotification *) notification
|
||||||
|
+{
|
||||||
|
+ NSTRACE ("[EmacsApp ns_accessibility_did_change:]");
|
||||||
|
+ [self ns_update_accessibility_state];
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
- (void)antialiasThresholdDidChange:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
|
@@ -7620,7 +7671,6 @@ - (id)accessibilityTopLevelUIElement
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +157,7 @@ index 5eaf480..1577338 100644
|
|||||||
static BOOL
|
static BOOL
|
||||||
ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point,
|
ns_ax_find_completion_overlay_range (struct buffer *b, ptrdiff_t point,
|
||||||
ptrdiff_t *out_start,
|
ptrdiff_t *out_start,
|
||||||
@@ -8722,7 +8724,6 @@ - (NSRect)accessibilityFrame
|
@@ -8722,7 +8772,6 @@ - (NSRect)accessibilityFrame
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +165,7 @@ index 5eaf480..1577338 100644
|
|||||||
/* ===================================================================
|
/* ===================================================================
|
||||||
EmacsAccessibilityBuffer (Notifications) — AX event dispatch
|
EmacsAccessibilityBuffer (Notifications) — AX event dispatch
|
||||||
|
|
||||||
@@ -9267,7 +9268,6 @@ - (NSRect)accessibilityFrame
|
@@ -9267,7 +9316,6 @@ - (NSRect)accessibilityFrame
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@@ -88,7 +173,7 @@ index 5eaf480..1577338 100644
|
|||||||
/* ===================================================================
|
/* ===================================================================
|
||||||
EmacsAccessibilityInteractiveSpan — helpers and implementation
|
EmacsAccessibilityInteractiveSpan — helpers and implementation
|
||||||
=================================================================== */
|
=================================================================== */
|
||||||
@@ -9597,6 +9597,7 @@ - (void)dealloc
|
@@ -9597,6 +9645,7 @@ - (void)dealloc
|
||||||
[layer release];
|
[layer release];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -96,7 +181,7 @@ index 5eaf480..1577338 100644
|
|||||||
[[self menu] release];
|
[[self menu] release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
@@ -10945,6 +10946,32 @@ - (void)windowDidBecomeKey /* for direct calls */
|
@@ -10945,6 +10994,32 @@ - (void)windowDidBecomeKey /* for direct calls */
|
||||||
XSETFRAME (event.frame_or_window, emacsframe);
|
XSETFRAME (event.frame_or_window, emacsframe);
|
||||||
kbd_buffer_store_event (&event);
|
kbd_buffer_store_event (&event);
|
||||||
ns_send_appdefined (-1); // Kick main loop
|
ns_send_appdefined (-1); // Kick main loop
|
||||||
@@ -129,7 +214,7 @@ index 5eaf480..1577338 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -12182,6 +12209,332 @@ - (int) fullscreenState
|
@@ -12182,6 +12257,332 @@ - (int) fullscreenState
|
||||||
return fs_state;
|
return fs_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,6 +547,30 @@ index 5eaf480..1577338 100644
|
|||||||
@end /* EmacsView */
|
@end /* EmacsView */
|
||||||
|
|
||||||
|
|
||||||
|
@@ -14182,12 +14583,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,
|
||||||
|
- doc: /* Non-nil means expose buffer content to the macOS accessibility
|
||||||
|
-subsystem (VoiceOver, Zoom, and other assistive technology).
|
||||||
|
-When nil, the accessibility virtual element tree is not built and no
|
||||||
|
-notifications are posted, eliminating the associated overhead.
|
||||||
|
-Requires the Cocoa (NS) build on macOS; ignored on GNUstep.
|
||||||
|
-Default is nil. Set to t to enable VoiceOver support. */);
|
||||||
|
+ doc: /* Non-nil enables Zoom cursor tracking and VoiceOver support.
|
||||||
|
+Emacs sets this automatically at startup when macOS Zoom is active or
|
||||||
|
+any assistive technology (VoiceOver, Switch Control, etc.) is connected,
|
||||||
|
+and updates it whenever that state changes. You can override manually:
|
||||||
|
+
|
||||||
|
+ (setq ns-accessibility-enabled t) ; always on
|
||||||
|
+ (setq ns-accessibility-enabled nil) ; always off
|
||||||
|
+
|
||||||
|
+When nil, no AX tree is built and no notifications are posted,
|
||||||
|
+giving zero per-redisplay overhead.
|
||||||
|
+Requires the Cocoa (NS) build on macOS; ignored on GNUstep. */);
|
||||||
|
ns_accessibility_enabled = NO;
|
||||||
|
|
||||||
|
DEFVAR_BOOL ("ns-use-mwheel-acceleration",
|
||||||
--
|
--
|
||||||
2.43.0
|
2.43.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 44cb6c8657feb1e17afabfb1a97d341727245bdd Mon Sep 17 00:00:00 2001
|
From e2213409bca76154764263879b4bd43459230d6c Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
Date: Sat, 28 Feb 2026 12:58:11 +0100
|
||||||
Subject: [PATCH 7/9] doc: add VoiceOver accessibility section to macOS
|
Subject: [PATCH 7/9] doc: add VoiceOver accessibility section to macOS
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
From 03bc19846230e9df6545948e6a431fdb7bdce031 Mon Sep 17 00:00:00 2001
|
From a5041ede13b2bbcea1ebcb501f8c7317c0fe998f Mon Sep 17 00:00:00 2001
|
||||||
From: Martin Sukany <martin@sukany.cz>
|
From: Martin Sukany <martin@sukany.cz>
|
||||||
Date: Sat, 28 Feb 2026 14:46:25 +0100
|
Date: Sat, 28 Feb 2026 14:46:25 +0100
|
||||||
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver
|
Subject: [PATCH 8/9] ns: announce overlay completion candidates for VoiceOver
|
||||||
@@ -61,10 +61,10 @@ index 6e830de..2102fb9 100644
|
|||||||
@property (nonatomic, assign) BOOL cachedMarkActive;
|
@property (nonatomic, assign) BOOL cachedMarkActive;
|
||||||
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
|
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
|
||||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
index 1577338..71b6d2e 100644
|
index 4ad451f..5654283 100644
|
||||||
--- a/src/nsterm.m
|
--- a/src/nsterm.m
|
||||||
+++ b/src/nsterm.m
|
+++ b/src/nsterm.m
|
||||||
@@ -7209,11 +7209,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
@@ -7257,11 +7257,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||||
|
|
||||||
/* ---- Helper: extract buffer text for accessibility ---- */
|
/* ---- Helper: extract buffer text for accessibility ---- */
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ index 1577338..71b6d2e 100644
|
|||||||
static NSString *
|
static NSString *
|
||||||
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||||
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
||||||
@@ -7284,7 +7427,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
@@ -7332,7 +7475,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||||
|
|
||||||
/* Extract this visible run's text. Use
|
/* Extract this visible run's text. Use
|
||||||
Fbuffer_substring_no_properties which correctly handles the
|
Fbuffer_substring_no_properties which correctly handles the
|
||||||
@@ -229,7 +229,7 @@ index 1577338..71b6d2e 100644
|
|||||||
include garbage bytes when the run spans the gap position. */
|
include garbage bytes when the run spans the gap position. */
|
||||||
Lisp_Object lstr = Fbuffer_substring_no_properties (
|
Lisp_Object lstr = Fbuffer_substring_no_properties (
|
||||||
make_fixnum (pos), make_fixnum (run_end));
|
make_fixnum (pos), make_fixnum (run_end));
|
||||||
@@ -7365,7 +7508,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
@@ -7413,7 +7556,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
|
|
||||||
/* charpos_start and charpos_len are already in buffer charpos
|
/* charpos_start and charpos_len are already in buffer charpos
|
||||||
@@ -238,7 +238,7 @@ index 1577338..71b6d2e 100644
|
|||||||
charposForAccessibilityIndex which handles invisible text. */
|
charposForAccessibilityIndex which handles invisible text. */
|
||||||
ptrdiff_t cp_start = charpos_start;
|
ptrdiff_t cp_start = charpos_start;
|
||||||
ptrdiff_t cp_end = cp_start + charpos_len;
|
ptrdiff_t cp_end = cp_start + charpos_len;
|
||||||
@@ -7844,6 +7987,7 @@ @implementation EmacsAccessibilityBuffer
|
@@ -7892,6 +8035,7 @@ @implementation EmacsAccessibilityBuffer
|
||||||
@synthesize cachedOverlayModiff;
|
@synthesize cachedOverlayModiff;
|
||||||
@synthesize cachedTextStart;
|
@synthesize cachedTextStart;
|
||||||
@synthesize cachedModiff;
|
@synthesize cachedModiff;
|
||||||
@@ -246,7 +246,7 @@ index 1577338..71b6d2e 100644
|
|||||||
@synthesize cachedPoint;
|
@synthesize cachedPoint;
|
||||||
@synthesize cachedMarkActive;
|
@synthesize cachedMarkActive;
|
||||||
@synthesize cachedCompletionAnnouncement;
|
@synthesize cachedCompletionAnnouncement;
|
||||||
@@ -7941,7 +8085,7 @@ - (void)ensureTextCache
|
@@ -7989,7 +8133,7 @@ - (void)ensureTextCache
|
||||||
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
|
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
|
||||||
/* This method is only called from the main thread (AX getters
|
/* This method is only called from the main thread (AX getters
|
||||||
dispatch_sync to main first). Reads of cachedText/cachedTextModiff
|
dispatch_sync to main first). Reads of cachedText/cachedTextModiff
|
||||||
@@ -255,7 +255,7 @@ index 1577338..71b6d2e 100644
|
|||||||
write section at the end needs synchronization to protect
|
write section at the end needs synchronization to protect
|
||||||
against concurrent reads from AX server thread. */
|
against concurrent reads from AX server thread. */
|
||||||
eassert ([NSThread isMainThread]);
|
eassert ([NSThread isMainThread]);
|
||||||
@@ -7953,25 +8097,16 @@ - (void)ensureTextCache
|
@@ -8001,25 +8145,16 @@ - (void)ensureTextCache
|
||||||
if (!b)
|
if (!b)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ index 1577338..71b6d2e 100644
|
|||||||
&& cachedTextStart == BUF_BEGV (b)
|
&& cachedTextStart == BUF_BEGV (b)
|
||||||
&& pt >= cachedTextStart
|
&& pt >= cachedTextStart
|
||||||
&& (textLen == 0
|
&& (textLen == 0
|
||||||
@@ -7987,7 +8122,7 @@ included in the cached AX text (it is handled separately via
|
@@ -8035,7 +8170,7 @@ included in the cached AX text (it is handled separately via
|
||||||
{
|
{
|
||||||
[cachedText release];
|
[cachedText release];
|
||||||
cachedText = [text retain];
|
cachedText = [text retain];
|
||||||
@@ -298,7 +298,7 @@ index 1577338..71b6d2e 100644
|
|||||||
cachedTextStart = start;
|
cachedTextStart = start;
|
||||||
|
|
||||||
if (visibleRuns)
|
if (visibleRuns)
|
||||||
@@ -8052,7 +8187,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
@@ -8100,7 +8235,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||||
/* Binary search: runs are sorted by charpos (ascending). Find the
|
/* Binary search: runs are sorted by charpos (ascending). Find the
|
||||||
run whose [charpos, charpos+length) range contains the target,
|
run whose [charpos, charpos+length) range contains the target,
|
||||||
or the nearest run after an invisible gap. O(log n) instead of
|
or the nearest run after an invisible gap. O(log n) instead of
|
||||||
@@ -307,7 +307,7 @@ index 1577338..71b6d2e 100644
|
|||||||
NSUInteger lo = 0, hi = visibleRunCount;
|
NSUInteger lo = 0, hi = visibleRunCount;
|
||||||
while (lo < hi)
|
while (lo < hi)
|
||||||
{
|
{
|
||||||
@@ -8065,7 +8200,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
@@ -8113,7 +8248,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Found: charpos is inside this run. Compute UTF-16 delta
|
/* Found: charpos is inside this run. Compute UTF-16 delta
|
||||||
@@ -316,7 +316,7 @@ index 1577338..71b6d2e 100644
|
|||||||
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
||||||
if (chars_in == 0 || !cachedText)
|
if (chars_in == 0 || !cachedText)
|
||||||
return r->ax_start;
|
return r->ax_start;
|
||||||
@@ -8090,10 +8225,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
@@ -8138,10 +8273,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||||
|
|
||||||
/* Convert accessibility string index to buffer charpos.
|
/* Convert accessibility string index to buffer charpos.
|
||||||
Safe to call from any thread: uses only cachedText (NSString) and
|
Safe to call from any thread: uses only cachedText (NSString) and
|
||||||
@@ -329,7 +329,7 @@ index 1577338..71b6d2e 100644
|
|||||||
@synchronized (self)
|
@synchronized (self)
|
||||||
{
|
{
|
||||||
if (visibleRunCount == 0)
|
if (visibleRunCount == 0)
|
||||||
@@ -8127,7 +8262,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
@@ -8175,7 +8310,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +338,7 @@ index 1577338..71b6d2e 100644
|
|||||||
if (lo > 0)
|
if (lo > 0)
|
||||||
{
|
{
|
||||||
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
||||||
@@ -8149,7 +8284,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
@@ -8197,7 +8332,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||||
deadlocking the AX server thread. This is prevented by:
|
deadlocking the AX server thread. This is prevented by:
|
||||||
|
|
||||||
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
|
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
|
||||||
@@ -347,7 +347,7 @@ index 1577338..71b6d2e 100644
|
|||||||
2. All dispatch_sync blocks run on the main thread where no
|
2. All dispatch_sync blocks run on the main thread where no
|
||||||
concurrent Lisp code can modify state between checks.
|
concurrent Lisp code can modify state between checks.
|
||||||
3. block_input prevents timer events and process output from
|
3. block_input prevents timer events and process output from
|
||||||
@@ -8503,6 +8638,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
@@ -8551,6 +8686,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||||
return [self lineForAXIndex:point_idx];
|
return [self lineForAXIndex:point_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ index 1577338..71b6d2e 100644
|
|||||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
||||||
{
|
{
|
||||||
if (![NSThread isMainThread])
|
if (![NSThread isMainThread])
|
||||||
@@ -8725,7 +8904,7 @@ - (NSRect)accessibilityFrame
|
@@ -8773,7 +8952,7 @@ - (NSRect)accessibilityFrame
|
||||||
|
|
||||||
|
|
||||||
/* ===================================================================
|
/* ===================================================================
|
||||||
@@ -407,7 +407,7 @@ index 1577338..71b6d2e 100644
|
|||||||
|
|
||||||
These methods notify VoiceOver of text and selection changes.
|
These methods notify VoiceOver of text and selection changes.
|
||||||
Called from the redisplay cycle (postAccessibilityUpdates).
|
Called from the redisplay cycle (postAccessibilityUpdates).
|
||||||
@@ -8740,7 +8919,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
@@ -8788,7 +8967,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||||
if (point > self.cachedPoint
|
if (point > self.cachedPoint
|
||||||
&& point - self.cachedPoint == 1)
|
&& point - self.cachedPoint == 1)
|
||||||
{
|
{
|
||||||
@@ -416,7 +416,7 @@ index 1577338..71b6d2e 100644
|
|||||||
[self invalidateTextCache];
|
[self invalidateTextCache];
|
||||||
[self ensureTextCache];
|
[self ensureTextCache];
|
||||||
if (cachedText)
|
if (cachedText)
|
||||||
@@ -8759,7 +8938,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
@@ -8807,7 +8986,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||||
/* Update cachedPoint here so the selection-move branch does NOT
|
/* Update cachedPoint here so the selection-move branch does NOT
|
||||||
fire for point changes caused by edits. WebKit and Chromium
|
fire for point changes caused by edits. WebKit and Chromium
|
||||||
never send both ValueChanged and SelectedTextChanged for the
|
never send both ValueChanged and SelectedTextChanged for the
|
||||||
@@ -425,7 +425,7 @@ index 1577338..71b6d2e 100644
|
|||||||
self.cachedPoint = point;
|
self.cachedPoint = point;
|
||||||
|
|
||||||
NSDictionary *change = @{
|
NSDictionary *change = @{
|
||||||
@@ -9092,16 +9271,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
@@ -9140,16 +9319,83 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||||
BOOL markActive = !NILP (BVAR (b, mark_active));
|
BOOL markActive = !NILP (BVAR (b, mark_active));
|
||||||
|
|
||||||
/* --- Text changed (edit) --- */
|
/* --- Text changed (edit) --- */
|
||||||
@@ -513,7 +513,7 @@ index 1577338..71b6d2e 100644
|
|||||||
{
|
{
|
||||||
ptrdiff_t oldPoint = self.cachedPoint;
|
ptrdiff_t oldPoint = self.cachedPoint;
|
||||||
BOOL oldMarkActive = self.cachedMarkActive;
|
BOOL oldMarkActive = self.cachedMarkActive;
|
||||||
@@ -9269,7 +9515,7 @@ - (NSRect)accessibilityFrame
|
@@ -9317,7 +9563,7 @@ - (NSRect)accessibilityFrame
|
||||||
|
|
||||||
|
|
||||||
/* ===================================================================
|
/* ===================================================================
|
||||||
@@ -522,7 +522,7 @@ index 1577338..71b6d2e 100644
|
|||||||
=================================================================== */
|
=================================================================== */
|
||||||
|
|
||||||
/* Scan visible range of window W for interactive spans.
|
/* Scan visible range of window W for interactive spans.
|
||||||
@@ -9477,7 +9723,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
@@ -9525,7 +9771,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||||
dispatch_async (dispatch_get_main_queue (), ^{
|
dispatch_async (dispatch_get_main_queue (), ^{
|
||||||
/* lwin is a Lisp_Object captured by value. This is GC-safe
|
/* lwin is a Lisp_Object captured by value. This is GC-safe
|
||||||
because Lisp_Objects are tagged integers/pointers that
|
because Lisp_Objects are tagged integers/pointers that
|
||||||
@@ -531,7 +531,7 @@ index 1577338..71b6d2e 100644
|
|||||||
Emacs. The WINDOW_LIVE_P check below guards against the
|
Emacs. The WINDOW_LIVE_P check below guards against the
|
||||||
window being deleted between capture and execution. */
|
window being deleted between capture and execution. */
|
||||||
if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin)))
|
if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin)))
|
||||||
@@ -9503,7 +9749,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
@@ -9551,7 +9797,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ index 1577338..71b6d2e 100644
|
|||||||
Methods are kept here (same .m file) so they access the ivars
|
Methods are kept here (same .m file) so they access the ivars
|
||||||
declared in the @interface ivar block. */
|
declared in the @interface ivar block. */
|
||||||
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
||||||
@@ -12225,7 +12471,7 @@ - (int) fullscreenState
|
@@ -12273,7 +12519,7 @@ - (int) fullscreenState
|
||||||
|
|
||||||
if (WINDOW_LEAF_P (w))
|
if (WINDOW_LEAF_P (w))
|
||||||
{
|
{
|
||||||
@@ -549,7 +549,7 @@ index 1577338..71b6d2e 100644
|
|||||||
EmacsAccessibilityBuffer *elem
|
EmacsAccessibilityBuffer *elem
|
||||||
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
||||||
if (!elem)
|
if (!elem)
|
||||||
@@ -12259,7 +12505,7 @@ - (int) fullscreenState
|
@@ -12307,7 +12553,7 @@ - (int) fullscreenState
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -558,7 +558,7 @@ index 1577338..71b6d2e 100644
|
|||||||
Lisp_Object child = w->contents;
|
Lisp_Object child = w->contents;
|
||||||
while (!NILP (child))
|
while (!NILP (child))
|
||||||
{
|
{
|
||||||
@@ -12371,7 +12617,7 @@ - (void)postAccessibilityUpdates
|
@@ -12419,7 +12665,7 @@ - (void)postAccessibilityUpdates
|
||||||
accessibilityUpdating = YES;
|
accessibilityUpdating = YES;
|
||||||
|
|
||||||
/* Detect window tree change (split, delete, new buffer). Compare
|
/* Detect window tree change (split, delete, new buffer). Compare
|
||||||
@@ -567,7 +567,7 @@ index 1577338..71b6d2e 100644
|
|||||||
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
||||||
if (!EQ (curRoot, lastRootWindow))
|
if (!EQ (curRoot, lastRootWindow))
|
||||||
{
|
{
|
||||||
@@ -12380,12 +12626,12 @@ - (void)postAccessibilityUpdates
|
@@ -12428,12 +12674,12 @@ - (void)postAccessibilityUpdates
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
||||||
|
|||||||
@@ -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>
|
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 9/9] ns: announce child frame completion candidates for
|
Subject: [PATCH 9/9] ns: announce child frame completion candidates for
|
||||||
@@ -109,10 +109,10 @@ index 2102fb9..dd98d56 100644
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
index 71b6d2e..fd7c520 100644
|
index 5654283..69644d5 100644
|
||||||
--- a/src/nsterm.m
|
--- a/src/nsterm.m
|
||||||
+++ b/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;
|
return nil;
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
/* Build accessibility text for window W, skipping invisible text.
|
/* Build accessibility text for window W, skipping invisible text.
|
||||||
Populates *OUT_START with the buffer start charpos.
|
Populates *OUT_START with the buffer start charpos.
|
||||||
Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS
|
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)
|
if (!b)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
&& cachedTextStart == BUF_BEGV (b)
|
&& cachedTextStart == BUF_BEGV (b)
|
||||||
&& pt >= cachedTextStart
|
&& pt >= cachedTextStart
|
||||||
&& (textLen == 0
|
&& (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 release];
|
||||||
cachedText = [text retain];
|
cachedText = [text retain];
|
||||||
@@ -268,7 +268,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
cachedTextStart = start;
|
cachedTextStart = start;
|
||||||
|
|
||||||
if (visibleRuns)
|
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 currentOverlayStart = 0;
|
||||||
ptrdiff_t currentOverlayEnd = 0;
|
ptrdiff_t currentOverlayEnd = 0;
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ index 71b6d2e..fd7c520 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)
|
||||||
@@ -9248,6 +9364,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
@@ -9296,6 +9412,7 @@ - (void)postCompletionAnnouncementForBuffer:(struct buffer *)b
|
||||||
self.cachedCompletionOverlayEnd = 0;
|
self.cachedCompletionOverlayEnd = 0;
|
||||||
self.cachedCompletionPoint = 0;
|
self.cachedCompletionPoint = 0;
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---- Notification dispatch (main entry point) ---- */
|
/* ---- Notification dispatch (main entry point) ---- */
|
||||||
@@ -9844,6 +9961,10 @@ - (void)dealloc
|
@@ -9892,6 +10009,10 @@ - (void)dealloc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[accessibilityElements release];
|
[accessibilityElements release];
|
||||||
@@ -295,7 +295,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
[[self menu] release];
|
[[self menu] release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
@@ -11293,6 +11414,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
|
@@ -11341,6 +11462,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
|
||||||
|
|
||||||
windowClosing = NO;
|
windowClosing = NO;
|
||||||
processingCompose = NO;
|
processingCompose = NO;
|
||||||
@@ -305,7 +305,7 @@ index 71b6d2e..fd7c520 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;
|
||||||
@@ -12601,6 +12725,80 @@ - (id)accessibilityFocusedUIElement
|
@@ -12649,6 +12773,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. */
|
||||||
@@ -386,7 +386,7 @@ index 71b6d2e..fd7c520 100644
|
|||||||
- (void)postAccessibilityUpdates
|
- (void)postAccessibilityUpdates
|
||||||
{
|
{
|
||||||
NSTRACE ("[EmacsView postAccessibilityUpdates]");
|
NSTRACE ("[EmacsView postAccessibilityUpdates]");
|
||||||
@@ -12611,11 +12809,59 @@ - (void)postAccessibilityUpdates
|
@@ -12659,11 +12857,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
|
||||||
|
|||||||
Reference in New Issue
Block a user