*** tkUnixWm.c	Mon Mar 27 12:02:59 2000
--- /home/ccox/tk8.3.2/unix/tkUnixWm.c	Mon Apr 30 11:32:29 2001
***************
*** 300,306 ****
--- 300,310 ----
  
  typedef struct WaitRestrictInfo {
      Display *display;		/* Window belongs to this display. */
+ #if 1 /* TNB */
+ 	WmInfo *wmInfoPtr;
+ #else /* TNB */
      Window window;		/* We're waiting for events on this window. */
+ #endif /* TNB */
      int type;			/* We only care about this type of event. */
      XEvent *eventPtr;		/* Where to store the event when it's found. */
      int foundEvent;		/* Non-zero means that an event of the
***************
*** 334,341 ****
--- 338,350 ----
  static void		UpdateWmProtocols _ANSI_ARGS_((WmInfo *wmPtr));
  static void		WaitForConfigureNotify _ANSI_ARGS_((TkWindow *winPtr,
  			    unsigned long serial));
+ #if 1 /* TNB */
+ static int		WaitForEvent _ANSI_ARGS_((Display *display,
+ 			    WmInfo *wmInfoPtr, int type, XEvent *eventPtr));
+ #else /* TNB */
  static int		WaitForEvent _ANSI_ARGS_((Display *display,
  			    Window window, int type, XEvent *eventPtr));
+ #endif /* TNB */
  static void		WaitForMapNotify _ANSI_ARGS_((TkWindow *winPtr,
  			    int mapped));
  static Tk_RestrictAction
***************
*** 2411,2416 ****
--- 2420,2429 ----
  	wmPtr->xInParent = wmPtr->yInParent = 0;
  	wrapperPtr->changes.x = reparentEventPtr->x;
  	wrapperPtr->changes.y = reparentEventPtr->y;
+ #if 1 /* TNB */
+ 	wmPtr->winPtr->changes.x = reparentEventPtr->x;
+ 	wmPtr->winPtr->changes.y = reparentEventPtr->y + wmPtr->menuHeight;
+ #endif /* TNB */
  	return;
      }
  
***************
*** 2851,2857 ****
--- 2864,2875 ----
      serial = NextRequest(winPtr->display);
      height += wmPtr->menuHeight;
      if (wmPtr->flags & WM_MOVE_PENDING) {
+ #if 1 /* TNB */
+ 	if ((x + wmPtr->xInParent == winPtr->changes.x) &&
+ 		(y + wmPtr->yInParent + wmPtr->menuHeight == winPtr->changes.y)
+ #else /* TNB */
  	if ((x == winPtr->changes.x) && (y == winPtr->changes.y)
+ #endif /* TNB */
  		&& (width == wmPtr->wrapperPtr->changes.width)
  		&& (height == wmPtr->wrapperPtr->changes.height)) {
  	    /*
***************
*** 3084,3091 ****
--- 3102,3114 ----
  
      while (!gotConfig) {
  	wmPtr->flags |= WM_SYNC_PENDING;
+ #if 1 /* TNB */
+ 	code = WaitForEvent(winPtr->display, wmPtr,
+ 		ConfigureNotify, &event);
+ #else /* TNB */
  	code = WaitForEvent(winPtr->display, wmPtr->wrapperPtr->window,
  		ConfigureNotify, &event);
+ #endif /* TNB */
  	wmPtr->flags &= ~WM_SYNC_PENDING;
  	if (code != TCL_OK) {
  	    if (winPtr->dispPtr->wmTracing) {
***************
*** 3131,3139 ****
--- 3154,3168 ----
   */
  
  static int
+ #if 0 /* TNB */
  WaitForEvent(display, window, type, eventPtr)
      Display *display;		/* Display event is coming from. */
      Window window;		/* Window for which event is desired. */
+ #else /* TNB */
+ WaitForEvent(display, wmInfoPtr, type, eventPtr)
+     Display *display;		/* Display event is coming from. */
+     WmInfo *wmInfoPtr;		/* Window for which event is desired. */
+ #endif /* TNB */
      int type;			/* Type of event that is wanted. */
      XEvent *eventPtr;		/* Place to store event. */
  {
***************
*** 3149,3155 ****
--- 3178,3188 ----
       */
  
      info.display = display;
+ #if 1 /* TNB */
+ 	info.wmInfoPtr = wmInfoPtr;
+ #else /* TNB */
      info.window = window;
+ #endif /* TNB */
      info.type = type;
      info.eventPtr = eventPtr;
      info.foundEvent = 0;
***************
*** 3203,3209 ****
--- 3236,3247 ----
      if (eventPtr->type == ReparentNotify) {
  	return TK_PROCESS_EVENT;
      }
+ #if 1 /* TNB */
+ 	if (((eventPtr->xany.window != infoPtr->wmInfoPtr->wrapperPtr->window)
+ 		&& (eventPtr->xany.window != infoPtr->wmInfoPtr->reparent))
+ #else /* TNB */
      if ((eventPtr->xany.window != infoPtr->window)
+ #endif /* TNB */
  	    || (eventPtr->xany.display != infoPtr->display)) {
  	return TK_DEFER_EVENT;
      }
***************
*** 3265,3272 ****
--- 3303,3315 ----
  	    break;
  	}
  	wmPtr->flags |= WM_SYNC_PENDING;
+ #if 1 /* TNB */
+ 	code = WaitForEvent(winPtr->display, wmPtr,
+ 		mapped ? MapNotify : UnmapNotify, &event);
+ #else /* TNB */
  	code = WaitForEvent(winPtr->display, wmPtr->wrapperPtr->window,
  		mapped ? MapNotify : UnmapNotify, &event);
+ #endif /* TNB */
  	wmPtr->flags &= ~WM_SYNC_PENDING;
  	if (code != TCL_OK) {
  	    /*
***************
*** 4254,4263 ****
       * is tricky if winPtr has been reparented, since the window getting
       * the event isn't one that Tk owns.
       */
- 
      if (window == wrapperPtr->window) {
  	WaitForConfigureNotify(winPtr, serial);
      } else {
  	while (1) {
  	    if (WaitForEvent(winPtr->display, window, ConfigureNotify,
  		    &event) != TCL_OK) {
--- 4297,4308 ----
       * is tricky if winPtr has been reparented, since the window getting
       * the event isn't one that Tk owns.
       */
      if (window == wrapperPtr->window) {
  	WaitForConfigureNotify(winPtr, serial);
      } else {
+ #if 1 /* TNB */
+ 	WaitForConfigureNotify(winPtr, serial);
+ #else /* TNB */
  	while (1) {
  	    if (WaitForEvent(winPtr->display, window, ConfigureNotify,
  		    &event) != TCL_OK) {
***************
*** 4268,4274 ****
  		break;
  	    }
  	}
! 
  	/*
  	 * Ignore errors that occur when we are de-selecting events on
  	 * window, since it's possible that the window doesn't exist
--- 4313,4319 ----
  		break;
  	    }
  	}
! #endif /* TNB */
  	/*
  	 * Ignore errors that occur when we are de-selecting events on
  	 * window, since it's possible that the window doesn't exist
