Subject: 26.0.91; Wrong AXSubrole of childframe on macOS
From: Fu Yuan <[email-masked]>
To: [email-masked]
Date: Mon, 30 Apr 2018 19:46:55 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

In GNU Emacs 26.0.91 (build 1, x86_64-apple-darwin17.4.0, NS appkit-1561.20 Version 10.13.3 (Build 17D102))
of 2018-02-26 built on missSilver
Windowing system distributor 'Apple', version 10.3.1561
Recent messages:
#<frame *scratch* 0x10181c5b0
Mark set
#<frame *Minibuf-1* 0x10181c5b0
You can run the command ‘eval-last-sexp’ with C-x C-e
#<frame *Minibuf-1* 0x10181c5b0
#<frame *scratch* 0x10181c5b0
Making completion list...
next-line: End of buffer
user-error: End of history; no default available
Making completion list...

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs-plus/26.0.91/share/info/emacs
--prefix=/usr/local/Cellar/emacs-plus/26.0.91 --with-xml2
--without-dbus --with-gnutls --with-imagemagick --with-modules
--with-rsvg --with-ns --disable-ns-self-contained'

Configured features:
JPEG RSVG IMAGEMAGICK NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS MODULES

Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LC_CTYPE: UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils thingatpt elec-pair
time-date tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 205417 11756)
(symbols 48 20204 1)
(miscs 40 54 222)
(strings 32 29199 1739)
(string-bytes 1 771193)
(vectors 16 35217)
(vector-slots 8 718818 13304)
(floats 8 53 283)
(intervals 56 290 38)
(buffers 992 12))

* Symptom

On macOS, the AXSubrole of a childframe is set to AXStandardWindow. This
setting causes other applications on the same machine to possible
interfere Emacs. For example, a windows manager will reposition the
childframe, as descussed here:
https://github.com/emacs-lsp/lsp-ui/issues/107#issuecomment-385377352

In the discussion, koekeishiya suggested to set the attribute to
kAXDialogSubrole or kAXFloatingWindowSubrole.

* Reproduce

- Open Emacs with emacs -Q
- insert
(let ((frame (selected-frame)))
(make-frame-command)
(set-frame-parameter nil :parent-frame frame))

- Use UIElementInspecter
(https://developer.apple.com/library/content/samplecode/UIElementInspector/UIElementInspector.zip)
to inspect the newly created childframe

- The AXSubrole row shows AXStandardWindow.

Sincerely, Yuan.