Subject: bug#78980: 31.0.50; C-z crashes emacsclient -nw

From: martin rudalics <[email-masked]>
Date: Thu, 10 Jul 2025 10:45:53 +0200

> Maybe one could pack all that in a new function, say
> is_display_optimizable that one would use instead of
> is_tty_root_frame_with_visible_children? For tty frames It could check
> that the frame is not an invisible root, and then check for visible
> chldren.

When I originally wrote the code for GUIs (on X and WINDOWS) I simply
relied on the promise made by the system designers that the window
manager will handle child frames as advertised.  Evaluate the following
forms in a row:

(setq frame1 (selected-frame))
(setq frame2 (make-frame `((parent-frame . ,frame1) (top . 40) (left . 40)
			   (width . 40) (height . 30))))
(setq frame3 (make-frame `((parent-frame . ,frame2) (top . 40) (left . 40)
			   (width . 20) (height . 15))))
(make-frame-invisible frame2)

On each GUI I know of, the last form will make frame3 invisible without
Emacs contributing anything to it.   Making frame2 visible again will
also make frame3 visible.  Making frame3 invisible before making frame2
invisible and making frame2 visible again will leave frame3 invisible.

According to what I read, an exception should be made for modal frames.
Hence if frame3 were a modal frame, it could be visible even if frame2
(or frame1) aren't.  But we do not have an interface for making our own
modal frames so I cannot check this.  Here any modal GUI windows are
likely child windows of the root and behave like popup menus - as long
as they are visible you cannot access any other window.

In either case, this means that the window manager and/or the toolkit
have to keep internally their own copy of the Emacs frame tree and
handle visibility autonomously.  On a TTY we have to (or probably
should) emulate that behavior ourselves.

martin