Tk Source Code

View Ticket
Login
Ticket UUID: 3609681
Title: terminal loss of focus involving shortcuts and gitk/wish
Type: Bug Version: current: 8.6.0
Submitter: drizzd Created on: 2013-04-01 09:45:57
Subsystem: 55. [focus] Assigned To: jenglish
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-09-19 11:19:30
Resolution: None Closed By: nobody
    Closed on:
Description:
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?
User Comments: serhiy.storchaka added on 2026-09-19 09:24:38:

Cannot reproduce with current Tk and the ibus XIM server: an xterm keeps receiving keyboard input after wish started from it exits. SCIM is no longer maintained or shipped by distributions.


kbk added on 2015-05-26 03:29:01:
I vaguely recall reading about input methods way back when 8.4 was getting 
ready for deployment.

KHIM, while it has 'input method' in its name, is merely a set of Tk 
keybindings, and has no connection with X input methods. I really don't 
understand them, except that to use them successfully appears to depend on 
several client libraries that we don't link to.

The most approachable discussion of how they work appears to be 
http://menehune.opt.wfu.edu/Kokua/Irix_6.5.21_doc_cd/usr/share/Insight/library/SGI_bookshelves/SGI_Developer/books/XLib_PG/sgi_html/ch11.html - 
and even at that, I have a hard time making sense of it.

I vaguely recall Joe discovering something in how we were handling keyboard
events that accounted for some odd behaviours under SCIM. I don't even 
recall what the outcome of the discussion was.

Kicking it over to Joe in hopes he remembers.

aku added on 2015-05-25 16:49:10:
Back to Kevin.

anonymous added on 2015-05-25 03:56:35:

Mention of SCIM identifies this ticket with [3610493fff].


ferrieux added on 2013-04-01 17:55:30:
Pinging Kevin, I think input methods are in his (numerous) areas of expertise.

drizzd added on 2013-04-01 17:47:17:
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>

drizzd added on 2013-04-01 17:45:40:
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.

drizzd added on 2013-04-01 17:41:34:

File Added - 462152: xscope-noscim.out

drizzd added on 2013-04-01 17:41:05:

File Added - 462151: xscope.out

ferrieux added on 2013-04-01 16:58:00:
Try inserting xscope between wish and the X server; with luck one of the X events or commands will stand out.

Attachments: