Tk Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
10:08 Ticket [e02aac5c] Grab documentation does not have caveats for windows & mac status still Open with 3 other changes artifact: 9b948067 user: cjmcdonald
11:31 Ticket [3009450f] Can't deiconify window if a child toplevel is grabbed status still Open with 3 other changes artifact: bc0f1e6e user: beric
10:47 Ticket [3009450f]: 3 changes artifact: 814c97e8 user: danckaert
11:07 Ticket [3009450f]: 6 changes artifact: aa031ade user: oehhar
23:29 Ticket [3009450f]: 3 changes artifact: ca91cebb user: cjmcdonald
07:41 Ticket [3009450f]: 6 changes artifact: 410ed55c user: fvogel
19:28 Ticket [3009450f]: 1 change artifact: bb6e3ba3 user: beric
12:26 New ticket [3009450f]. artifact: 7721eef2 user: beric

Ticket UUID: 3009450
Title: Can't deiconify window if a child toplevel is grabbed
Type: Bug Version: 8.5.8 - 8.6.4
Submitter: beric Created on: 2010-05-31 12:26:35
Subsystem: 56. [grab] Assigned To: patthoyts
Priority: 6 Severity: Minor
Status: Open Last Modified: 2016-02-18 11:31:35
Resolution: None Closed By: nobody
    Closed on:
Under windows, if a child toplevel has a grab and is transient, you can not deiconify the application.

# Better example than words:
package require Tk
toplevel .t
wm transient .t .
grab .t

# Now, click on "Show desktop" button
# You will not be able to deiconify the application

Bug introduced by resulotion of #1847002 ?
User Comments: beric added on 2016-02-18 11:31:35:
Your workaround is excellent!
In fact, it fixes the problem and gives user feedback, but also is easy to use.


danckaert added on 2016-02-18 10:47:50:
I have also hit this bug, and found a workaround by disabling the main window after the the grab:
  grab .t
  wm attributes . -disabled 1

And when releasing the grab:
  grab release .t
  wm attributes . -disabled 0

This also gives a better user experience on Windows: the transient window flickers when you click on the main window.

oehhar added on 2016-02-12 11:07:37:

Indeed, anoying bug and present in tcl 8.5.18 and 8.6.4 Great workaround! I have put it on the wiki:

Nevertheless would not mind that this is corrected. Couln't this binding be added for all transient windows (on MS-windows) by default ?

Here is the test description:

Having a transient toplevel window:

toplevel .c
wm transient .c .
pack [entry .c.e]
grab .c
and then press the "iconify all" button in the windows 10 taskbar or press "Windows-Key + d" in WIndows Vista to Windows 10. It is not possible to restore the application, as only the main window (.) is in the taskbar, but restoring it fails.

It is necessary, that the window is transient. Otherwise, it may be restored by its own icon in the task bar.

cjmcdonald added on 2016-02-11 23:29:55:

Don't you think it's strange that this workaround is necessary to avoid such a simple example locking up, just because the user clicks on the "Show Desktop" taskbar button? Any tk app with a modal dialog is vulnerable to this.

See also tickets #2896605 and #3414089.

I think that #1847002 was ill-advised. It's caused more problems than it solved; it's introduced an unexpected and unsafe linkage between the grab state and toplevel deiconify and raise; and it's increased inconsistency in behaviour between windows & unix. I never found the issue that #1847002 aimed to solve to be a big problem (if I'm understanding it correctly).

fvogel added on 2016-02-11 07:41:06:
The OP states in clt that he uses the following workaround on his dialog library, which temporarily ungrab the toplevel:

    bind Dialog <Unmap> {
        if {[grab current] eq "%W"} {
            grab release %W
            bind %W <Map> [subst {
                bind %W <Map> {}
                grab set %W
                catch { focus -force [focus -lastfor %W] }

See the thread:!topic/comp.lang.tcl/YA2OWAgWzV8