From 7971f426001c48b035ed1eeb03258e80c6f4fb15 Mon Sep 17 00:00:00 2001 From: Daneel Date: Fri, 27 Feb 2026 12:59:32 +0100 Subject: [PATCH] patches: restore full-line AnnouncementRequested for C-n/C-p --- ...oundsForRange-for-macOS-Zoom-cursor-.patch | 99 ++++++++++++------- 1 file changed, 63 insertions(+), 36 deletions(-) diff --git a/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch b/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch index 6a7f5ca..03ea34f 100644 --- a/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch +++ b/patches/0001-ns-implement-AXBoundsForRange-for-macOS-Zoom-cursor-.patch @@ -1,21 +1,19 @@ -From f58ceb517c9bff049dcc7bf315062f1fa80c85b2 Mon Sep 17 00:00:00 2001 +From 515d3e0cfc42c1c9f907359b1dff379206d940a7 Mon Sep 17 00:00:00 2001 From: Martin Sukany -Date: Fri, 27 Feb 2026 12:49:43 +0100 -Subject: [PATCH] ns: implement VoiceOver accessibility (hybrid notification - strategy) +Date: Fri, 27 Feb 2026 12:59:28 +0100 +Subject: [PATCH] ns: implement VoiceOver accessibility (restore line + announcement fallback) -Notification architecture: -- SelectedTextChanged ALWAYS posted for focused element (interrupts - VoiceOver auto-read, updates braille displays) -- For character moves: omit granularity from userInfo so VoiceOver - cannot derive speech; post AnnouncementRequested with char AT point -- For word/line: include granularity (VoiceOver reads word/line correctly) -- Word granularity: same-line moves > 1 UTF-16 unit (fixes M-f/M-b) -- Non-focused: AnnouncementRequested only (completions) +C-n/C-p need explicit AnnouncementRequested for line text; VoiceOver +processes these differently from arrow keys. Restore full-line +fallback announcement for all line moves (not just completion-string). +SelectedTextChanged(granularity=line) + AnnouncementRequested(line text) +does NOT cause double-speech for lines (same text = VoiceOver deduplicates +or announcement replaces; unlike character moves where the texts differ). --- src/nsterm.h | 109 ++ - src/nsterm.m | 2727 +++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 2687 insertions(+), 149 deletions(-) + src/nsterm.m | 2756 +++++++++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 2716 insertions(+), 149 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index 7c1ee4c..6c95673 100644 @@ -152,7 +150,7 @@ index 7c1ee4c..6c95673 100644 diff --git a/src/nsterm.m b/src/nsterm.m -index 932d209..d33299b 100644 +index 932d209..4288e68 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch) @@ -213,7 +211,7 @@ index 932d209..d33299b 100644 ns_focus (f, NULL, 0); NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; -@@ -6849,219 +6886,2280 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg +@@ -6849,219 +6886,2309 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg /* ========================================================================== @@ -2062,30 +2060,59 @@ index 932d209..d33299b 100644 + } + } + -+ /* For focused line moves: announce line text (or completion -+ candidate for horizontal multi-column layouts). -+ VoiceOver already reads the line via SelectedTextChanged -+ with granularity=line, but for completion-list-mode we need -+ to announce just the candidate, not the whole line. */ ++ /* For focused line moves: always announce line text explicitly. ++ SelectedTextChanged with granularity=line works for arrow ++ keys, but C-n/C-p need the explicit announcement (VoiceOver ++ processes these keystrokes differently from arrows). ++ In completion-list-mode, read the completion candidate ++ instead of the whole line. */ + if (cachedText + && granularity == ns_ax_text_selection_granularity_line) + { ++ NSString *announceText = nil; ++ ++ /* 1. completion--string at point. */ + Lisp_Object cstr + = Fget_char_property (make_fixnum (point), + intern ("completion--string"), Qnil); -+ NSString *compText -+ = ns_ax_completion_string_from_prop (cstr); -+ if (compText) ++ announceText = ns_ax_completion_string_from_prop (cstr); ++ ++ /* 2. Fallback: full line text. */ ++ if (!announceText) + { -+ NSDictionary *annInfo = @{ -+ NSAccessibilityAnnouncementKey: compText, -+ NSAccessibilityPriorityKey: -+ @(NSAccessibilityPriorityHigh) -+ }; -+ NSAccessibilityPostNotificationWithUserInfo ( -+ NSApp, -+ NSAccessibilityAnnouncementRequestedNotification, -+ annInfo); ++ NSUInteger point_idx ++ = [self accessibilityIndexForCharpos:point]; ++ if (point_idx <= [cachedText length]) ++ { ++ NSInteger lineNum ++ = [self accessibilityLineForIndex:point_idx]; ++ NSRange lineRange ++ = [self accessibilityRangeForLine:lineNum]; ++ if (lineRange.location != NSNotFound ++ && lineRange.length > 0 ++ && NSMaxRange (lineRange) <= [cachedText length]) ++ announceText ++ = [cachedText substringWithRange:lineRange]; ++ } ++ } ++ ++ if (announceText) ++ { ++ announceText = [announceText ++ stringByTrimmingCharactersInSet: ++ [NSCharacterSet whitespaceAndNewlineCharacterSet]]; ++ if ([announceText length] > 0) ++ { ++ NSDictionary *annInfo = @{ ++ NSAccessibilityAnnouncementKey: announceText, ++ NSAccessibilityPriorityKey: ++ @(NSAccessibilityPriorityHigh) ++ }; ++ NSAccessibilityPostNotificationWithUserInfo ( ++ NSApp, ++ NSAccessibilityAnnouncementRequestedNotification, ++ annInfo); ++ } + } + } + } @@ -2643,7 +2670,7 @@ index 932d209..d33299b 100644 unsigned fnKeysym = 0; static NSMutableArray *nsEvArray; unsigned int flags = [theEvent modifierFlags]; -@@ -8237,6 +10335,28 @@ - (void)windowDidBecomeKey /* for direct calls */ +@@ -8237,6 +10364,28 @@ - (void)windowDidBecomeKey /* for direct calls */ XSETFRAME (event.frame_or_window, emacsframe); kbd_buffer_store_event (&event); ns_send_appdefined (-1); // Kick main loop @@ -2672,7 +2699,7 @@ index 932d209..d33299b 100644 } -@@ -9474,6 +11594,307 @@ - (int) fullscreenState +@@ -9474,6 +11623,307 @@ - (int) fullscreenState return fs_state; } @@ -2980,7 +3007,7 @@ index 932d209..d33299b 100644 @end /* EmacsView */ -@@ -11303,6 +13724,14 @@ Convert an X font name (XLFD) to an NS font name. +@@ -11303,6 +13753,14 @@ 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");