Tk Source Code

Artifact [35679ed6]
Login

Artifact 35679ed6c0f838b5f53a6a2487c25392acc8f276:

Attachment "tip125.patch" to ticket [998125ff] added by bgriffin 2004-07-26 22:53:38.
? test.log
? tristate.tar
? doc/man.macros
? unix/tkConfig.sh
? unix/tkUnixButton.patch
? unix/wish
Index: generic/tk.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tk.h,v
retrieving revision 1.80
diff -p -r1.80 tk.h
*** generic/tk.h	26 Mar 2004 19:57:34 -0000	1.80
--- generic/tk.h	26 Jul 2004 15:19:03 -0000
*************** typedef XActivateDeactivateEvent XDeacti
*** 727,732 ****
--- 727,734 ----
      (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)
  #define Tk_IsTopLevel(tkwin) \
      (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)
+ #define Tk_IsFrame(tkwin) \
+     (((Tk_FakeWin *) (tkwin))->flags & TK_FRAME)
  #define Tk_HasWrapper(tkwin) \
      (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER)
  #define Tk_WinManaged(tkwin) \
*************** typedef struct Tk_FakeWin {
*** 811,816 ****
--- 813,819 ----
   * TK_MAPPED:			1 means window is currently mapped,
   *				0 means unmapped.
   * TK_TOP_LEVEL:		1 means this is a top-level widget.
+  * TK_FRAME:			1 means this is a Frame (or derived from Frame)
   * TK_ALREADY_DEAD:		1 means the window is in the process of
   *				being destroyed already.
   * TK_NEED_CONFIG_NOTIFY:	1 means that the window has been reconfigured
*************** typedef struct Tk_FakeWin {
*** 874,879 ****
--- 877,884 ----
   * TK_PROP_PROPCHANGE		1 means that PropertyNotify events in
   *				this window's children should propagate
   *				up to this window.
+  * TK_URBAN_RENEWAL		1 means this window needs to be re-created
+  *				from the ground up because it's been reparented.
   */
  
  
*************** typedef struct Tk_FakeWin {
*** 896,901 ****
--- 901,908 ----
  #define TK_WIN_MANAGED		0x10000
  #define TK_TOP_HIERARCHY	0x20000
  #define TK_PROP_PROPCHANGE	0x40000
+ #define TK_FRAME                0x80000
+ #define TK_URBAN_RENEWAL	0x100000
  
  /*
   *--------------------------------------------------------------
Index: generic/tkFrame.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkFrame.c,v
retrieving revision 1.17
diff -p -r1.17 tkFrame.c
*** generic/tkFrame.c	13 Jan 2004 02:06:00 -0000	1.17
--- generic/tkFrame.c	26 Jul 2004 15:19:03 -0000
*************** static Tk_OptionSpec frameOptSpec[] = {
*** 237,242 ****
--- 237,245 ----
      {TK_OPTION_STRING, "-class", "class", "Class",
  	DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className),
  	0, 0, 0},
+     {TK_OPTION_STRING, "-menu", "menu", "Menu",
+ 	DEF_TOPLEVEL_MENU, -1, Tk_Offset(Frame, menuName),
+ 	TK_OPTION_NULL_OK, 0, 0},
      {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
  	DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief),
  	0, 0, 0},
*************** CreateFrame(clientData, interp, objc, ob
*** 664,669 ****
--- 667,675 ----
  	labelframePtr->labelAnchor = LABELANCHOR_NW;
  	labelframePtr->textGC = None;
      }
+     if (framePtr->type == TYPE_FRAME) {
+ 	((TkWindow *)new)->flags |= TK_FRAME;
+     }
  
      /*
       * Store backreference to frame widget in window structure.
*************** ConfigureFrame(interp, framePtr, objc, o
*** 961,970 ****
       * A few of the options require additional processing.
       */
  
!     if (((oldMenuName == NULL) && (framePtr->menuName != NULL))
! 	    || ((oldMenuName != NULL) && (framePtr->menuName == NULL))
! 	    || ((oldMenuName != NULL) && (framePtr->menuName != NULL)
! 	    && strcmp(oldMenuName, framePtr->menuName) != 0)) {
  	TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
  		framePtr->menuName);
      }
--- 967,977 ----
       * A few of the options require additional processing.
       */
  
!     if ((((oldMenuName == NULL) && (framePtr->menuName != NULL))
!     ||   ((oldMenuName != NULL) && (framePtr->menuName == NULL))
!     ||   ((oldMenuName != NULL) && (framePtr->menuName != NULL)
!     &&   strcmp(oldMenuName, framePtr->menuName) != 0))
!     &&  framePtr->type == TYPE_TOPLEVEL) {
  	TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
  		framePtr->menuName);
      }
*************** FrameLostSlaveProc(clientData, tkwin)
*** 1936,1941 ****
--- 1943,1974 ----
      }
      FrameWorldChanged((ClientData) framePtr);
  }
+ 
+ 
+ void
+ TkMapTopFrame (tkwin)
+      Tk_Window tkwin;
+ {
+     Frame *framePtr = ((TkWindow*)tkwin)->instanceData;
+     Tk_OptionTable optionTable;
+     if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) {
+ 	framePtr->type = TYPE_TOPLEVEL;
+ 	Tcl_DoWhenIdle(MapFrame, (ClientData)framePtr);
+ 	if (framePtr->menuName != NULL) {
+ 	    TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, NULL,
+ 			       framePtr->menuName);
+ 	}
+     } else if (!Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_TOPLEVEL) {
+ 	framePtr->type = TYPE_FRAME;
+     }
+     /*
+      * The option table has already been created so 
+      * the cached pointer will be returned.
+      */
+     optionTable = Tk_CreateOptionTable(framePtr->interp, optionSpecs[framePtr->type]);
+     framePtr->optionTable = optionTable;
+ }
+ 
  
  /*
   *--------------------------------------------------------------
Index: generic/tkInt.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkInt.h,v
retrieving revision 1.62
diff -p -r1.62 tkInt.h
*** generic/tkInt.h	5 Jul 2004 21:21:52 -0000	1.62
--- generic/tkInt.h	26 Jul 2004 15:19:03 -0000
*************** EXTERN int		Tk_WmObjCmd _ANSI_ARGS_((Cli
*** 1089,1094 ****
--- 1089,1095 ----
  			    Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
  
+ 
  EXTERN void		TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp,
  			    int devId, CONST char *buffer, long size));
  
*************** EXTERN char *		TkTilePrintProc _ANSI_ARG
*** 1166,1171 ****
--- 1167,1173 ----
  			    ClientData clientData, Tk_Window tkwin,
  			    char *widgRec, int offset,
  			    Tcl_FreeProc **freeProcPtr));
+ EXTERN void             TkMapTopFrame _ANSI_ARGS_((Tk_Window tkwin));
  EXTERN XEvent *		TkpGetBindingXEvent _ANSI_ARGS_((
  			    Tcl_Interp *interp));
  EXTERN void		TkCreateExitHandler _ANSI_ARGS_((Tcl_ExitProc *proc,
Index: macosx/tkMacOSXButton.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXButton.c,v
retrieving revision 1.9
diff -p -r1.9 tkMacOSXButton.c
*** macosx/tkMacOSXButton.c	18 Feb 2004 00:40:24 -0000	1.9
--- macosx/tkMacOSXButton.c	26 Jul 2004 15:19:03 -0000
*************** TkMacOSXDrawControl(
*** 917,923 ****
      Rect       paneRect;
      Rect       cntrRect;
      int        hilitePart = -1;
! 
  
      winPtr = (TkWindow *)butPtr->tkwin;
     
--- 917,923 ----
      Rect       paneRect;
      Rect       cntrRect;
      int        hilitePart = -1;
!     int        rebuild;
  
      winPtr = (TkWindow *)butPtr->tkwin;
     
*************** TkMacOSXDrawControl(
*** 943,953 ****
       * The control has been previously initialised
       * It may need to be re-initialised 
       */
       
      if (mbPtr->flags) {
          MacControlParams params;
          TkMacOSXComputeControlParams(butPtr, &params);
!         if (bcmp(&params, &mbPtr->params, sizeof(params))) {
              /* 
               * the type of control has changed
               * Clean it up and clear the flag 
--- 943,955 ----
       * The control has been previously initialised
       * It may need to be re-initialised 
       */
+     rebuild = winPtr->flags & TK_URBAN_RENEWAL;
+     winPtr->flags &= ~TK_URBAN_RENEWAL;
       
      if (mbPtr->flags) {
          MacControlParams params;
          TkMacOSXComputeControlParams(butPtr, &params);
!         if (rebuild || bcmp(&params, &mbPtr->params, sizeof(params))) {
              /* 
               * the type of control has changed
               * Clean it up and clear the flag 
*************** TkMacOSXDrawControl(
*** 979,985 ****
          len = TkFontGetFirstTextLayout(butPtr->textLayout, 
                  &font, controlTitle);
          controlTitle[len] = 0;
!         if (bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
              CFStringRef cf;    	    
              cf = CFStringCreateWithCString(NULL,
                    controlTitle, kCFStringEncodingUTF8);
--- 981,987 ----
          len = TkFontGetFirstTextLayout(butPtr->textLayout, 
                  &font, controlTitle);
          controlTitle[len] = 0;
!         if (rebuild || bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
              CFStringRef cf;    	    
              cf = CFStringCreateWithCString(NULL,
                    controlTitle, kCFStringEncodingUTF8);
Index: macosx/tkMacOSXMenubutton.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXMenubutton.c,v
retrieving revision 1.3
diff -p -r1.3 tkMacOSXMenubutton.c
*** macosx/tkMacOSXMenubutton.c	16 Feb 2004 00:19:42 -0000	1.3
--- macosx/tkMacOSXMenubutton.c	26 Jul 2004 15:19:03 -0000
*************** TkpDisplayMenuButton(
*** 204,210 ****
          MenuButtonControlParams params;
          bzero(&params, sizeof(params));
          ComputeMenuButtonControlParams(butPtr, &params );
!         if (bcmp(&params,&mbPtr->params,sizeof(params))) {
              if (mbPtr->userPane) {
                  DisposeControl(mbPtr->userPane);
                  mbPtr->userPane = NULL;
--- 204,212 ----
          MenuButtonControlParams params;
          bzero(&params, sizeof(params));
          ComputeMenuButtonControlParams(butPtr, &params );
!         if ((winPtr->flags & TK_URBAN_RENEWAL) || 
! 	    bcmp(&params,&mbPtr->params,sizeof(params))) {
! 	    winPtr->flags &= ~TK_URBAN_RENEWAL;
              if (mbPtr->userPane) {
                  DisposeControl(mbPtr->userPane);
                  mbPtr->userPane = NULL;
Index: macosx/tkMacOSXWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXWm.c,v
retrieving revision 1.12
diff -p -r1.12 tkMacOSXWm.c
*** macosx/tkMacOSXWm.c	16 Jun 2004 20:03:18 -0000	1.12
--- macosx/tkMacOSXWm.c	26 Jul 2004 15:19:03 -0000
*************** static int wmTracing = 0;
*** 48,53 ****
--- 48,55 ----
  
  static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
  	Tk_Window tkwin));
+ static void		RemapWindows _ANSI_ARGS_((TkWindow *winPtr,
+ 			    MacDrawable *parentWin));
  
  static Tk_GeomMgr wmMgrType = {
      "wm",				/* name */
*************** static int 		WmDeiconifyCmd _ANSI_ARGS_(
*** 101,106 ****
--- 103,111 ----
  static int 		WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin,
                                            TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                            Tcl_Obj *CONST objv[]));
+ static int 		WmForgetCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 				      TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 				      Tcl_Obj *CONST objv[]));
  static int 		WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin,
                                       TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                       Tcl_Obj *CONST objv[]));
*************** static int 		WmIconpositionCmd _ANSI_ARG
*** 131,136 ****
--- 136,144 ----
  static int 		WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin,
                                            TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                            Tcl_Obj *CONST objv[]));
+ static int 		WmManageCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 				      TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 				      Tcl_Obj *CONST objv[]));
  static int 		WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
                                         TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                         Tcl_Obj *CONST objv[]));
*************** Tk_WmObjCmd(
*** 536,556 ****
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
          "aspect", "attributes", "client", "colormapwindows",
!         "command", "deiconify", "focusmodel", "frame",
          "geometry", "grid", "group", "iconbitmap",
          "iconify", "iconmask", "iconname", "iconposition",
!         "iconwindow", "maxsize", "minsize", "overrideredirect",
!         "positionfrom", "protocol", "resizable", "sizefrom",
!         "stackorder", "state", "title", "transient",
          "withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
!         WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
          WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
          WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
!         WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
!         WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
!         WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
          WMOPT_WITHDRAW };
      int index, length;
      char *argv1;
--- 544,564 ----
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
          "aspect", "attributes", "client", "colormapwindows",
!         "command", "deiconify", "focusmodel", "forget", "frame",
          "geometry", "grid", "group", "iconbitmap",
          "iconify", "iconmask", "iconname", "iconposition",
!         "iconwindow", "manage", "maxsize", "minsize", 
! 	"overrideredirect", "positionfrom", "protocol", "resizable", 
! 	"sizefrom", "stackorder", "state", "title", "transient",
          "withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
!         WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET, WMOPT_FRAME,
          WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
          WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
!         WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, 
! 	WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, 
! 	WMOPT_SIZEFROM, WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
          WMOPT_WITHDRAW };
      int index, length;
      char *argv1;
*************** wrongNumArgs:
*** 589,595 ****
          != TCL_OK) {
          return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr)) {
          Tcl_AppendResult(interp, "window \"", winPtr->pathName,
                           "\" isn't a top-level window", (char *) NULL);
          return TCL_ERROR;
--- 597,604 ----
          != TCL_OK) {
          return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr) &&
! 	!((index == WMOPT_MANAGE) && Tk_IsFrame(winPtr))) {
          Tcl_AppendResult(interp, "window \"", winPtr->pathName,
                           "\" isn't a top-level window", (char *) NULL);
          return TCL_ERROR;
*************** wrongNumArgs:
*** 610,615 ****
--- 619,626 ----
              return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_FOCUSMODEL:
              return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
+         case WMOPT_FORGET:
+             return WmForgetCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_FRAME:
              return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_GEOMETRY:
*************** wrongNumArgs:
*** 630,635 ****
--- 641,648 ----
              return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_ICONWINDOW:
              return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
+         case WMOPT_MANAGE:
+             return WmManageCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_MAXSIZE:
              return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
          case WMOPT_MINSIZE:
*************** Tcl_Obj *CONST objv[];	/* Argument objec
*** 1142,1147 ****
--- 1155,1217 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmForgetCmd --
+  *
+  *	This procedure is invoked to process the "wm forget" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmForgetCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ 	CGrafPtr destPort = TkMacOSXGetDrawablePort(winPtr->window);
+ 	
+ 	Tk_UnmapWindow(frameWin);
+ 
+ 	if (destPort != NULL) {
+ 	    WindowRef winRef = GetWindowFromPort(destPort);
+ 	    TkMacOSXUnregisterMacWindow(winRef);
+ 	    DisposeWindow(winRef);
+ 	}
+ 	macWin->grafPtr = NULL;
+ 	macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;
+ 	macWin->flags &= ~TK_HOST_EXISTS;
+ 
+ 	RemapWindows(winPtr, macWin);
+ 	winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ 	if (strcmp(oldClass, "Toplevel") == 0)
+ 	    Tk_SetClass(frameWin, "Frame");
+ 	/* flags (above) must be cleared before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame(frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), " is not a Frame.", (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmFrameCmd --
   *
   *	This procedure is invoked to process the "wm frame" Tcl command.
*************** Tcl_Obj *CONST objv[];	/* Argument objec
*** 1780,1785 ****
--- 1850,1912 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmManageCmd --
+  *
+  *	This procedure is invoked to process the "wm manage" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmManageCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     register WmInfo *wmPtr = winPtr->wmInfoPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (!Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ 	Tk_UnmapWindow(frameWin);
+ 	if (wmPtr == NULL) {
+ 	    TkWmNewWindow(winPtr);
+ 	    TkWmMapWindow(winPtr);
+ 	    Tk_UnmapWindow(frameWin);
+ 	}
+ 	wmPtr = winPtr->wmInfoPtr;
+ 	if (strcmp(oldClass, "Frame") == 0)
+ 	    Tk_SetClass(frameWin, "Toplevel");
+ 	winPtr->flags &= ~TK_MAPPED;
+ 	macWin->grafPtr = NULL;
+ 	macWin->toplevel = macWin;
+ 	RemapWindows(winPtr, macWin);
+ 	winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
+ 	/* flags (above) must be set before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame (frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), 
+ 			 " is not a frame.\nOnly Frames may be managed as a toplevel.", 
+ 			 (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmMaxsizeCmd --
   *
   *	This procedure is invoked to process the "wm maxsize" Tcl command.
*************** TkWmStackorderToplevel(parentPtr)
*** 5521,5527 ****
      return windows;
  }
  
  
  
  
! 
--- 5648,5690 ----
      return windows;
  }
  
+ /*
+  *----------------------------------------------------------------------
+  *
+  * RemapWindows
+  *
+  *	Adjust parent/child relation ships of
+  *	the given window hierarchy.
+  *
+  * Results:
+  *	none
+  *
+  * Side effects:
+  *	keeps windowing system (X11) happy
+  *
+  *----------------------------------------------------------------------
+  */
  
+ static void 
+ RemapWindows(winPtr, parentWin)
+      TkWindow *winPtr;
+      MacDrawable *parentWin;
+ {
+     TkWindow *childPtr;
  
+     /* Remove the OS specific window.
+      * It will get rebuilt when the window gets Mapped.
+      */
+     if (winPtr->window != None) {
+ 	MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ 	macWin->grafPtr = NULL;
+ 	macWin->toplevel = parentWin->toplevel;
+ 	winPtr->flags &= ~TK_MAPPED;
+ 	winPtr->flags |= TK_URBAN_RENEWAL;
+     }
  
!     /* Repeat for all the children */
!     for (childPtr=winPtr->childList; childPtr; childPtr=childPtr->nextPtr) {
! 	RemapWindows(childPtr, (MacDrawable *) winPtr->window);
!     }
! }
Index: unix/tkUnixWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixWm.c,v
retrieving revision 1.43
diff -p -r1.43 tkUnixWm.c
*** unix/tkUnixWm.c	5 Jul 2004 19:19:43 -0000	1.43
--- unix/tkUnixWm.c	26 Jul 2004 15:19:03 -0000
*************** typedef struct TkWmInfo {
*** 276,281 ****
--- 276,283 ----
  
  static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
  			    Tk_Window tkwin));
+ static void		RemapWindows _ANSI_ARGS_((TkWindow *winPtr,
+ 			    TkWindow *parentPtr));
  
  static Tk_GeomMgr wmMgrType = {
      "wm",				/* name */
*************** static void		TkWmStackorderToplevelWrapp
*** 327,332 ****
--- 329,336 ----
  			    Tcl_HashTable *reparentTable));
  static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
  			    Tk_Window tkwin));
+ static void		RemapWindows _ANSI_ARGS_((TkWindow *winPtr, 
+ 			    TkWindow *parentPtr));
  static void		UpdateCommand _ANSI_ARGS_((TkWindow *winPtr));
  static void		UpdateGeometryInfo _ANSI_ARGS_((
  			    ClientData clientData));
*************** static int 		WmDeiconifyCmd _ANSI_ARGS_(
*** 371,376 ****
--- 375,383 ----
  static int 		WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
+ static int		WmForgetCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 			    Tcl_Obj *CONST objv[]));
  static int 		WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
*************** static int 		WmIconpositionCmd _ANSI_ARG
*** 401,406 ****
--- 408,416 ----
  static int 		WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
+ static int		WmManageCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 			    Tcl_Obj *CONST objv[]));
  static int 		WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 952,972 ****
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
  	"aspect", "attributes", "client", "colormapwindows",
! 	"command", "deiconify", "focusmodel", "frame",
  	"geometry", "grid", "group", "iconbitmap",
  	"iconify", "iconmask", "iconname", "iconposition",
! 	"iconwindow", "maxsize", "minsize", "overrideredirect",
!         "positionfrom", "protocol", "resizable", "sizefrom",
!         "stackorder", "state", "title", "transient",
  	"withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
! 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
  	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
! 	WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
!         WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
!         WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
  	WMOPT_WITHDRAW };
      int index; 
      int length;
--- 962,982 ----
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
  	"aspect", "attributes", "client", "colormapwindows",
! 	"command", "deiconify", "focusmodel", "forget", "frame",
  	"geometry", "grid", "group", "iconbitmap",
  	"iconify", "iconmask", "iconname", "iconposition",
! 	"iconwindow", "manage", "maxsize", "minsize", 
! 	"overrideredirect", "positionfrom", "protocol", "resizable", 
! 	"sizefrom", "stackorder", "state", "title", "transient",
  	"withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
! 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET, WMOPT_FRAME,
  	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
! 	WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, 
! 	WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, 
! 	WMOPT_SIZEFROM, WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
  	WMOPT_WITHDRAW };
      int index; 
      int length;
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 1018,1024 ****
  	    != TCL_OK) {
  	return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr)) {
  	Tcl_AppendResult(interp, "window \"", winPtr->pathName,
  		"\" isn't a top-level window", (char *) NULL);
  	return TCL_ERROR;
--- 1028,1035 ----
  	    != TCL_OK) {
  	return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr) && 
! 	!((index == WMOPT_MANAGE) && Tk_IsFrame(winPtr))) {
  	Tcl_AppendResult(interp, "window \"", winPtr->pathName,
  		"\" isn't a top-level window", (char *) NULL);
  	return TCL_ERROR;
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 1039,1044 ****
--- 1050,1057 ----
  	return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_FOCUSMODEL:
  	return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
+       case WMOPT_FORGET:
+ 	return WmForgetCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_FRAME:
  	return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_GEOMETRY:
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 1059,1064 ****
--- 1072,1079 ----
  	return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_ICONWINDOW:
  	return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
+       case WMOPT_MANAGE:
+ 	return WmManageCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_MAXSIZE:
  	return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_MINSIZE:
*************** WmFocusmodelCmd(tkwin, winPtr, interp, o
*** 1537,1542 ****
--- 1552,1602 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmForgetCmd --
+  *
+  *	This procedure is invoked to process the "wm forget" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmForgetCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	Tk_UnmapWindow(frameWin);
+ 	TkWmDeadWindow(winPtr);
+ 	winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ 	RemapWindows(winPtr, winPtr->parentPtr);
+ 	if (strcmp(oldClass, "Toplevel") == 0)
+ 	    Tk_SetClass(frameWin, "Frame");
+ 	/* flags (above) must be cleared before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame(frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), " is not a Frame.", (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmFrameCmd --
   *
   *	This procedure is invoked to process the "wm frame" Tcl command.
*************** WmIconwindowCmd(tkwin, winPtr, interp, o
*** 2214,2219 ****
--- 2274,2333 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmManageCmd --
+  *
+  *	This procedure is invoked to process the "wm manage" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmManageCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     register WmInfo *wmPtr = winPtr->wmInfoPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (!Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	Tk_UnmapWindow(frameWin);
+ 	winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
+ 	if (wmPtr == NULL) {
+ 	    TkWmNewWindow(winPtr);
+ 	    TkWmMapWindow(winPtr);
+ 	    Tk_UnmapWindow(frameWin);
+ 	}
+ 	wmPtr = winPtr->wmInfoPtr;
+ 	if (strcmp(oldClass, "Frame") == 0)
+ 	    Tk_SetClass(frameWin, "Toplevel");
+ 	winPtr->flags &= ~TK_MAPPED;
+ 	RemapWindows(winPtr, wmPtr->wrapperPtr);
+ 	/* flags (above) must be set before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame (frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), 
+ 			 " is not a frame.\nOnly Frames may be managed as a toplevel.", 
+ 			 (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmMaxsizeCmd --
   *
   *	This procedure is invoked to process the "wm maxsize" Tcl command.
*************** TkpWmSetState(winPtr, state)
*** 6420,6422 ****
--- 6534,6583 ----
  
      return 1;
  }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
+  * RemapWindows
+  *
+  *	Adjust parent/child relation ships of
+  *	the given window hierarchy.
+  *
+  * Results:
+  *	none
+  *
+  * Side effects:
+  *	keeps windowing system (X11) happy
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static void 
+ RemapWindows(winPtr, parentPtr)
+      TkWindow *winPtr;
+      TkWindow *parentPtr;
+ {
+     TkWindow *childPtr;
+     XWindowAttributes win_attr;
+ 
+     if (strcmp(Tk_Class(winPtr), "Menu") == 0) {
+       return;
+     }
+     if (winPtr->window) {
+ 	XGetWindowAttributes(winPtr->display, winPtr->window, &win_attr);
+ 	if (parentPtr == NULL) {
+ 	    XReparentWindow(winPtr->display, winPtr->window,
+ 	            XRootWindow(winPtr->display, winPtr->screenNum), 
+ 		    win_attr.x, win_attr.y);
+ 	} else if (parentPtr->window) {
+ 	    XReparentWindow(parentPtr->display, winPtr->window, 
+ 			    parentPtr->window, 
+ 			    win_attr.x, win_attr.y);
+ 	}
+     }
+ 
+     /* Repeat for all the children */
+     for (childPtr=winPtr->childList; childPtr; childPtr=childPtr->nextPtr) {
+ 	RemapWindows(childPtr, winPtr);
+     }
+ }
Index: win/tkWinWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinWm.c,v
retrieving revision 1.63
diff -p -r1.63 tkWinWm.c
*** win/tkWinWm.c	16 Jun 2004 20:03:20 -0000	1.63
--- win/tkWinWm.c	26 Jul 2004 15:19:03 -0000
*************** typedef struct TkWmInfo {
*** 331,336 ****
--- 331,337 ----
   */
  
  static void		TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
+ static void		RemapWindows(TkWindow *winPtr, HWND parentHWND);
  
  static Tk_GeomMgr wmMgrType = {
      "wm",				/* name */
*************** static int 		WmDeiconifyCmd _ANSI_ARGS_(
*** 456,461 ****
--- 457,465 ----
  static int 		WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
+ static int		WmForgetCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 			    Tcl_Obj *CONST objv[]));
  static int 		WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
*************** static int 		WmIconpositionCmd _ANSI_ARG
*** 486,491 ****
--- 490,498 ----
  static int 		WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
+ static int		WmManageCmd _ANSI_ARGS_((Tk_Window tkwin,
+ 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ 			    Tcl_Obj *CONST objv[]));
  static int 		WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
  			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
  			    Tcl_Obj *CONST objv[]));
*************** TkWmDeadWindow(winPtr)
*** 2346,2352 ****
      if (!(winPtr->flags & TK_EMBEDDED)) {
  	if (wmPtr->wrapper != NULL) {
  	    DestroyWindow(wmPtr->wrapper);
! 	} else {
  	    DestroyWindow(Tk_GetHWND(winPtr->window));
  	}
      }
--- 2353,2359 ----
      if (!(winPtr->flags & TK_EMBEDDED)) {
  	if (wmPtr->wrapper != NULL) {
  	    DestroyWindow(wmPtr->wrapper);
! 	} else if (winPtr->window) {
  	    DestroyWindow(Tk_GetHWND(winPtr->window));
  	}
      }
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 2419,2439 ****
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
  	"aspect", "attributes", "client", "colormapwindows",
! 	"command", "deiconify", "focusmodel", "frame",
  	"geometry", "grid", "group", "iconbitmap",
  	"iconify", "iconmask", "iconname", "iconposition",
! 	"iconwindow", "maxsize", "minsize", "overrideredirect",
!         "positionfrom", "protocol", "resizable", "sizefrom",
!         "stackorder", "state", "title", "transient",
  	"withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
! 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
  	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
! 	WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
!         WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
!         WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
  	WMOPT_WITHDRAW };
      int index, length;
      char *argv1;
--- 2426,2446 ----
      Tk_Window tkwin = (Tk_Window) clientData;
      static CONST char *optionStrings[] = {
  	"aspect", "attributes", "client", "colormapwindows",
! 	"command", "deiconify", "focusmodel", "forget", "frame",
  	"geometry", "grid", "group", "iconbitmap",
  	"iconify", "iconmask", "iconname", "iconposition",
! 	"iconwindow", "manage", "maxsize", "minsize", 
! 	"overrideredirect", "positionfrom", "protocol", "resizable", 
! 	"sizefrom", "stackorder", "state", "title", "transient",
  	"withdraw", (char *) NULL };
      enum options {
          WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
! 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET, WMOPT_FRAME,
  	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
! 	WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, 
! 	WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, 
! 	WMOPT_SIZEFROM, WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
  	WMOPT_WITHDRAW };
      int index, length;
      char *argv1;
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 2484,2490 ****
  	    != TCL_OK) {
  	return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr)) {
  	Tcl_AppendResult(interp, "window \"", winPtr->pathName,
  		"\" isn't a top-level window", (char *) NULL);
  	return TCL_ERROR;
--- 2491,2498 ----
  	    != TCL_OK) {
  	return TCL_ERROR;
      }
!     if (!Tk_IsTopLevel(winPtr) &&
! 	!((index == WMOPT_MANAGE) && Tk_IsFrame(winPtr))) {
  	Tcl_AppendResult(interp, "window \"", winPtr->pathName,
  		"\" isn't a top-level window", (char *) NULL);
  	return TCL_ERROR;
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 2505,2510 ****
--- 2513,2520 ----
  	return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_FOCUSMODEL:
  	return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
+       case WMOPT_FORGET:
+ 	return WmForgetCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_FRAME:
  	return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_GEOMETRY:
*************** Tk_WmObjCmd(clientData, interp, objc, ob
*** 2525,2530 ****
--- 2535,2542 ----
  	return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_ICONWINDOW:
  	return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
+       case WMOPT_MANAGE:
+ 	return WmManageCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_MAXSIZE:
  	return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
        case WMOPT_MINSIZE:
*************** WmFocusmodelCmd(tkwin, winPtr, interp, o
*** 3097,3102 ****
--- 3109,3159 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmForgetCmd --
+  *
+  *	This procedure is invoked to process the "wm forget" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmForgetCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	Tk_UnmapWindow(frameWin);
+ 	winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ 	RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
+ 	TkWmDeadWindow(winPtr);
+ 	if (strcmp(oldClass, "Toplevel") == 0)
+ 	    Tk_SetClass(frameWin, "Frame");
+ 	/* flags (above) must be cleared before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame(frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), " is not a Frame.", (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmFrameCmd --
   *
   *	This procedure is invoked to process the "wm frame" Tcl command.
*************** WmIconwindowCmd(tkwin, winPtr, interp, o
*** 3817,3822 ****
--- 3874,3931 ----
  /*
   *----------------------------------------------------------------------
   *
+  * WmManageCmd --
+  *
+  *	This procedure is invoked to process the "wm manage" Tcl command.
+  *	See the user documentation for details on what it does.
+  *
+  * Results:
+  *	A standard Tcl result.
+  *
+  * Side effects:
+  *	See the user documentation.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ WmManageCmd(tkwin, winPtr, interp, objc, objv)
+     Tk_Window tkwin;		/* Main window of the application. */
+     TkWindow *winPtr;           /* Toplevel or Frame to work with */
+     Tcl_Interp *interp;		/* Current interpreter. */
+     int objc;			/* Number of arguments. */
+     Tcl_Obj *CONST objv[];	/* Argument objects. */
+ {
+     register Tk_Window frameWin = (Tk_Window)winPtr;
+     register WmInfo *wmPtr = winPtr->wmInfoPtr;
+     char *oldClass = (char*)Tk_Class(frameWin);
+ 
+     if (!Tk_IsTopLevel(frameWin) && Tk_IsFrame(frameWin)) {
+ 	Tk_UnmapWindow(frameWin);
+ 	winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
+ 	RemapWindows(winPtr, NULL);
+ 	if (wmPtr == NULL) {
+ 	    TkWmNewWindow(winPtr);
+ 	}
+ 	wmPtr = winPtr->wmInfoPtr;
+ 	if (strcmp(oldClass, "Frame") == 0)
+ 	    Tk_SetClass(frameWin, "Toplevel");
+ 	winPtr->flags &= ~TK_MAPPED;
+ 	/* flags (above) must be set before calling */
+ 	/* TkMapTopFrame (below) */
+ 	TkMapTopFrame (frameWin);
+     } else if (!Tk_IsFrame(frameWin)) {
+ 	Tcl_AppendResult(interp, Tk_PathName(frameWin), 
+ 			 " is not a frame.\nOnly Frames may be managed as a toplevel.", 
+ 			 (char*)NULL);
+ 	return TCL_ERROR;
+     }
+     return TCL_OK;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
   * WmMaxsizeCmd --
   *
   *	This procedure is invoked to process the "wm maxsize" Tcl command.
*************** TkWinSetForegroundWindow(winPtr)
*** 7173,7175 ****
--- 7282,7322 ----
  	SetForegroundWindow(Tk_GetHWND(winPtr->window));
      }
  }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
+  * RemapWindows
+  *
+  *	Adjust parent/child relation ships of
+  *	the given window hierarchy.
+  *
+  * Results:
+  *	none
+  *
+  * Side effects:
+  *	keeps windowing system happy
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static void 
+ RemapWindows(winPtr, parentHWND)
+      TkWindow *winPtr;
+      HWND parentHWND;
+ {
+     TkWindow *childPtr;
+ 
+     /* Skip Menus as they are handled differently */
+     if (strcmp(Tk_Class(winPtr), "Menu") == 0) {
+       return;
+     }
+     if (winPtr->window) {
+ 	SetParent(Tk_GetHWND(winPtr->window), parentHWND);
+     }
+ 
+     /* Repeat for all the children */
+     for (childPtr=winPtr->childList; childPtr; childPtr=childPtr->nextPtr) {
+ 	RemapWindows(childPtr, winPtr->window ? Tk_GetHWND(winPtr->window):NULL);
+     }
+ }