#1877 wm transient broken

obsolete: 8.4.9
Kyle Bateman

In tk 8.3.5, the "wm transient" command made a window
so it always stayed on top of its parent. In addition,
my window manager is configured to not put a title bar
on a transient window.

In Fedora 3, I am using tk 8.4.7 and my test window
does not seem to be getting marked as transient. It
doesn't stay on top of its parent and its title bar is
no longer suppressed.

I'm enclosing a test script. Just run the script and
then move the "." window to the same part of the screen
as the "HI" window. As I understand it, the "HI" window
should always stay on top of the "." window.


  • Kyle Bateman
    Kyle Bateman

    Test case

  • Joe English
    Joe English

    • milestone: 420075 --> obsolete: 8.4.9
  • Joe English
    Joe English

    • priority: 5 --> 3
  • Joe English
    Joe English

    Logged In: YES

    This looks like a race condition -- [wm transient .t .] is
    being called before the main toplevel "." has been mapped.
    If you run the script from an interactive wish (after "."
    has been mapped), or run "tkwait visibility ." before
    creating .t, or anything else that ensures "." is mapped,
    you'll get the expected behavior.

    With that information, are you able to find a workaround in
    your application?

    This is related to changes made in 2002:

    2002-05-27 (feature change) [wm transient .t .t] now raises
    an error (dejong)

    2002-06-12 (feature change) A transient toplevel now mirrors
    state changes
    in the master. (dejong)

    See also CVS log entries for tkUnixWm.c r1.21 and r1.20.

    Changing back to the 8.3 behavior would reintroduce whatever
    problems the original changes were intended to fix.

  • Jeffrey Hobbs
    Jeffrey Hobbs

    Logged In: YES

    Mo should comment on this.

  • Jeffrey Hobbs
    Jeffrey Hobbs

    • assigned_to: jenglish --> stwo
  • Logged In: NO

    I can confirm that if I get the parent window to map before
    creating the transients, that solves the problem. In my
    particular case, this is a suitable workaround. Thanks for
    the info--that helped.

    Seems like it would still be nice to make this work right if
    a solution is achievable. For example, I notice that even
    if I do:

    after idle "wm transient ..."

    Seemed like in order to get it to work, I had to do an
    actual "update" before creating the child windows.

  • Kyle Bateman
    Kyle Bateman

    Logged In: YES

    Yup, that last post was from me, I just wasn't logged in.

  • Pat Thoyts
    Pat Thoyts

    The following patch would appear to be sufficient.

    Index: unix/tkUnixWm.c

    RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixWm.c,v
    retrieving revision 1.77
    diff -u -p -r1.77 tkUnixWm.c
    --- unix/tkUnixWm.c 9 Dec 2009 13:55:14 -0000 1.77
    +++ unix/tkUnixWm.c 5 Jan 2010 01:49:43 -0000
    @@ -676,11 +676,10 @@ TkWmMapWindow(
    if (!Tk_IsMapped(wmPtr->masterPtr)) {
    wmPtr->withdrawn = 1;
    wmPtr->hints.initial_state = WithdrawnState;
    - } else {
    - XSetTransientForHint(winPtr->display,
    - wmPtr->wrapperPtr->window,
    - wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window);
    + XSetTransientForHint(winPtr->display,
    + wmPtr->wrapperPtr->window,
    + wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window);

    wmPtr->flags |= WM_UPDATE_SIZE_HINTS;

  • Verified that this does indeed fix things. Fixed in HEAD

    Test used to check follows:
    test wm-transient-8.1 {transient to withdrawn window, Bug 1163496} -setup {
    set result {}
    } -body {
    # Verifies that transients stay on top of their masters, even if they were
    # made transients when those masters were withdrawn.
    toplevel .t1; wm withdraw .t1; update
    toplevel .t2; wm transient .t2 .t1; update
    lappend result [winfo ismapped .t1] [winfo ismapped .t2]
    wm deiconify .t1; update
    lappend result [winfo ismapped .t1] [winfo ismapped .t2]
    raise .t1; update
    lappend result [lsearch -all -inline -glob [wm stackorder .] ".t?"]
    } -cleanup {
    } -result {0 0 1 1 {.t1 .t2}}

    • priority: 3 --> 5
    • assigned_to: stwo --> dkf
  • And 8.5 branch

    • status: open --> closed-fixed