Beispiel #1
0
	extern public static int XReconfigureWMWindow
			(IntPtr display, XWindow w, int screen_number,
			 uint value_mask, ref XWindowChanges changes);
		// Dispatch an event to this widget.
		internal override void DispatchEvent(ref XEvent xevent)
				{
					IntPtr display;
					XWindow child;
					if (xevent.type == Xsharp.Events.EventType.MapRequest)
					{
						// This may be notification of a new window
						// that we need to take control of.
						try
						{
							display = dpy.Lock();
							child = xevent.xmaprequest.window;
							if(WantThisWindow(display, child))
							{
								// This is the top-level child window that
								// we have been waiting for.
								XWindowChanges wc = new XWindowChanges();
								wc.width = embedParent.Width;
								wc.height = embedParent.Height;
								wc.border_width = 0;
								Xlib.XConfigureWindow
									(display, child,
									 (int)(ConfigureWindowMask.CWWidth |
									 	   ConfigureWindowMask.CWHeight |
									 	   ConfigureWindowMask.CWBorderWidth),
									 ref wc);
								Xlib.XReparentWindow
									(display, child,
									 embedParent.GetWidgetHandle(), 0, 0);
								Xlib.XMapWindow(display, child);
								embedParent.child = child;
							}
							else
							{
								// We don't want this window, or we already
								// know about it, so replay the map request.
								Xlib.XMapWindow(display, child);
							}
						}
						finally
						{
							dpy.Unlock();
						}
					}
					else if (xevent.type == Xsharp.Events.EventType.ConfigureRequest)
					{
						// Replay the configure event direct to the X server.
						XWindowChanges wc = new XWindowChanges();
						wc.x = xevent.xconfigurerequest.x;
						wc.y = xevent.xconfigurerequest.y;
						wc.width = xevent.xconfigurerequest.width;
						wc.height = xevent.xconfigurerequest.height;
						wc.border_width = xevent.xconfigurerequest.border_width;
						wc.sibling = xevent.xconfigurerequest.above;
						wc.stack_mode = xevent.xconfigurerequest.detail;
						try
						{
							display = dpy.Lock();
							Xlib.XConfigureWindow
								(display,
								 xevent.xconfigurerequest.window,
								 xevent.xconfigurerequest.value_mask, ref wc);
						}
						finally
						{
							dpy.Unlock();
						}
					}
					base.DispatchEvent(ref xevent);
				}
Beispiel #3
0
	extern public static int XConfigureWindow
			(IntPtr display, XWindow w, uint value_mask,
			 ref XWindowChanges changes);
	// Perform a MoveResize request.
	internal override void PerformMoveResize
				(IntPtr display, int newX, int newY,
				 int newWidth, int newHeight)
			{
				// If our parent is a caption widget, then let it
				// handle the move/resize operation so that the
				// borders can be adjusted to match the request.
				if(Parent is CaptionWidget)
				{
					((CaptionWidget)Parent).PerformChildResize
						(newX, newY, newWidth, newHeight);
					return;
				}

				XWindow handle = GetWidgetHandle();
				XWindowChanges changes = new XWindowChanges();
				ConfigureWindowMask mask = (ConfigureWindowMask)0;

				// If we haven't mapped the window to the screen yet,
				// then set the size hints and bail out with a normal
				// move/resize event.
				if(!firstMapDone)
				{
					XSizeHints hints = BuildSizeHints
						(newX, newY, newWidth, newHeight);
					Xlib.XSetWMNormalHints(display, handle, ref hints);
					if(newWidth != width || newHeight != height)
					{
						expectedWidth = newWidth;
						expectedHeight = newHeight;
					}
					base.PerformMoveResize
						(display, newX, newY, newWidth, newHeight);
					return;
				}

				// Collect up the changes that need to be performed.
				if(newX != x || newY != y)
				{
					if(newWidth != width || newHeight != height)
					{
						changes.x = newX;
						changes.y = newY;
						changes.width = newWidth;
						changes.height = newHeight;
						expectedWidth = newWidth;
						expectedHeight = newHeight;
						mask = ConfigureWindowMask.CWX |
							   ConfigureWindowMask.CWY |
							   ConfigureWindowMask.CWWidth |
							   ConfigureWindowMask.CWHeight;
					}
					else
					{
						changes.x = newX;
						changes.y = newY;
						mask = ConfigureWindowMask.CWX |
							   ConfigureWindowMask.CWY;
					}
				}
				else if(newWidth != width || newHeight != height)
				{
					changes.width = newWidth;
					changes.height = newHeight;
					expectedWidth = newWidth;
					expectedHeight = newHeight;
					mask = ConfigureWindowMask.CWWidth |
						   ConfigureWindowMask.CWHeight;
				}

				// Send the reconfiguration request to the window manager.
				if(mask != (ConfigureWindowMask)0)
				{
					Xlib.XReconfigureWMWindow
							(display, handle,
							 Screen.ScreenNumber,
						     (uint)mask,
							 ref changes);
				}
			}
	/// <summary>
	/// <para>Lower this widget to the bottom of its layer.</para>
	/// </summary>
	public override void Lower()
			{
				if(!Caption(CaptionWidget.Operation.Lower))
				{
					return;
				}
				try
				{
					// Send a message to the window manager to restack us.
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();
					XWindowChanges changes = new XWindowChanges();
					changes.stack_mode = 1;		/* Below */
					Xlib.XReconfigureWMWindow
							(display, handle,
							 Screen.ScreenNumber,
						     (uint)(ConfigureWindowMask.CWStackMode),
							 ref changes);
				}
				finally
				{
					dpy.Unlock();
				}
			}
	// Reposition this widget above one of its siblings.
	private void RepositionAbove(Widget child)
			{
				// Detach ourselves from the widget tree.
				if(nextAbove != null)
				{
					nextAbove.nextBelow = nextBelow;
				}
				else
				{
					parent.topChild = nextBelow;
				}
				if(nextBelow != null)
				{
					nextBelow.nextAbove = nextAbove;
				}

				// Re-insert at the new position.
				nextAbove = child.nextAbove;
				nextBelow = child;
				if(nextAbove != null)
				{
					nextAbove.nextBelow = this;
				}
				else
				{
					parent.topChild = this;
				}
				child.nextAbove = this;

				try
				{
					IntPtr display = dpy.Lock();
					XWindowChanges changes = new XWindowChanges();
					changes.stack_mode = 0;		/* Above */
					if(child is TopLevelWindow)
					{
						Xlib.XConfigureWindow
								(display, GetWidgetHandle(),
							     (uint)(ConfigureWindowMask.CWStackMode),
								 ref changes);
					}
					else
					{
						changes.sibling = child.GetWidgetHandle();
						Xlib.XConfigureWindow
								(display, GetWidgetHandle(),
							     (uint)(ConfigureWindowMask.CWSibling |
								 	    ConfigureWindowMask.CWStackMode),
								 ref changes);
					}
				}
				finally
				{
					dpy.Unlock();
				}
			}
	/// <summary>
	/// <para>Lower this widget to the bottom of its layer.</para>
	/// </summary>
	public override void Lower()
			{
				if(IsMapped)
				{
					GetGrabWindow().LowerPopup(this);
				}

				try
				{
					IntPtr display = dpy.Lock();
					XWindowChanges changes = new XWindowChanges();
					changes.stack_mode = 0;		/* Above */

						Xlib.XConfigureWindow
								(display, GetWidgetHandle(),
							     (uint)(ConfigureWindowMask.CWStackMode),
								 ref changes);
				}
				finally
				{
					dpy.Unlock();
				}
			}