GNU bug report logs - #31324
26.0.91; Wrong AXSubrole of childframe on macOS

Previous Next

Package: emacs;

Reported by: Fu Yuan <casouri <at> gmail.com>

Date: Mon, 30 Apr 2018 23:55:01 UTC

Severity: normal

Found in version 26.0.91

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31324 in the body.
You can then email your comments to 31324 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Mon, 30 Apr 2018 23:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Fu Yuan <casouri <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 30 Apr 2018 23:55:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Fu Yuan <casouri <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Mon, 30 Apr 2018 19:46:55 -0400
[Message part 1 (text/plain, inline)]
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.
[Message part 2 (text/html, inline)]
[Screen Shot 2018-04-30 at 7.07.10 PM.png (image/png, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Tue, 01 May 2018 20:39:01 GMT) Full text and rfc822 format available.

Message #8 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Fu Yuan <casouri <at> gmail.com>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Tue, 1 May 2018 21:37:58 +0100
On Mon, Apr 30, 2018 at 07:46:55PM -0400, Fu Yuan wrote:
> 
> * 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.

Unfortunately those are Carbon attributes and I don’t think we can (or
want to) set them directly.

It looks like the nearest equivalent is the NSWindow level attribute,
which we’re using for z‐groups.

Can you please try the following:

    (let ((frame (selected-frame)))
      (make-frame-command)
      (set-frame-parameter nil 'parent-frame frame)
      (set-frame-parameter nil 'z-group 'above))

and see what the UIElementInspector returns? (I can’t build it as I
don’t have xcode installed.)

If you’re able you could try applying this patch:

1 file changed, 1 insertion(+), 1 deletion(-)
src/nsterm.m | 2 +-

modified   src/nsterm.m
@@ -2028,7 +2028,7 @@ so some key presses (TAB) are swallowed by the system. */
     }
   else if (EQ (new_value, Qabove))
     {
-      window.level = NSNormalWindowLevel + 1;
+      window.level = NSFloatingWindowLevel;
       FRAME_Z_GROUP (f) = z_group_above;
     }
   else if (EQ (new_value, Qabove_suspended))

and run the lisp above again and see if it’s different.

-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Sun, 13 May 2018 10:15:01 GMT) Full text and rfc822 format available.

Message #11 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Fu Yuan <casouri <at> gmail.com>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Sun, 13 May 2018 11:14:02 +0100
[Message part 1 (text/plain, inline)]
Please keep the bug tracker Cc’d in.

On Fri, May 11, 2018 at 09:31:14PM +0800, Fu Yuan wrote:
> I first ran the lisp code and nothing changed. Then I patched source
> file and compiled, then ran the lisp code on the compiled emacs.
> Nothing different on that Emacs. The UIElementInspecter shows
> AXStandardWindow. Of course both time I used “emacs" command with
> “-Q" flag.
> 
> Is there anything else I can do?

OK, I looked into this a bit further and it seems this stuff is in the
accessibility API. I’ve attached a couple of patches, please apply
‘fix redefinition of child frames on NS’, then ‘Set accessibility
subroles for child frame’ and see if it does what you expect.

This will only work on macOS >= 10.10. I think there must be another
way of doing it on older versions but I haven’t found it yet. I’ll see
if this works before digging any more.
-- 
Alan Third
[0001-Fix-redefinition-of-child-frames-on-NS.patch (text/plain, attachment)]
[0001-Set-accessibility-subroles-for-child-frame-bug-31324.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Sun, 13 May 2018 10:34:02 GMT) Full text and rfc822 format available.

Message #14 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Fu Yuan <casouri <at> gmail.com>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Sun, 13 May 2018 11:33:41 +0100
On Sun, May 13, 2018 at 06:17:10PM +0800, Fu Yuan wrote:
> Hi Alan,
> 
> Where should I get the Emacs source files?
> I was getting those from emacs mirror on GitHub master branch.
> Last time I manually edited your fix and noticed that line numbers doesn’t match.
> So I guess you are not using HEAD version to create those patches.
> 
> What version or commit or branch should I use?

The easiest way is to use git to get the emacs-26 branch, either from
savannah or emacs mirror. Then apply the patches using:

    git am <patch‐file‐name>

This applies the patch as a commit in git.
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Sun, 13 May 2018 21:55:02 GMT) Full text and rfc822 format available.

Message #17 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Fu Yuan <casouri <at> gmail.com>
To: Alan Third <alan <at> idiocy.org>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Sun, 13 May 2018 18:17:10 +0800
[Message part 1 (text/plain, inline)]
Hi Alan,

Where should I get the Emacs source files?
I was getting those from emacs mirror on GitHub master branch.
Last time I manually edited your fix and noticed that line numbers doesn’t match.
So I guess you are not using HEAD version to create those patches.

What version or commit or branch should I use?
Thanks.

Sincerely, Yuan.

On May 13, 2018, 6:14 PM +0800, Alan Third <alan <at> idiocy.org>, wrote:
> Please keep the bug tracker Cc’d in.
>
> On Fri, May 11, 2018 at 09:31:14PM +0800, Fu Yuan wrote:
> > I first ran the lisp code and nothing changed. Then I patched source
> > file and compiled, then ran the lisp code on the compiled emacs.
> > Nothing different on that Emacs. The UIElementInspecter shows
> > AXStandardWindow. Of course both time I used “emacs" command with
> > “-Q" flag.
> >
> > Is there anything else I can do?
>
> OK, I looked into this a bit further and it seems this stuff is in the
> accessibility API. I’ve attached a couple of patches, please apply
> ‘fix redefinition of child frames on NS’, then ‘Set accessibility
> subroles for child frame’ and see if it does what you expect.
>
> This will only work on macOS >= 10.10. I think there must be another
> way of doing it on older versions but I haven’t found it yet. I’ll see
> if this works before digging any more.
> --
> Alan Third
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Sun, 20 May 2018 10:12:01 GMT) Full text and rfc822 format available.

Message #20 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Fu Yuan <casouri <at> gmail.com>
To: Alan Third <alan <at> idiocy.org>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Sun, 20 May 2018 14:33:28 +0800
[Message part 1 (text/plain, inline)]
Hi Alan,

I applied the patch and rebuilt Emacs, then ran

    (let ((frame (selected-frame)))
      (make-frame-command)
      (set-frame-parameter nil 'parent-frame frame))

And the subrole of the new frame is now “AXFloatingWindow”.

I think that will do it. It there anything else that I can do?

Sincerely, Yuan.

On May 13, 2018, 6:33 PM +0800, Alan Third <alan <at> idiocy.org>, wrote:
> On Sun, May 13, 2018 at 06:17:10PM +0800, Fu Yuan wrote:
> > Hi Alan,
> >
> > Where should I get the Emacs source files?
> > I was getting those from emacs mirror on GitHub master branch.
> > Last time I manually edited your fix and noticed that line numbers doesn’t match.
> > So I guess you are not using HEAD version to create those patches.
> >
> > What version or commit or branch should I use?
>
> The easiest way is to use git to get the emacs-26 branch, either from
> savannah or emacs mirror. Then apply the patches using:
>
> git am <patch‐file‐name
>
> This applies the patch as a commit in git.
> --
> Alan Third
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Sun, 20 May 2018 11:46:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Tue, 22 May 2018 19:41:02 GMT) Full text and rfc822 format available.

Message #26 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Fu Yuan <casouri <at> gmail.com>
Cc: 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Tue, 22 May 2018 20:40:02 +0100
On Sun, May 20, 2018 at 02:33:28PM +0800, Fu Yuan wrote:
> Hi Alan,
> 
> I applied the patch and rebuilt Emacs, then ran
> 
>     (let ((frame (selected-frame)))
>       (make-frame-command)
>       (set-frame-parameter nil 'parent-frame frame))
> 
> And the subrole of the new frame is now “AXFloatingWindow”.
> 
> I think that will do it. It there anything else that I can do?

Thanks for your help. The only thing that would be helpful for now is
if you could run with this patch applied for a while and look out for
anything unexpected. I don’t think it will cause problems, but you
never know!

Unfortunately, I think this will have to wait until Emacs 26.2.

Eli, should it be added to master then cherry‐picked back to emacs-26
when we’re ready, or am I best just waiting?
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31324; Package emacs. (Wed, 23 May 2018 02:28:01 GMT) Full text and rfc822 format available.

Message #29 received at 31324 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Third <alan <at> idiocy.org>
Cc: casouri <at> gmail.com, 31324 <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Wed, 23 May 2018 05:27:17 +0300
> Date: Tue, 22 May 2018 20:40:02 +0100
> From: Alan Third <alan <at> idiocy.org>
> Cc: 31324 <at> debbugs.gnu.org
> 
> Unfortunately, I think this will have to wait until Emacs 26.2.
> 
> Eli, should it be added to master then cherry‐picked back to emacs-26
> when we’re ready, or am I best just waiting?

It's up to you, but my recommendation is to commit to master now, and
then cherry-pick after Emacs 26.1 is released (which should be very
soon).




Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Sun, 03 Jun 2018 19:37:02 GMT) Full text and rfc822 format available.

Notification sent to Fu Yuan <casouri <at> gmail.com>:
bug acknowledged by developer. (Sun, 03 Jun 2018 19:37:03 GMT) Full text and rfc822 format available.

Message #34 received at 31324-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 31324-done <at> debbugs.gnu.org
Subject: Re: bug#31324: 26.0.91; Wrong AXSubrole of childframe on macOS
Date: Sun, 03 Jun 2018 20:35:57 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Tue, 22 May 2018 20:40:02 +0100
>> From: Alan Third <alan <at> idiocy.org>
>> Cc: 31324 <at> debbugs.gnu.org
>> 
>> Unfortunately, I think this will have to wait until Emacs 26.2.
>> 
>> Eli, should it be added to master then cherry‐picked back to emacs-26
>> when we’re ready, or am I best just waiting?
>
> It's up to you, but my recommendation is to commit to master now, and
> then cherry-pick after Emacs 26.1 is released (which should be very
> soon).

I ended up just leaving this for ages, so I've pushed it to emacs-26 now.
-- 
Alan Third




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 02 Jul 2018 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 356 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.