Tk Source Code

Check-in [48640053]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make it be an error to create a transient/master cycle on Aqua. Other platforms will be handled in separate check-ins.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-1951abf33d
Files: files | file ages | folders
SHA3-256: 48640053f4cb77764225f86bfa93b8bacd4fe4a8a6596d4057f11ec3e3ed4352
User & Date: culler 2019-03-01 15:28:48
Context
2019-03-01
15:46
Make it be an error to create a transient/master cycle on unix. check-in: d0d1c883 user: culler tags: bug-1951abf33d
15:28
Make it be an error to create a transient/master cycle on Aqua. Other platforms will be handled in separate check-ins. check-in: 48640053 user: culler tags: bug-1951abf33d
2019-02-28
15:29
Fix bugs in the list management code for the record of transient windows. check-in: eab3c21c user: culler tags: bug-1951abf33d
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/wm.n.

706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722

723
724

725
726
727
728
729
730
731
732
733
should display this string in \fIwindow\fR's title bar).  In this
case the command returns an empty string.  If \fIstring\fR is not
specified then the command returns the current title for the
\fIwindow\fR.  The title for a window defaults to its name.
.TP
\fBwm transient \fIwindow\fR ?\fImaster\fR?
.
If \fImaster\fR is specified, then the window manager is informed
that \fIwindow\fR is a transient window (e.g. pull-down menu) working
on behalf of \fImaster\fR (where \fImaster\fR is the
path name for a top-level window).  If \fImaster\fR
is specified as an empty string then \fIwindow\fR is marked as not
being a transient window any more.  Otherwise the command
returns the path name of \fIwindow\fR's current master, or an
empty string if \fIwindow\fR is not currently a transient window.
A transient window will mirror state changes in the master and
inherit the state of the master when initially mapped. It is an

error to attempt to make a window a transient of itself.
The window manager may also decorate a transient window differently, removing

some features normally present (e.g., minimize and maximize buttons) though
this is entirely at the discretion of the window manager.
.TP
\fBwm withdraw \fIwindow\fR
.
Arranges for \fIwindow\fR to be withdrawn from the screen.  This
causes the window to be unmapped and forgotten about by the window
manager.  If the window
has never been mapped, then this command






|
|
|
|
<
|
|
|
|
|
>
|
|
>
|
|







706
707
708
709
710
711
712
713
714
715
716

717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
should display this string in \fIwindow\fR's title bar).  In this
case the command returns an empty string.  If \fIstring\fR is not
specified then the command returns the current title for the
\fIwindow\fR.  The title for a window defaults to its name.
.TP
\fBwm transient \fIwindow\fR ?\fImaster\fR?
.
If \fImaster\fR is specified, then the window manager is informed that
\fIwindow\fR is a transient window (e.g. pull-down menu) working on
behalf of \fImaster\fR (where \fImaster\fR is the path name for a
top-level window).  If \fImaster\fR is specified as an empty string

then \fIwindow\fR is marked as not being a transient window any more.
Otherwise the command returns the path name of \fIwindow\fR's current
master, or an empty string if \fIwindow\fR is not currently a
transient window.  A transient window will mirror state changes in the
master and inherit the state of the master when initially mapped. The
directed graph with an edge from each transient to its master must be
acyclic.  In particular, it is an error to attempt to make a window a
transient of itself.  The window manager may also decorate a transient
window differently, removing some features normally present (e.g.,
minimize and maximize buttons) though this is entirely at the
discretion of the window manager.
.TP
\fBwm withdraw \fIwindow\fR
.
Arranges for \fIwindow\fR to be withdrawn from the screen.  This
causes the window to be unmapped and forgotten about by the window
manager.  If the window
has never been mapped, then this command

Changes to macosx/tkMacOSXWm.c.

3564
3565
3566
3567
3568
3569
3570

3571
3572
3573
3574
3575
3576
3577
....
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
....
3614
3615
3616
3617
3618
3619
3620


3621
3622
3623


3624
3625

3626
3627
3628
3629
3630
3631
3632
....
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
    TkWindow *winPtr,		/* Toplevel to work with */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    register WmInfo *wmPtr = winPtr->wmInfoPtr;
    Tk_Window master;

    WmInfo *wmPtr2;
    Transient *transient;

    if ((objc != 3) && (objc != 4)) {
	Tcl_WrongNumArgs(interp, 2, objv, "window ?master?");
	return TCL_ERROR;
    }
................................................................................
    if (Tcl_GetString(objv[3])[0] == '\0') {
	RemoveTransient(winPtr);

    } else {
	if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
	    return TCL_ERROR;
	}
	TkWindow *masterPtr = (TkWindow*) master;
	while (!Tk_TopWinHierarchy(masterPtr)) {

            /*
             * Ensure that the master window is actually a Tk toplevel.
             */

            masterPtr = masterPtr->parentPtr;
................................................................................
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "can't make \"%s\" a master: it is an icon for %s",
		    Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
	    return TCL_ERROR;
	}



	if (masterPtr == winPtr) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "can't make \"%s\" its own master", Tk_PathName(winPtr)));


	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
	    return TCL_ERROR;

	}

	/*
	 * Add the transient to the master's list, if it not already there.
	 */
	
	for (transient = wmPtr2->transientPtr;
................................................................................
		     */

		    parentWindow = [macWindow parentWindow];
		    if (parentWindow && parentWindow != masterMacWin) {
			[parentWindow removeChildWindow:macWindow];
		    }

		    /*
		     * To avoid cycles, if the master is a child of some
		       other window, remove it.
		     */
		    parentWindow = [masterMacWin parentWindow];
		    if (parentWindow) {
			[parentWindow removeChildWindow:masterMacWin];
		    }
		    [masterMacWin addChildWindow:macWindow
					     ordered:NSWindowAbove];
		    }
	    }
	} else {
	    parentWindow = [macWindow parentWindow];
	    if (parentWindow) {






>







 







|







 







>
>
|
|
<
>
>
|
|
>







 







<
<
<
<
<
<
<
<







3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
....
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
....
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625

3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
....
6882
6883
6884
6885
6886
6887
6888








6889
6890
6891
6892
6893
6894
6895
    TkWindow *winPtr,		/* Toplevel to work with */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    register WmInfo *wmPtr = winPtr->wmInfoPtr;
    Tk_Window master;
    TkWindow *masterPtr, *w;
    WmInfo *wmPtr2;
    Transient *transient;

    if ((objc != 3) && (objc != 4)) {
	Tcl_WrongNumArgs(interp, 2, objv, "window ?master?");
	return TCL_ERROR;
    }
................................................................................
    if (Tcl_GetString(objv[3])[0] == '\0') {
	RemoveTransient(winPtr);

    } else {
	if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
	    return TCL_ERROR;
	}
	masterPtr = (TkWindow*) master;
	while (!Tk_TopWinHierarchy(masterPtr)) {

            /*
             * Ensure that the master window is actually a Tk toplevel.
             */

            masterPtr = masterPtr->parentPtr;
................................................................................
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "can't make \"%s\" a master: it is an icon for %s",
		    Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
	    return TCL_ERROR;
	}

	for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL;
	     w = (TkWindow *)w->wmInfoPtr->master) {
	    if (w == winPtr) {
		Tcl_SetObjResult(interp, Tcl_ObjPrintf(

		    "setting \"%s\" as master creates a transient/master cycle",
		    Tk_PathName(masterPtr)));
		Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
		return TCL_ERROR;
	    }
	}

	/*
	 * Add the transient to the master's list, if it not already there.
	 */
	
	for (transient = wmPtr2->transientPtr;
................................................................................
		     */

		    parentWindow = [macWindow parentWindow];
		    if (parentWindow && parentWindow != masterMacWin) {
			[parentWindow removeChildWindow:macWindow];
		    }









		    [masterMacWin addChildWindow:macWindow
					     ordered:NSWindowAbove];
		    }
	    }
	} else {
	    parentWindow = [macWindow parentWindow];
	    if (parentWindow) {

Changes to tests/wm.test.

1636
1637
1638
1639
1640
1641
1642
1643
1644










1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
    deleteWindows
} -result {can't make ".icon" a master: it is an icon for .top}
test wm-transient-1.7 {usage} -returnCodes error -body {
    toplevel .master
    wm transient .master .master
} -cleanup {
    deleteWindows
} -result {can't make ".master" its own master}
test wm-transient-1.8 {usage} -returnCodes error -body {










    toplevel .master
    frame .master.f
    wm transient .master .master.f
} -cleanup {
    deleteWindows
} -result {can't make ".master" its own master}

test wm-transient-2.1 {basic get/set of master} -setup {
    set results [list]
} -body {
    toplevel .master
    toplevel .subject
    lappend results [wm transient .subject]






|

>
>
>
>
>
>
>
>
>
>





|







1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
    deleteWindows
} -result {can't make ".icon" a master: it is an icon for .top}
test wm-transient-1.7 {usage} -returnCodes error -body {
    toplevel .master
    wm transient .master .master
} -cleanup {
    deleteWindows
} -result {setting ".master" as master creates a transient/master cycle}
test wm-transient-1.8 {usage} -returnCodes error -body {
    toplevel .t1
    toplevel .t2
    toplevel .t3
    wm transient .t2 .t1
    wm transient .t3 .t2
    wm transient .t1 .t3
} -cleanup {
    deleteWindows
} -result {setting ".t3" as master creates a transient/master cycle}
test wm-transient-1.9 {usage} -returnCodes error -body {
    toplevel .master
    frame .master.f
    wm transient .master .master.f
} -cleanup {
    deleteWindows
} -result {setting ".master" as master creates a transient/master cycle}

test wm-transient-2.1 {basic get/set of master} -setup {
    set results [list]
} -body {
    toplevel .master
    toplevel .subject
    lappend results [wm transient .subject]