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

From: Gerd Möllmann <[email-masked]>
Date: Wed, 09 Jul 2025 18:57:45 +0200

martin rudalics <[email-masked]> writes:

>> I find more interesting what redisplay_internal does. The first thing
>> I see is
>>
>> xdisp.c:
>> 17387       /* If this is a window on a tty root frame displaying a child frame,
>> 17388          the current matrix of W may contain glyphs of that child frame.
>> 17389          Don't try shortcuts that might use the current matrix in this case.  */
>> 17390       && !is_tty_root_frame_with_visible_child (XFRAME (w->frame)))
>>
>> Here w->frame can be invisible, apparently. And I wonder if one should
>> check if the root frame of w->frame is visible as a starter. Something
>> like `FRAME_VISIBLE_P (root_frame (XFRAME (w->frame)))` before checking
>> `is_tty_root...`. Because I wonder if that wouldn't be more correct also
>> in the GUI case.
>>
>> And there are potentially more places. I don't see at the moment if
>> that's already done somewhere in redisplay_internal, but maybe we should
>> discard redisplays for invisible frames somewhere further down, too. Or
>> one could first add assert that frames are visible when we display them,
>> e.g. in redisplay_window and so on?
>
> There is one loose end for GUIs: When I have a child frame marked as
> visible, its parent frame is marked as invisible and their root frame is
> marked as visible, then I have no idea whether there exists a window
> manager that expects us to redraw the child frame marked as visible.  At
> least when that child frame corresponds to a modal window.
>
> martin

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.