ax: fix VoiceOver cursor sync and word double-read

Bug 1 (VO cursor not following Emacs cursor):
- Remove FocusedUIElementChangedNotification on emacsView (was a no-op:
  VO re-queried the same element)
- For Emacs-initiated char/word moves, keep natural next/previous
  direction instead of forcing discontiguous; SelectedTextChanged with
  direction=next advances VO browse cursor sequentially
- Only force discontiguous for line-boundary crossings and large jumps

Bug 2 (word double-read with punctuation):
- Root cause was FocusedUIElementChanged causing VO re-anchor speech
  on top of the explicit word announcement
- Removing FocusedUIElementChanged eliminates the duplicate speech
- Add emacsInitiated parameter to postFocusedCursorNotification;
  omit AXTextSelectionGranularity for Emacs-initiated moves so VO
  does not auto-speak (only explicit announcements provide speech)
- isWordMove now triggers on emacsInitiated flag (Emacs-initiated
  word moves always get explicit announcement)
This commit is contained in:
2026-03-02 12:38:40 +01:00
parent 53ea58725e
commit bc5714b7b7
9 changed files with 124 additions and 118 deletions

View File

@@ -1,4 +1,4 @@
From 1ecb71555d3419523d8ccebc03ace9bffac4f99e Mon Sep 17 00:00:00 2001
From efe1a90a98dc725ea55bda0fa466427b39cdd253 Mon Sep 17 00:00:00 2001
From: Martin Sukany <martin@sukany.cz>
Date: Sat, 28 Feb 2026 12:58:11 +0100
Subject: [PATCH 1/8] ns: add accessibility base classes and text extraction
@@ -29,11 +29,11 @@ ns-accessibility-enabled with corrected doc: initial value is nil,
set non-nil automatically when an AT is detected at startup.
---
src/nsterm.h | 131 +++++++++++++++
src/nsterm.m | 456 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/nsterm.m | 452 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 583 insertions(+)
diff --git a/src/nsterm.h b/src/nsterm.h
index ea6e7ba..5746e9e 100644
index ea6e7ba4f5..5746e9e9bd 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -453,6 +453,124 @@ enum ns_return_frame_mode
@@ -189,7 +189,7 @@ index ea6e7ba..5746e9e 100644
diff --git a/src/nsterm.m b/src/nsterm.m
index fc75910..852e7f9 100644
index 417c312a88..a1cece7c23 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch)
@@ -200,7 +200,7 @@ index fc75910..852e7f9 100644
#include "systime.h"
#include "character.h"
#include "xwidget.h"
@@ -7209,6 +7210,430 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
@@ -7200,6 +7201,430 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
}
#endif
@@ -631,7 +631,7 @@ index fc75910..852e7f9 100644
/* ==========================================================================
EmacsView implementation
@@ -11665,6 +12090,24 @@ Convert an X font name (XLFD) to an NS font name.
@@ -11656,6 +12081,24 @@ Convert an X font name (XLFD) to an NS font name.
DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic");
DEFSYM (Qns_handle_drag_motion, "ns-handle-drag-motion");
@@ -656,7 +656,7 @@ index fc75910..852e7f9 100644
Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier));
Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));
Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier));
@@ -11813,6 +12260,15 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
@@ -11804,6 +12247,15 @@ Nil means use fullscreen the old (< 10.7) way. The old way works better with
This variable is ignored on Mac OS X < 10.7 and GNUstep. */);
ns_use_srgb_colorspace = YES;