I recently reported this to gnome: https://bugzilla.gnome.org/show_bug.cgi?id=695561 . In some circumstances, when wish exits, keyboard events are no longer received/processed in the terminal window from which wish was started. (I described this as a "loss of focus", but I am not sure if window focus is the issue.)
In gnome-shell, I can only reproduce with the wish application gitk. If I try to simplify gitk, the issue appears only sporadically (e.g. once in 10 times).
But in fallback mode (gsettings set org.gnome.desktop.session
session-name 'gnome-fallback') it can be reproduced easily and reliably by doing either one of:
echo 'after idle { exit }' | wish
echo 'bind . <Control-q> { exit }' | wish
I failed to reproduce this with a small program doing XOpenDisplay, XCreateSimpleWIndow, XSelectInput, XMapWindow, XNextEvent, XCloseDisplay. What might Tk be doing differently?
Try inserting xscope between wish and the X server; with luck one of the X events or commands will stand out.
xscope output with SCIM
xcope output without SCIM (good case)
Indeed there are some suspicious events which appear to be related to scim (my X input method daemon). If I turn off scim in the calling terminal (unset XMODIFIERS; xterm), the problem goes away.
I have attacked xscope output both with and without scim.
Here is one such message:
0.01: Client --> 24 bytes
............REQUEST: ConvertSelection
requestor: WIN 04c00001
selection: <@server=SCIM>
target: <LOCALES>
property: <LOCALES>
time: CurrentTime
0.01: 32 bytes <-- X11 Server
..............EVENT: **INVALID** (159)
time: CurrentTime
requestor: WIN 04c00001
selection: <@server=SCIM>
target: <LOCALES>
property: <LOCALES>
Pinging Kevin, I think input methods are in his (numerous) areas of expertise.