protected override void OnActivateChild(TopLevelWindow child)
			{
				sink.ToolkitMdiActivate((IToolkitWindow)child);
			}
	/// <summary>
	/// <para>Method that is called when a child becomes inactive within
	/// the MDI client.</para>
	/// </summary>
	///
	/// <param name="child">
	/// <para>The child that was deactivated.</para>
	/// </param>
	protected virtual void OnDeactivateChild(TopLevelWindow child)
			{
				// Nothing to do here.
			}
	/// <summary>
	/// <para>Remove the transient parent window hint.</para>
	/// </summary>
	///
	/// <remarks>
	/// <para>Setting the <c>TransientFor</c> property to
	/// <see langword="null"/> will mark the window as transient, but
	/// for the whole screen instead of an application window.</para>
	///
	/// <para>Calling <c>RemoveTransientFor</c> removes the hint entirely,
	/// resetting the window back to the normal "non-transient" mode.</para>
	/// </remarks>
	public virtual void RemoveTransientFor()
			{
				if(Parent is CaptionWidget)
				{
					// Cannot set transients for MDI children.
					return;
				}
				try
				{
					// Lock down the display and get the handle.
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();

					// Remove the "transient for" hint.
					Xlib.XDeleteProperty
						(display, handle, Xlib.XInternAtom
							(display, "WM_TRANSIENT_FOR", XBool.False));

					// We no longer have a transient parent for this window.
					transientFor = null;
				}
				finally
				{
					dpy.Unlock();
				}
			}
	// Construct a new caption widget underneath "parent", which
	// encapsulates the given "child" widget.
	public CaptionWidget(Widget parent, String name, int x, int y,
						 int width, int height, Type type)
			: base(parent, x, y,
				   width + FrameBorderSize * 2,
				   height + GetCaptionHeight(parent) + FrameBorderSize,
				   new Color(StandardColor.Foreground),
				   new Color(StandardColor.Background))
			{
				// Don't automatically map the child when it is created.
				AutoMapChildren = false;

				// Calculate the size of the caption, including the border.
				captionHeight = GetCaptionHeight(parent);

				// The caption widget is not focusable.
				Focusable = false;

				// Create the "top-level" window object for the child.
				ConstructorInfo ctor = type.GetConstructor
					(new Type [] {typeof(Widget), typeof(String),
								  typeof(int), typeof(int),
								  typeof(int), typeof(int)});
				child = (TopLevelWindow)(ctor.Invoke
					(new Object[] {this, name, FrameBorderSize, captionHeight,
					 			   width, height}));
				child.reparented = true;

				// Set the default flags.
				flags = CaptionFlags.HasClose |
						CaptionFlags.HasMaximize |
						CaptionFlags.HasMinimize;
				clickMode = HitTest.Outside;

				// Perform an initial move/resize to position the child
				// window properly within the MDI client area.
				MoveResize(this.x, this.y, this.width, this.height);

				// Make sure that we have the inactive grab.
				MakeInactive();
			}
	// Internal constructor, that can create a top-level window on either
	// the root window or underneath an MDI client parent.
	public TopLevelWindow(Widget parent, String name,
						  int x, int y, int width, int height)
			: base(parent, x, y, width, height,
			       new Color(StandardColor.Foreground),
			       new Color(StandardColor.Background),
				   true, false)
			{
				// Check the parent.
				if(!(parent is RootWindow) && !(parent is CaptionWidget))
				{
					throw new XInvalidOperationException();
				}

				// Initialize this object's state.
				this.name = ((name != null) ? name : String.Empty);
				this.iconic = false;
				this.maximized = false;
				this.hasPrimaryFocus = false;
				this.reparented = false;
				this.sticky = false;
				this.shaded = false;
				this.hidden = false;
				this.fullScreen = false;
				this.keyBuffer = IntPtr.Zero;
				this.focusWidget = this;
				this.defaultFocus = null;
				this.decorations = MotifDecorations.All;
				this.functions = MotifFunctions.All;
				this.inputType = MotifInputType.Normal;
				this.transientFor = null;
				this.resizeTimer = null;
				this.expectedWidth = -1;
				this.expectedHeight = -1;

				// Top-level widgets receive all key and focus events.
				SelectInput(EventMask.KeyPressMask |
							EventMask.KeyReleaseMask |
							EventMask.FocusChangeMask |
							EventMask.StructureNotifyMask |
							EventMask.PropertyChangeMask);

				// We don't use WM properties if the parent is a CaptionWidget.
				if(parent is CaptionWidget)
				{
					return;
				}

				// Set the initial WM properties.
				try
				{
					// Lock down the display and get the window handle.
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();

					// Make this the group leader if we don't have one yet.
					bool isFirst = false;
					if(dpy.groupLeader == XWindow.Zero)
					{
						dpy.groupLeader = handle;
						isFirst = true;
					}

					// Set the WM_CLASS hint.
					Application app = Application.Primary;
					if(app != null)
					{
						XClassHint classHint = new XClassHint();
						classHint.res_name = app.ResourceName;
						classHint.res_class = app.ResourceClass;
						Xlib.XSetClassHint(display, handle, ref classHint);
						classHint.Free();
					}

					// Set the title bar and icon names.
					SetWindowName(display, handle, this.name);

					// Ask for "WM_DELETE_WINDOW" and "WM_TAKE_FOCUS".
					SetProtocols(display, handle);

					// Set the window hints.
					if(isFirst && app != null && app.StartIconic)
					{
						// The user supplied "-iconic" on the command-line.
						iconic = true;
					}
					SetWMHints(display, handle);

					// Set some other string properties.
					String cultureName = CultureInfo.CurrentCulture.Name;
					if(cultureName == null || (cultureName.Length == 0))
					{
						cultureName = "en_US";
					}
					else
					{
						cultureName = cultureName.Replace("-", "_");
					}
					SetTextProperty(display, handle, "WM_LOCALE_NAME",
									cultureName);
					String hostname = Application.Hostname;
					if(hostname != null)
					{
						SetTextProperty(display, handle,
										"WM_CLIENT_MACHINE", hostname);
					}
					if(isFirst)
					{
						String[] args = Environment.GetCommandLineArgs();
						if(args != null && args.Length > 0)
						{
							// We put "ilrun" at the start of the command,
							// because the command needs to be in a form
							// that can be directly executed by fork/exec,
							// and IL binaries normally aren't in this form.
							String[] newArgs = new String [args.Length + 1];
							newArgs[0] = "ilrun";
							Array.Copy(args, 0, newArgs, 1, args.Length);
							SetTextProperty(display, handle,
											"WM_COMMAND", newArgs);
						}
					}

				#if CONFIG_EXTENDED_DIAGNOSTICS
					// Put the process ID on the window.
					int pid = Process.GetCurrentProcess().Id;
					if(pid != -1 && pid != 0)
					{
						Xlib.XChangeProperty
							(display, handle,
							 Xlib.XInternAtom(display, "_NET_WM_PID",
							 				  XBool.False),
							 Xlib.XInternAtom(display, "CARDINAL",
							 				  XBool.False),
							 32, 0 /* PropModeReplace */,
							 new Xlib.Xlong [] {(Xlib.Xlong)(pid)}, 1);
					}
				#endif
				}
				finally
				{
					dpy.Unlock();
				}
			}