Subject: Re: bug#71343: 30.0.50; TTY frame doesn't automatically redisplay itself after having closed another frame

From: Eli Zaretskii <[email-masked]>
Date: Thu, 06 Jun 2024 14:54:02 +0300

> From: Daniel Clemente <[email-masked]>
> Date: Mon, 3 Jun 2024 15:33:16 +0000
> 
> This happens since I started using TTY emacs (with no X support)
> around 2 months ago. It's easy to reproduce but it may have something
> to do with my terminal or window manager.
> 
> The problem is that Emacs doesn't redisplay in one particular case.
> It's just a minor annoyance because I can just press a key or move the
> mouse and the frame will redisplay. But it may hint at some other bug
> that could be worthy of fixing.
> 
> 
> I can consistently do this to reproduce it:
> 
> 1. Launch emacs --daemon -Q
> 2. Using my tiling window manager "wmii", I divide the screen in a
> left part and a right part. Each one has other non-Emacs windows
> 3. In the left side, I press a key to launch a terminal with TTY
> emacs. I use a command like this: urxvtcd -e emacsclient -c &
> 4. I move focus to the right side, I launch another
> terminal+emacsclient with the same command
> 5. Sanity check; verifying that everything works: I move to the left
> terminal and press wmii keys to make the terminal wider or thinner. It
> works as expected, it redisplays; Emacs uses all available space
> inside the X window
> 6. Now I go to the right side. I press a key to kill the terminal
> running emacsclient. Now only the terminal in the left side remains
> 7. I move to the left side (pressing a wmii key) and I press the wmii
> keys to make the terminal wider or thinner (same as step 5). wmii
> obeys, the X windows change size as expected.
> 8. However, the Emacs TTY frame isn't redisplayed: if I made it wider,
> the new area at the right of the frame is shown in black (it sometimes
> shows garbage from previous attempts). The mode line doesn't extend to
> the right. If I make it thinner, the text isn't readjusted to the new
> line length. Etc. The cursor keeps blinking.
> 9. I can keep circulating through other X windows and come back to
> this X window, and try to resize it again. It still doesn't redisplay.
> Pressing Ctrl also doesn't redisplay it
> 10. Only when I press a non-modifier key (e.g. right arrow) or I move
> the mouse, it redisplays and starts using the whole X window
> 
> 
> Note that step 6 is essential. This issue only appears immediately
> after having killed another emacslient. It doesn't happen e.g. after
> killing another type of X window. Or after having shuffled the X
> windows (moving the terminal around, left/right, without killing it).
> It's just after killing a frame.

I'm not sure this is a bug.  Emacs switches to reading input from a
different terminal/keyboard when there's actually some input from that
terminal's keyboard.  In the situation you described, the terminal
whose keyboard was active was killed.  I'm guessing we get SIGHUP in
this case, so we could do something about it, but what exactly should
we do?  Since no other keyboard provided any input, to which keyboard
to switch, and why?

So I think we should not change this behavior, since the "workaround"
is so easy.

Paul, any other ideas or comments?