Commit Graph

227 Commits

Author SHA1 Message Date
f41fe14772 v13.2: fix protected ivar access (@public for lastAccessibilityCursorRect) 2026-02-26 09:09:09 +01:00
46265bdaa6 v13.2 patch: restore Zoom cursor tracking + fix MRC + fix typing echo
- Restore UAZoomChangeFocus() in ns_draw_window_cursor (was missing in v13)
- Restore accessibilityBoundsForRange: on EmacsView (Zoom queries the view)
- Restore legacy parameterized attribute APIs (Zoom uses these)
- Add lastAccessibilityCursorRect ivar for cursor position tracking
- Fix typing echo: AXTextEditType=3 (not 0), add AXTextChangeValues array
- Keep virtual element tree (EmacsAccessibilityBuffer) for VoiceOver
- MRC fixes: retain/release for accessibilityElements array
2026-02-26 09:03:10 +01:00
e5bfce500f v13 patch: fix MRC retain/release for accessibilityElements array
- arrayWithCapacity: returns autorelease object, must retain for ivar
- Release old array before reassigning in rebuildAccessibilityTree
- Release in EmacsView dealloc
- Fixes crash: _NSPasteboardTypeCache countByEnumeratingWithState (dangling pointer)
2026-02-26 08:52:46 +01:00
e152900004 v13 patch: fix MRC weak property error (unsafe_unretained) 2026-02-26 08:46:34 +01:00
60afee0aec v13 patch: VoiceOver virtual accessibility tree
Complete rewrite of accessibility support. Instead of flat AXTextArea
on EmacsView, implements proper tree with virtual elements:

  EmacsWindow (AXWindow)
  └── EmacsView (AXGroup)
      ├── EmacsAccessibilityBuffer (AXTextArea) — window 1
      ├── EmacsAccessibilityBuffer (AXTextArea) — window 2
      └── ...

Each EmacsAccessibilityBuffer maps to one Emacs window and exposes:
- Buffer text via glyph row iteration (accurate, handles overlays)
- Visual line navigation (glyph_row vpos)
- Cursor tracking with glyph charpos mapping
- Hit testing (accessibilityRangeForPosition:)
- Selection range with active mark
- Screen geometry via pixel coordinate conversion
- Rich typing echo (kAXTextEditTypeTyping userInfo)
- UAZoomChangeFocus for Zoom

Dynamic tree rebuilt on each redisplay cycle from FRAME_ROOT_WINDOW.
Notifications on correct virtual elements (not container view).

3 review cycles (scores: 62 → 68 → 82), plus manual fixes for
hit testing and selection range.
2026-02-25 23:26:59 +01:00
f5ecc44871 revert to v9 patch while deep accessibility rewrite in progress
v10-v12 made VoiceOver worse. Reverting to v9 (Zoom works, typing echo works).
Full accessibility tree implementation in progress.
2026-02-25 22:41:28 +01:00
2c78f04089 v12 patch: visual line numbering for VoiceOver (3 iterations)
Root cause: all accessibility line methods used count_lines (logical/
newline-counting), but VoiceOver compares line numbers before/after
cursor movement. Wrapped lines had same logical line number, so VO
fell back to reading single characters instead of full lines.

Fix: replaced count_lines/find_newline_no_quit with compute_motion/
vmotion (visual screen lines) in all three methods. Matches iTerm2's
approach of returning screen rows.

Changes from v11:
- accessibilityInsertionPointLineNumber: compute_motion visual lines
- accessibilityLineForIndex: compute_motion visual lines
- accessibilityRangeForLine: vmotion for line start/end
- SelectedRowsChanged only on visual line change (new ivar tracking)
- accessibilityLabel returns buffer name for window switch
- No double ValueChanged on edits (content_changed flag)
- Trailing newline stripped from line ranges
- compute_motion width=-1 for consistency with vmotion

3 pipeline iterations, scores: 78 → 92 → 95
2026-02-25 22:13:28 +01:00
2f1fbd30d2 v11 patch: fix VoiceOver cursor movement (iTerm2 pattern)
Key insight from iTerm2 analysis: VoiceOver does NOT need rich userInfo
on SelectedTextChanged for cursor movement. Bare notifications + correct
protocol methods (accessibilityStringForRange:, accessibilityLineForIndex:,
accessibilityRangeForLine:) are sufficient. Rich userInfo with wrong values
was likely causing VoiceOver to silently discard notifications.

Changes from v10:
- SelectedTextChanged: bare notification (removed rich userInfo)
- Added SelectedRowsChanged + SelectedColumnsChanged (iTerm2 triple pattern)
- Added bare ValueChanged on every cursor draw (not just edits)
- Fixed current_buffer safety: BUF_BYTE_ADDRESS, set_buffer_internal_1
- Added accessibilityRangeForIndex:, accessibilitySelectedTextRanges,
  isAccessibilityFocused, accessibilityLabel
2026-02-25 21:42:20 +01:00
54183cc8eb v10 patch: rich SelectedTextChanged for VoiceOver cursor movement
Key changes from v9:
- SelectedTextChanged now includes rich userInfo:
  direction (Next/Previous/Discontiguous) and
  granularity (Character/Word/Line) inferred from
  old vs new cursor position comparison
- Track lastAccessibilityCursorPos + lastAccessibilityCursorLine
  ivars for position delta detection
- accessibilityInsertionPointLineNumber: buffer lines (count_lines)
  instead of visual vpos
- accessibilityLineForIndex: buffer lines via count_lines
- accessibilityRangeForLine: buffer lines via find_newline_no_quit
- Skip notification on unchanged position (avoids VO repeating)
- Word granularity heuristic: same line, >1 char delta
2026-02-25 21:14:08 +01:00
01ea5d1f0a v9 patch: fix macOS 26 SDK compilation error
Replace extern NSString* declarations with raw string literals
(@"AXTextStateChangeType" etc.) to avoid redeclaration type conflict
with NSAccessibilityConstants.h on macOS 26 Tahoe SDK where these
symbols were added to public headers.
2026-02-25 20:49:12 +01:00
5529418b48 v8 patch: full VoiceOver support with typing echo + reviewer fixes
New in v8:
- Rich typing echo via NSAccessibilityPostNotificationWithUserInfo
  with kAXTextEditTypeTyping userInfo (WebKit pattern)
- BUF_MODIFF tracking: content edit -> ValueChanged, cursor move -> SelectedTextChanged only
- Parameterized text navigation: lineForIndex, rangeForLine, frameForRange,
  attributedStringForRange, rangeForPosition (stub)

Reviewer fixes applied:
- Fix multibyte byte_range cap (use buf_charpos_to_bytepos, not hardcoded 10000)
- Fix legacy BoundsForRange to use actual parameter instead of NSMakeRange(0,0)
- Move extern NSString* declarations to file scope

Review score: 82 -> fixes applied.
2026-02-25 20:37:14 +01:00
d0cd1f103b v7 patch: fix Zoom snapping to old window on C-x o
Guard accessibility notifications with on_p && active_p so they only
fire when drawing the cursor in the selected window. Without this,
ns_draw_window_cursor is called for both old and new windows during
redisplay, and UAZoomChangeFocus fires for the old window last.
2026-02-25 20:10:12 +01:00
15a7c927f4 v6 patch: fix VoiceOver double cursor + add typing echo
Fixes:
1. accessibilityFrame now returns view frame (not cursor rect) - fixes
   VoiceOver drawing duplicate cursor overlay
2. Added NSAccessibilityValueChangedNotification - enables VoiceOver
   typing echo (character-by-character feedback when typing)
3. Cursor position exposed only via accessibilityBoundsForRange:

Full VoiceOver text protocol retained (accessibilityValue,
accessibilitySelectedText, accessibilityStringForRange:, etc).
2026-02-25 19:01:25 +01:00
4e34114fc8 v5 patch: full VoiceOver support + Zoom cursor tracking
Added full NSAccessibility text protocol for VoiceOver:
- accessibilityValue (buffer text, capped at 10k chars)
- accessibilitySelectedText (active region)
- accessibilitySelectedTextRange (cursor position)
- accessibilityInsertionPointLineNumber
- accessibilityVisibleCharacterRange
- accessibilityStringForRange:
- accessibilityAttributeValue: delegating to modern methods
Plus legacy parameterized attributes (StringForRange, BoundsForRange).

UAZoomChangeFocus retained for Zoom 'Follow keyboard focus'.
2026-02-25 18:45:48 +01:00
2a58436f32 v4 patch: dual UAZoomChangeFocus + NSAccessibility, with Apple doc refs
UAZoomChangeFocus is Apple's documented API for Zoom focus control.
NSAccessibility serves VoiceOver and other AT tools.
Both are needed - same approach as iTerm2.
References Apple developer documentation URLs in comments.
2026-02-25 18:20:55 +01:00
d7aae4b7d1 v4 patch: UAZoomChangeFocus (Apple documented) + NSAccessibility, with doc refs
Based on verified research:
- UAZoomChangeFocus IS officially documented by Apple (UniversalAccess.h)
- iTerm2 uses UAZoomChangeFocus for Zoom tracking (PTYTextView.m)
- NSAccessibility alone insufficient for Zoom custom view tracking
- Added Apple documentation URLs in code comments
2026-02-25 18:17:53 +01:00
6933d8f9c0 v4 patch: dual mechanism with Apple doc references
UAZoomChangeFocus (documented Apple API) + NSAccessibility.
References to official Apple documentation in comments.
Pattern matches iTerm2 implementation.
2026-02-25 18:11:05 +01:00
f3b8ff661c v3 patch: NSAccessibility-only, drop UAZoomChangeFocus per reviewer feedback 2026-02-25 17:50:04 +01:00
Martin Sukany
8a8e71764d update 2026-02-25 17:09:08 +01:00
a234ded3db Rewrite Zoom a11y patch: NSAccessibility primary, UAZoomChangeFocus supplementary
Key changes:
- Add accessibilityFrame on EmacsView returning cursor screen rect
  (the standard mechanism used by Terminal.app, iTerm2, Firefox)
- Guard UAZoomChangeFocus with bundleIdentifier check (bare binaries
  are silently ignored by the window server)
- Extensive English comments explaining both mechanisms
- Deduplicate legacy parameterized attribute via accessibilityBoundsForRange:

Root cause of Stéphane's failure: UAZoomChangeFocus communicates via the
window server which identifies apps by CFBundleIdentifier. Bare binaries
(src/emacs, symlinks) have no bundle ID and are ignored. NSAccessibility
notifications + accessibilityFrame work for ALL launch methods.
2026-02-25 17:02:40 +01:00
Martin Sukany
365219c4d1 patch updated 2026-02-23 10:55:10 +01:00
87003cac96 fix: use manual y-flip instead of accessibilityConvertScreenRect:
Compilation error: EmacsView does not declare NSAccessibility conformance
so accessibilityConvertScreenRect: is not visible to the compiler.
Replaced with manual coordinate conversion:
  primaryH = NSScreen.screens.first.frame.height
  cgRect.origin.y = primaryH - cgRect.origin.y - cgRect.size.height
2026-02-23 10:28:02 +01:00
5196674d9e fix: UAZoomChangeFocus() — actual fix for macOS Zoom cursor tracking
Root cause found via research pipeline:
NSAccessibility notifications alone are insufficient for custom NSView.
macOS Zoom 'Follow keyboard focus' requires UAZoomChangeFocus() from
HIServices/UniversalAccess.h — same as iTerm2 and Chromium.

Squashed into single clean patch. 159 insertions, 2 files.
2026-02-23 10:22:59 +01:00
56db072f06 fix: add NSAccessibilityPostNotification (key missing piece)
macOS Zoom is event-driven -- it only queries AXBoundsForRange after
receiving NSAccessibilitySelectedTextChangedNotification. Previous
version implemented the bounds methods but never posted notifications,
so Zoom never triggered a cursor position query.

Added:
- NSAccessibilityPostNotification(SelectedTextChanged) in ns_draw_window_cursor
- NSAccessibilityPostNotification(FocusedUIElementChanged) in windowDidBecomeKey
- accessibilityAttributeNames + accessibilityAttributeValue: for
  NSAccessibilitySelectedTextRangeAttribute -> returns {0,0}
2026-02-23 10:03:51 +01:00
12869677e7 fix: correct hunk line count in patch (83→91) 2026-02-23 09:22:51 +01:00
ce46e5b7eb fix: add accessibilityBoundsForRange: (new NSAccessibilityProtocol) + isAccessibilityElement
Old parameterized attribute API alone insufficient — macOS Zoom prefers
the new NSAccessibilityProtocol method accessibilityBoundsForRange:.
Also adds isAccessibilityElement returning YES.

Both APIs now implemented for compatibility across macOS versions.
2026-02-23 09:19:51 +01:00
e6d6fc62fd feat: add NSAccessibility AXBoundsForRange patch for macOS Zoom cursor tracking 2026-02-22 23:31:12 +01:00