// Get the contents of a 32-bit window property.
	private Xlib.Xlong[] GetWindowProperty(XAtom name)
			{
				try
				{
					// Lock down the display and get the window handle.
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();

					// Fetch the value of the property.
					XAtom actualTypeReturn;
					Xlib.Xint actualFormatReturn;
					Xlib.Xulong nitemsReturn;
					Xlib.Xulong bytesAfterReturn;
					IntPtr propReturn;
					nitemsReturn = Xlib.Xulong.Zero;
					if(Xlib.XGetWindowProperty
							(display, handle, name, 0, 256,
							 XBool.False, XAtom.Zero,
							 out actualTypeReturn, out actualFormatReturn,
							 out nitemsReturn, out bytesAfterReturn,
							 out propReturn) == XStatus.Zero)
					{
						if(((uint)bytesAfterReturn) > 0)
						{
							// We didn't get everything, so try again.
							if(propReturn != IntPtr.Zero)
							{
								Xlib.XFree(propReturn);
								propReturn = IntPtr.Zero;
							}
							int length = 256 + (((int)bytesAfterReturn) / 4);
							nitemsReturn = Xlib.Xulong.Zero;
							if(Xlib.XGetWindowProperty
									(display, handle, name, 0, length,
									 XBool.False, XAtom.Zero,
									 out actualTypeReturn,
									 out actualFormatReturn,
									 out nitemsReturn, out bytesAfterReturn,
									 out propReturn) != XStatus.Zero)
							{
								propReturn = IntPtr.Zero;
								nitemsReturn = Xlib.Xulong.Zero;
							}
						}
					}
					else
					{
						propReturn = IntPtr.Zero;
						nitemsReturn = Xlib.Xulong.Zero;
					}

					// Convert the property data into an array of longs.
					Xlib.Xlong[] data = new Xlib.Xlong [(int)nitemsReturn];
					int size, posn;
					unsafe
					{
						size = sizeof(Xlib.Xlong);
					}
					for(posn = 0; posn < (int)nitemsReturn; ++posn)
					{
						if(size == 4)
						{
							data[posn] = (Xlib.Xlong)
								Marshal.ReadInt32(propReturn, size * posn);
						}
						else if(size == 8)
						{
							data[posn] = (Xlib.Xlong)
								Marshal.ReadInt64(propReturn, size * posn);
						}
					}

					// Free the property data.
					if(propReturn != IntPtr.Zero)
					{
						Xlib.XFree(propReturn);
					}

					// Return the final data to the caller.
					return data;
				}
				finally
				{
					dpy.Unlock();
				}
			}
	// Set the "_NET_WM_STATE" property, to include extended state requests.
	private void SetNetState(IntPtr display, XWindow handle)
			{
				Xlib.Xlong[] atoms = new Xlib.Xlong [8];
				int numAtoms = 0;

				// Determine if the window should be hidden from the taskbar.
				if((otherHints & OtherHints.HideFromTaskBar) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_SKIP_TASKBAR",
							 XBool.False);

					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_SKIP_PAGER",
							 XBool.False);
				}

				// Determine if the window should be made top-most on-screen.
				if((otherHints & OtherHints.TopMost) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_ABOVE",
						     XBool.False);
				}

				// Determine if we should stick in a fixed position
				if((otherHints & OtherHints.Sticky) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_STICKY",
						    XBool.False);
				}

				// Determine if we should shade
				if((otherHints & OtherHints.Shaded) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_SHADED",
						    XBool.False);
				}

				// Determine if we should hide
				if((otherHints & OtherHints.Hidden) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_HIDDEN",
						    XBool.False);
				}

				// Determine if we should go full screen
				if((otherHints & OtherHints.FullScreen) != 0)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_FULLSCREEN",
						    XBool.False);
				}

				// Determine if the window should be maximized by default.
				if(maximized)
				{
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_MAXIMIZED_VERT",
						     XBool.False);
					atoms[numAtoms++] =
						(Xlib.Xlong)Xlib.XInternAtom
							(display, "_NET_WM_STATE_MAXIMIZED_HORZ",
						     XBool.False);
				}

				// Update the "_NET_WM_STATE" property as appropriate.
				XAtom type = Xlib.XInternAtom
					(display, "ATOM", XBool.False);
				if(numAtoms > 0)
				{
					Xlib.XChangeProperty
						(display, handle, dpy.wmNetState, type,
						 32, 0 /* PropModeReplace */, atoms, numAtoms);
				}
				else
				{
					Xlib.XDeleteProperty(display, handle, dpy.wmNetState);
				}
			}
	// Update the Motif hint information in the X server.
	private void UpdateMotifHints()
			{
				// Bail out if the caption widget handled the decorations.
				if(!Caption(CaptionWidget.Operation.Decorations))
				{
					return;
				}

				// Build the Motif hint structure.
				Xlib.Xlong[] hint = new Xlib.Xlong [5];
				int flags = 0;
				if(functions != MotifFunctions.All)
				{
					hint[1] = (Xlib.Xlong)(int)functions;
					flags |= 1;
				}
				else
				{
					hint[1] = (Xlib.Xlong)(-1);
				}
				if(decorations != MotifDecorations.All)
				{
					hint[2] = (Xlib.Xlong)(int)decorations;
					flags |= 2;
				}
				else
				{
					hint[2] = (Xlib.Xlong)(-1);
				}
				if(inputType != MotifInputType.Normal)
				{
					hint[3] = (Xlib.Xlong)(int)inputType;
					flags |= 4;
				}
				else
				{
					hint[3] = (Xlib.Xlong)(-1);
				}
				hint[4] = (Xlib.Xlong)(-1);
				hint[0] = (Xlib.Xlong)flags;

				// Set the Motif hint structure on the window.
				try
				{
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();
					Xlib.XChangeProperty
						(display, handle, dpy.wmMwmHints, dpy.wmMwmHints,
						 32, 0 /* PropModeReplace */, hint, 4);
				}
				finally
				{
					dpy.Unlock();
				}
			}