Subject: 28.0.50; C-g leaves inactive minibuffer selected with pop-up-frames

From: "Basil L. Contovounesios" <[email-masked]>
Date: Tue, 04 May 2021 16:43:17 +0100

With the tiling WM Xmonad (regardless of Lucid/GTK2/GTK3/PGTK toolkit),
in which new Emacs frames always receive focus by default:

0. emacs -Q
1. M-: (setq pop-up-frames 'graphic-only) RET
2. M-x TAB

This pops up and gives focus to a new frame with the *Completions*
buffer:

Ignore the missing scrollbar; that's a separate long-standing issue ;).

3. q

As part of another long-standing issue on Xmonad (I guess because it
doesn't really do invisibility/minimisation/what-have-you), this
actually retains the *Completions* frame (which is still highlighted as
focused by the WM), but now neither frame looks "active" (all three
visible cursors are hollow):

4. Close the *Completions* frame.  In Xmonad that's Mod-Shift-c by
   default.

The minibuffer of the original frame is now selected:

5. C-g

This leaves the inactive minibuffer selected:

I think this inconsistent state might be the cause of or related to some
harder-to-reproduce "attempted to do X in sole/inactive
(mini)buffer/window" (or something like that) errors down the line with
Ivy minibuffer completion.  They happen seemingly at random when exiting
the minibuffer, perhaps multiple times an hour in a busy editing
session.  Once a frame reaches this inactive-but-selected minibuffer
state, subsequent minibuffer sessions are often problematic, so my
workaround is to simply delete that frame and hope it doesn't reoccur
for a while.  One thing that feels like it reduced the frequency of
these issues was disabling winner-mode and using {next,previous}-buffer
instead, FWIW.

This has been happening for a while now, I guess since the recent
overhaul of minibuffer behaviour (which is why I'm CCing Alan).

OTOH I can reliably reproduce the narrower issue in this report, so let
me know if you'd like me to test anything.

Thanks,

-- 
Basil

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2021-05-04 built on tia
Repository revision: b8f88d76ea79b12d600a090f76cea9d6ec3818f2
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux bullseye/sid

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
graphic-only
Making completion list...
Quit

Configured using:
 'configure 'CC=ccache gcc' 'CFLAGS=-O2 -march=native' --config-cache
 --prefix=/home/blc/.local --enable-checking=structs
 --with-x-toolkit=lucid --with-file-notification=yes --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: InactiveMinibuffer

Minor modes in effect:
  tooltip-mode: t
  global-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
  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 dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer 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
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 79371 6927)
 (symbols 48 6593 1)
 (strings 32 19873 1765)
 (string-bytes 1 631488)
 (vectors 16 12627)
 (vector-slots 8 182958 8008)
 (floats 8 31 41)
 (intervals 56 10451 4)
 (buffers 992 11))