patches: fix C-n/C-p VoiceOver regression - exclude isCtrlNP from re-anchor

When Emacs moves the cursor (emacsMovedCursor=YES), we post
FocusedUIElementChanged on the NSWindow to re-anchor VoiceOver's
browse cursor.  For C-n/C-p this notification races with
AXSelectedTextChanged(granularity=line) and causes VoiceOver to
drop the line-read speech.

Arrow key movement works because VoiceOver intercepts those as AX
selection changes (setAccessibilitySelectedTextRange:), making
voiceoverSetPoint=YES and emacsMovedCursor=NO, so no
FocusedUIElementChanged is posted.

Fix: skip FocusedUIElementChanged for sequential C-n/C-p moves
(isCtrlNP).  AXSelectedTextChanged with direction=next/previous +
granularity=line is sufficient for VoiceOver to read the new line.
FocusedUIElementChanged is only needed for discontiguous jumps
(]], M-<, isearch, xref etc.) where VoiceOver must re-anchor.

Also merge duplicate comment blocks and fix two compile errors
from a64d24c that Martin caught during testing.
This commit is contained in:
2026-03-02 20:48:57 +01:00
parent a64d24cbd9
commit 7a0b4f6cf2
9 changed files with 84 additions and 92 deletions

View File

@@ -1,4 +1,4 @@
From dd8b0911c8a690aa7110b881b6a88977e2fc67f1 Mon Sep 17 00:00:00 2001
From 8c99359156443223d13905de4cfbca58fb3e1177 Mon Sep 17 00:00:00 2001
From: Daneel <daneel@sukany.cz>
Date: Mon, 2 Mar 2026 18:39:46 +0100
Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver
@@ -34,7 +34,7 @@ index 5746e9e9bd..21a93bc799 100644
@property (nonatomic, assign) BOOL cachedMarkActive;
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
diff --git a/src/nsterm.m b/src/nsterm.m
index 8a1bfd9eb1..523f79d235 100644
index a0598a73c2..3d8a5dd0fc 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7263,11 +7263,154 @@ Accessibility virtual elements (macOS / Cocoa only)
@@ -465,7 +465,7 @@ index 8a1bfd9eb1..523f79d235 100644
{
ptrdiff_t oldPoint = self.cachedPoint;
BOOL oldMarkActive = self.cachedMarkActive;
@@ -12358,7 +12604,7 @@ - (int) fullscreenState
@@ -12402,7 +12648,7 @@ - (int) fullscreenState
if (WINDOW_LEAF_P (w))
{
@@ -474,7 +474,7 @@ index 8a1bfd9eb1..523f79d235 100644
EmacsAccessibilityBuffer *elem
= [existing objectForKey:[NSValue valueWithPointer:w]];
if (!elem)
@@ -12392,7 +12638,7 @@ - (int) fullscreenState
@@ -12436,7 +12682,7 @@ - (int) fullscreenState
}
else
{
@@ -483,7 +483,7 @@ index 8a1bfd9eb1..523f79d235 100644
Lisp_Object child = w->contents;
while (!NILP (child))
{
@@ -12504,7 +12750,7 @@ - (void)postAccessibilityUpdates
@@ -12548,7 +12794,7 @@ - (void)postAccessibilityUpdates
accessibilityUpdating = YES;
/* Detect window tree change (split, delete, new buffer). Compare
@@ -492,7 +492,7 @@ index 8a1bfd9eb1..523f79d235 100644
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
if (!EQ (curRoot, lastRootWindow))
{
@@ -12513,12 +12759,12 @@ - (void)postAccessibilityUpdates
@@ -12557,12 +12803,12 @@ - (void)postAccessibilityUpdates
}
/* If tree is stale, rebuild FIRST so we don't iterate freed