Subject: [PATCH] NS: Correct the accessibility role of Emacs windows
From: Rudolf Adamkovič <[email-masked]>
To: [email-masked]
Date: Mon, 17 Mar 2025 02:55:05 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

See the commit message in the patch.

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.3.0, NS
 appkit-2575.40 Version 15.3.1 (Build 24D70)) of 2025-03-17 built on
 skynet.local
Repository revision: eab14d68b2e72b9a6b8b0cc67c9667c2bfbed4f5
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.3.1

Configured using:
 'configure --with-json --with-tree-sitter --with-sqlite3
 --with-native-compilation=aot'

From a8cb24f9069de15b1ac5a31ee85079fbc4376ed9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <[email-masked]>
Date: Mon, 17 Mar 2025 02:25:21 +0100
Subject: [PATCH] NS: Correct the accessibility role of Emacs windows

* src/nsterm.m: ([EmacsWindow accessibilityAttributeValue:]): Make the
accessibility role of Emacs windows to be "standard window" (AXWindow)
instead of "text field" (AXTextField).  This matches other applications
on NS, as can be verified with any accessibility inspector.  All widely
used NS ports, such as Emacs Plus, have this patch already applied. As
for practical impact, this change makes Emacs, for example, work with
tiling window managers, such as Yabai, where many users report problems
with Emacs specifically, and are instructed to simply avoid the official
NS port of GNU Emacs due to this problem.
---
 src/nsterm.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 46bb3f5dd7a..45526d96910 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -9722,7 +9722,7 @@ - (id)accessibilityAttributeValue:(NSString *)attribute
   NSTRACE ("[EmacsWindow accessibilityAttributeValue:]");
 
   if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
-    return NSAccessibilityTextFieldRole;
+    return NSAccessibilityWindowRole;
 
   if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]
       && curbuf && ! NILP (BVAR (curbuf, mark_active)))
-- 
2.39.5 (Apple Git-154)

-- 
"Chop your own wood and it will warm you twice."
--- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič <[email-masked]> [he/him]
http://adamkovic.org