// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				ButtonName button;
				XTime time;
	
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.ButtonPress:
					{
						// Process button events.
						button = xevent.xbutton.button;
						time = xevent.xbutton.time;
						if(lastClickButton == button &&
						   lastClickTime != XTime.CurrentTime &&
						   (time - lastClickTime) < 500)
						{
							OnButtonDoubleClick(xevent.xbutton.x,
								        		xevent.xbutton.y, button,
								        		xevent.xbutton.state);
							time = XTime.CurrentTime;
						}
						else
						{
							OnButtonPress(xevent.xbutton.x,
								  		  xevent.xbutton.y, button,
								  		  xevent.xbutton.state);
						}
						lastClickTime = time;
						lastClickButton = button;
					}
					break;

					case EventType.ButtonRelease:
					{
						// Dispatch a button release event.
						button = xevent.xbutton.button;
						OnButtonRelease(xevent.xbutton.x,
										xevent.xbutton.y, button,
										xevent.xbutton.state);
					}
					break;

					case EventType.MotionNotify:
					{
						// Dispatch a pointer motion event.
						OnPointerMotion(xevent.xmotion.x,
								   	    xevent.xmotion.y,
								   	    xevent.xmotion.state);
					}
					break;

					case EventType.EnterNotify:
					{
						// Dispatch a widget enter event.
						Widget child = dpy.handleMap
							[xevent.xcrossing.subwindow];
						OnEnter(child,
							    xevent.xcrossing.x,
							    xevent.xcrossing.y,
							    xevent.xcrossing.state,
							    xevent.xcrossing.mode,
							    xevent.xcrossing.detail);
					}
					break;

					case EventType.LeaveNotify:
					{
						// Dispatch a widget leave event.
						Widget child = dpy.handleMap
							[xevent.xcrossing.subwindow];
						OnLeave(child,
							    xevent.xcrossing.x,
							    xevent.xcrossing.y,
							    xevent.xcrossing.state,
							    xevent.xcrossing.mode,
							    xevent.xcrossing.detail);
					}
					break;
				}
			}
		// 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);
				}
Exemplo n.º 3
0
	/// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				if(((EventType)(xevent.xany.type__)) ==
						EventType.PropertyNotify &&
				   xevent.xproperty.atom == resourceManager)
				{
					// The "RESOURCE_MANAGER" property has changed.
					IntPtr resptr = Xlib.XSharpGetResources
							(dpy.dpy, GetWidgetHandle());
					if(resptr != IntPtr.Zero)
					{
						resources = Marshal.PtrToStringAnsi(resptr);
						Xlib.XSharpFreeResources(resptr);
					}
					else
					{
						resources = null;
					}
					if(ResourcesChanged != null)
					{
						ResourcesChanged(this, EventArgs.Empty);
					}
				}
			}
Exemplo n.º 4
0
	extern public static int XNextEventWithTimeout
			(IntPtr display, out XEvent xevent, int timeout);
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				if (xevent.type == Xsharp.Events.EventType.DestroyNotify &&
				   xevent.xdestroywindow.window == child)
				{
					// The child window has been destroyed.
					ChildDestroyed();
				}
				base.DispatchEvent(ref xevent);
			}
Exemplo n.º 6
0
	protected void SendBeginInvoke(IntPtr i_gch)
			{
				XEvent xevent = new XEvent();
				xevent.xany.type = (int)(EventType.ClientMessage);
				xevent.xany.window = GetWidgetHandle();
				xevent.xclient.format = 32;
				xevent.xclient.setl(0,(int)i_gch);

				try
				{
					IntPtr display = dpy.Lock();
					xevent.xclient.message_type = Xlib.XInternAtom
							(display, "INTERNAL_BEGIN_INVOKE", XBool.False);
					Xlib.XSendEvent (display, GetWidgetHandle(),
							XBool.False, (int)(EventMask.NoEventMask), ref xevent);
					Xlib.XFlush(display);
				}
				finally
				{
					dpy.Unlock();
				}
			}
Exemplo n.º 7
0
	extern public static XStatus XSendEvent
			(IntPtr display, XWindow w, XBool propagate,
			 int event_mask, ref XEvent event_send);
Exemplo n.º 8
0
	// Send a fake "LeaveNotify" event to a popup window.
	private static void FakeLeave(InputOutputWidget window)
			{
				if(window != null)
				{
					XEvent xevent = new XEvent();
					xevent.xany.type__ =
						(Xlib.Xint)(int)(EventType.LeaveNotify);
					window.DispatchEvent(ref xevent);
				}
			}
Exemplo n.º 9
0
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				XKeySym keysym;
				PopupWindow popup;
				InputOutputWidget child = null;
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.ButtonPress:
					{
						// A mouse button was pressed during the grab.
						lock(this)
						{
							if(lastButton != null)
							{
								// We currently have a button window, so
								// all mouse events should go to it.
								popup = lastButton;
							}
							else
							{
								// Determine which popup contains the mouse.
								// If nothing contains, then use the top.
								popup = Find(xevent.xbutton.x_root,
											 xevent.xbutton.y_root, true);
							}
							lastButton = popup;
						}
						// Find the child window.
						child = FindChild(popup, xevent.xbutton.x_root,
							xevent.xbutton.y_root);
						ChangeEntered(popup, child);
						if(popup != null)
						{
							// Adjust the co-ordinates and re-dispatch.
							xevent.xbutton.x__ =
								(Xlib.Xint)(xevent.xbutton.x_root - popup.x);
							xevent.xbutton.y__ = 
								(Xlib.Xint)(xevent.xbutton.y_root - popup.y);
							popup.DispatchEvent(ref xevent);
							// Re-dispatch to the child window if necessary.
							if (child != null)
							{
								xevent.xbutton.x__ -= child.x;
								xevent.xbutton.y__ -= child.y;
								child.DispatchEvent(ref xevent);
							}
						}
					}
					break;

					case EventType.ButtonRelease:
					{
						// A mouse button was released during the grab.
						lock(this)
						{
							popup = lastButton;
							if(popup != null)
							{
								// Reset "lastButton" if this is the last
								// button to be released.
								ModifierMask mask = ModifierMask.AllButtons;
								mask &= (ModifierMask)~((int)ModifierMask.Button1Mask <<
									((int)(xevent.xbutton.button__) - 1));
								if((xevent.xbutton.state & mask) == 0)
								{
									lastButton = null;
								}
							}
						}
						// Find the child window.
						child = FindChild(popup, xevent.xbutton.x_root,
							xevent.xbutton.y_root);
						ChangeEntered(popup, child);
						if(popup != null)
						{
							// Adjust the co-ordinates and re-dispatch.
							xevent.xbutton.x__ =
								(Xlib.Xint)(xevent.xbutton.x_root - popup.x);
							xevent.xbutton.y__ = 
								(Xlib.Xint)(xevent.xbutton.y_root - popup.y);
							popup.DispatchEvent(ref xevent);
							// Re-dispatch to the child window if necessary.
							if (child != null)
							{
								xevent.xbutton.x__ -= child.x;
								xevent.xbutton.y__ -= child.y;
								child.DispatchEvent(ref xevent);
							}
						}
					}
					break;

					case EventType.MotionNotify:
					{
						// The mouse pointer was moved during the grab.
						lock(this)
						{
							// If there is a last button window, then use
							// that, otherwise find the one under the mouse.
							popup = lastButton;
							if(popup == null)
							{
								popup = Find(xevent.xmotion.x_root,
											 xevent.xmotion.y_root, false);
							}
						}
						// Find the child window.
						child = FindChild(popup, xevent.xbutton.x_root,
							xevent.xbutton.y_root);
						ChangeEntered(popup, child);
						if(popup != null)
						{
							// Adjust the co-ordinates and re-dispatch.
							xevent.xmotion.x__ =
								(Xlib.Xint)(xevent.xmotion.x_root - popup.x);
							xevent.xmotion.y__ = 
								(Xlib.Xint)(xevent.xmotion.y_root - popup.y);
							popup.DispatchEvent(ref xevent);
							// Re-dispatch to the child window if necessary.
							if (child != null)
							{
								xevent.xbutton.x__ -= child.x;
								xevent.xbutton.y__ -= child.y;
								child.DispatchEvent(ref xevent);
							}
						}
					}
					break;

					case EventType.KeyPress:
					{
						// Convert the event into a symbol and a string.
						if(keyBuffer == IntPtr.Zero)
						{
							keyBuffer = Marshal.AllocHGlobal(32);
						}
						keysym = 0;
						int len = Xlib.XLookupString
							(ref xevent.xkey, keyBuffer, 32,
							 ref keysym, IntPtr.Zero);
						String str;
						if(len > 0)
						{
							str = Marshal.PtrToStringAnsi(keyBuffer, len);
						}
						else
						{
							str = null;
						}

						// Dispatch the event to the top-most popup.
						lock(this)
						{
							if(list.Length > 0)
							{
								popup = list[list.Length - 1];
							}
							else
							{
								popup = null;
							}
						}
						if(popup != null)
						{
							// Find the child window.
							child = FindFocusedChild(popup);
							if (child == null)
								popup.DispatchKeyEvent
									((KeyName)keysym, xevent.xkey.state, str);
							else
								child.DispatchKeyEvent
									((KeyName)keysym, xevent.xkey.state, str);
						}
					}
					break;

					case EventType.KeyRelease:
					{
						// Convert the event into a symbol and a string.
						if(keyBuffer == IntPtr.Zero)
						{
							keyBuffer = Marshal.AllocHGlobal(32);
						}
						keysym = 0;
						int len = Xlib.XLookupString
							(ref xevent.xkey, keyBuffer, 32,
							 ref keysym, IntPtr.Zero);

						// Dispatch the event to the top-most popup.
						lock(this)
						{
							if(list.Length > 0)
							{
								popup = list[list.Length - 1];
							}
							else
							{
								popup = null;
							}
						}
						if(popup != null)
						{
							// Find the child window.
							child = FindFocusedChild(popup);
							if (child == null)
								popup.DispatchKeyReleaseEvent
									((KeyName)keysym, xevent.xkey.state);
							else
								child.DispatchKeyReleaseEvent
									((KeyName)keysym, xevent.xkey.state);
						}
					}
					break;

					default:
					{
						// Everything else is handled normally.
						base.DispatchEvent(ref xevent);
					}
					break;
				}
			}
Exemplo n.º 10
0
	// Dispatch an event that occurred on this display.  We currently
	// have the display lock.
	private void DispatchEvent(ref XEvent xevent)
			{
				// Find the widget that should process the event.
				Widget widget = handleMap[xevent.xany.window];

				// Record the time at which the event occurred.  We need
				// this to process keyboard and pointer grabs correctly.
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.KeyPress:
					case EventType.KeyRelease:
					{
						knownEventTime = xevent.xkey.time;
						if(widget != null && !(widget.Parent is RootWindow))
						{
							// KeyPress/KeyRelease events must be dispatched
							// via the top-level window, never via children.
							while(widget.Parent != null &&
							      !(widget.Parent is RootWindow))
							{
								widget = widget.Parent;
							}
						}
					}
					break;

					case EventType.ButtonPress:
					case EventType.ButtonRelease:
					{
						knownEventTime = xevent.xbutton.time;

						if (((xevent.xbutton.button == ButtonName.Button4) ||
						     (xevent.xbutton.button == ButtonName.Button5)) &&
						    ((widget != null) && !(widget.Parent is RootWindow)))
						{
							// Mousewheel events must be dispatched
							// via the top-level window, never via children.
							while (widget.Parent != null &&
							    !(widget.Parent is RootWindow))
							{
								widget = widget.Parent;
							}
						}
					}
					break;

					case EventType.MotionNotify:
					{
						knownEventTime = xevent.xmotion.time;
					}
					break;

					case EventType.EnterNotify:
					case EventType.LeaveNotify:
					{
						knownEventTime = xevent.xcrossing.time;
					}
					break;

					case EventType.PropertyNotify:
					{
						knownEventTime = xevent.xproperty.time;
					}
					break;

					case EventType.SelectionClear:
					{
						knownEventTime = xevent.xselectionclear.time;
					}
					break;

					case EventType.SelectionNotify:
					{
						knownEventTime = xevent.xselection.time;
					}
					break;

					case EventType.SelectionRequest:
					{
						knownEventTime = xevent.xselectionrequest.time;
					}
					break;

					default:
					{
						// We don't have a time value for this event.
						knownEventTime = XTime.CurrentTime;
					}
					break;
				}

				// Dispatch the event to the widget.
				if(widget != null)
				{
					widget.DispatchEvent(ref xevent);
				}
			}
Exemplo n.º 11
0
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				ButtonName button;
				XTime time;
	
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.ButtonPress:
					{
						// If we have a passive grab in force, then raise
						// this window and replay the event normally.
						if((flags & CaptionFlags.Grabbed) != 0)
						{
							Raise();
							try
							{
								IntPtr display = dpy.Lock();
								Xlib.XAllowEvents
									(display, 2 /* ReplayPointer */,
									 dpy.knownEventTime);
							}
							finally
							{
								dpy.Unlock();
							}
							return;
						}

						// Process button events.
						button = xevent.xbutton.button;
						time = xevent.xbutton.time;
						if(lastClickButton == button &&
						   lastClickTime != XTime.CurrentTime &&
						   (time - lastClickTime) < 500)
						{
							OnButtonDoubleClick(xevent.xbutton.x,
								        		xevent.xbutton.y,
												xevent.xbutton.x_root,
												xevent.xbutton.y_root,
												button, xevent.xbutton.state);
							time = XTime.CurrentTime;
						}
						else
						{
							OnButtonPress(xevent.xbutton.x,
								  		  xevent.xbutton.y,
								  		  xevent.xbutton.x_root,
								  		  xevent.xbutton.y_root,
										  button, xevent.xbutton.state);
						}
						lastClickTime = time;
						lastClickButton = button;
					}
					break;

					case EventType.ButtonRelease:
					{
						// Dispatch a button release event.
						button = xevent.xbutton.button;
						OnButtonRelease(xevent.xbutton.x,
										xevent.xbutton.y,
										xevent.xbutton.x_root,
										xevent.xbutton.y_root,
										button, xevent.xbutton.state);
					}
					break;

					case EventType.MotionNotify:
					{
						// Dispatch a pointer motion event.
						OnPointerMotion(xevent.xmotion.x,
								   	    xevent.xmotion.y,
								   	    xevent.xmotion.x_root,
								   	    xevent.xmotion.y_root,
								   	    xevent.xmotion.state);
					}
					break;

					default:
					{
						base.DispatchEvent(ref xevent);
					}
					break;
				}
			}
Exemplo n.º 12
0
	// Send a maximize or restore message to the window manager.
	private void SendMaximizeMessage
				(IntPtr display, XWindow handle, bool maximize)
			{
				XEvent xevent = new XEvent();
				xevent.xany.type = (int)(Xsharp.Events.EventType.ClientMessage);
				xevent.xany.window = handle;
				xevent.xclient.message_type = Xlib.XInternAtom
					(display, "_NET_WM_STATE", XBool.False);
				xevent.xclient.format = 32;
				if(maximize)
				{
					xevent.xclient.setl(0, 1 /* _NET_WM_STATE_ADD */ );
				}
				else
				{
					xevent.xclient.setl(0, 0 /* _NET_WM_STATE_REMOVE */ );
				}
				XAtom atom1 = Xlib.XInternAtom
					(display, "_NET_WM_STATE_MAXIMIZED_VERT", XBool.False);
				XAtom atom2 = Xlib.XInternAtom
					(display, "_NET_WM_STATE_MAXIMIZED_HORZ", XBool.False);
				xevent.xclient.setl(1, (int)atom1);
				xevent.xclient.setl(2, (int)atom2);
				Xlib.XSendEvent
					(display, screen.RootWindow.GetWidgetHandle(),
					 XBool.False, (int)(EventMask.NoEventMask),
					 ref xevent);
			}
Exemplo n.º 13
0
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				XKeySym keysym;
				Widget widget;
				InputOnlyWidget io;
				Xlib.Xlong[] data;

				switch((Xsharp.Events.EventType)(xevent.xany.type__))
				{
					case Xsharp.Events.EventType.ClientMessage:
						{
						// Handle messages from the window manager.
						if(xevent.xclient.message_type == dpy.wmProtocols)
						{
							if(xevent.xclient.l(0) == (int)(dpy.wmDeleteWindow))
							{
								// User wants the window to close.
								Close();
							}
							else if(xevent.xclient.l(0) == (int)(dpy.wmTakeFocus))
							{
								// We were given the primary input focus.
								PrimaryFocusIn();
							}
							else if(xevent.xclient.l(0) == (int)(dpy.wmContextHelp))
							{
								// The user pressed the "help" button.
								OnHelp();
							}
							else if(xevent.xclient.l(0) == (int)(dpy.wmPing))
							{
								// The window manager has pinged us to see
								// if we are still responding or are dead.
								// We send the message straight back to the WM.
								try
								{
									IntPtr display = dpy.Lock();
									xevent.xany.window = screen.RootWindow.GetWidgetHandle();
									Xlib.XSendEvent
										(display, xevent.xany.window,
										 XBool.False,
										 (int)(EventMask.NoEventMask),
										 ref xevent);
								}
								finally
								{
									dpy.Unlock();
								}
							}
						}
					}
					break;

				case Xsharp.Events.EventType.PropertyNotify:
					{
						// Handle a property change notification.
						if(xevent.xproperty.atom == dpy.wmState)
						{
							// The "WM_STATE" property has changed.
							if(xevent.xproperty.state == 0)
							{
								// New value for the window state.
								data = GetWindowProperty(dpy.wmState);
								if(data.Length >= 1 && data[0] == (Xlib.Xlong)3)
								{
									// The window is now in the iconic state.
									if(!iconic)
									{
										iconic = true;
										OnIconicStateChanged(true);
									}
								}
								else
								{
									// The window is now in the normal state.
									if(iconic)
									{
										iconic = false;
										OnIconicStateChanged(false);
									}
								}
							}
							else
							{
								// Property removed, so it is "normal" now.
								if(iconic)
								{
									iconic = false;
									OnIconicStateChanged(false);
								}
							}
						}
						else if(xevent.xproperty.atom == dpy.wmNetState)
						{
							// The "_NET_WM_STATE" property has changed.
							if(xevent.xproperty.state == 0)
							{
								// New value: look for maximized state atoms.
								data = GetWindowProperty(dpy.wmNetState);
								if(ContainsMaximizedAtom(data))
								{
									// The window is now maximized.
									if(!maximized)
									{
										maximized = true;
										OnMaximizedStateChanged(true);
									}
								}
								else
								{
									// The window has been restored.
									if(maximized)
									{
										maximized = false;
										OnMaximizedStateChanged(false);
									}
								}
							}
							else
							{
								// Value removed, so not maximized any more.
								if(maximized)
								{
									maximized = false;
									OnMaximizedStateChanged(false);
								}
							}
						}
						else if(xevent.xclient.message_type == dpy.internalBeginInvoke)
						{
							OnBeginInvokeMessage((IntPtr)xevent.xclient.l(0));
						}
					}
					break;

				case Xsharp.Events.EventType.FocusIn:
					{
						// This window has received the focus.
						PrimaryFocusIn();
					}
					break;

				case Xsharp.Events.EventType.FocusOut:
					{
						// This window has lost the focus.
						if(hasPrimaryFocus)
						{
							hasPrimaryFocus = false;
							if(focusWidget != null)
							{
								focusWidget.DispatchFocusOut(null);
							}
							OnPrimaryFocusOut();
						}
					}
					break;

				case Xsharp.Events.EventType.KeyPress:
					{
						// Convert the event into a symbol and a string.
						if(keyBuffer == IntPtr.Zero)
						{
							keyBuffer = Marshal.AllocHGlobal(32);
						}
						keysym = 0;
						int len = Xlib.XLookupString
							(ref xevent.xkey, keyBuffer, 32,
							 ref keysym, IntPtr.Zero);
						String str;
						if(len > 0)
						{
							str = Marshal.PtrToStringAnsi(keyBuffer, len);
						}
						else
						{
							str = null;
						}

						// Special case: check for Alt+F4 to close the window.
						// Some window managers trap Alt+F4 themselves, but not
						// all.  People who are used to System.Windows.Forms
						// under Windows expect Alt+F4 to close the window,
						// irrespective of what key the window manager uses.
						//
						// Note: this check is not foolproof.  The window
						// manager or the kernel may have redirected Alt+F4
						// for some other purpose (e.g. switching between
						// virtual consoles).  On such systems, there is
						// nothing that we can do to get the key event and
						// this code will never be called.
						//
						if((((KeyName)keysym) == KeyName.XK_F4 ||
						    ((KeyName)keysym) == KeyName.XK_KP_F4) &&
						   (xevent.xkey.state & ModifierMask.Mod1Mask) != 0)
						{
							Close();
							break;
						}

						// If we have an MDI client, then give it a chance
						// to process the keypress just in case it is
						// something like Ctrl+F4 or Ctrl+Tab.
						if(mdiClient != null)
						{
							if(mdiClient.DispatchKeyEvent
								((KeyName)keysym, xevent.xkey.state, str))
							{
								break;
							}
						}

						// Dispatch the event.
						widget = focusWidget;
						while(widget != null)
						{
							io = (widget as InputOnlyWidget);
							if(io != null)
							{
								if(io.DispatchKeyEvent
									((KeyName)keysym, xevent.xkey.state, str))
								{
									break;
								}
							}
							if(widget == this)
							{
								break;
							}
							widget = widget.Parent;
						}
					}
					break;

				case Xsharp.Events.EventType.KeyRelease:
					{
						// Convert the event into a symbol and a string.
						if(keyBuffer == IntPtr.Zero)
						{
							keyBuffer = Marshal.AllocHGlobal(32);
						}
						keysym = 0;
						int len = Xlib.XLookupString
							(ref xevent.xkey, keyBuffer, 32,
							 ref keysym, IntPtr.Zero);

						// Dispatch the event.
						widget = focusWidget;
						while(widget != null)
						{
							io = (widget as InputOnlyWidget);
							if(io != null)
							{
								if(io.DispatchKeyReleaseEvent
									((KeyName)keysym, xevent.xkey.state))
								{
									break;
								}
							}
							if(widget == this)
							{
								break;
							}
							widget = widget.Parent;
						}
					}
					break;

				case Xsharp.Events.EventType.ButtonPress:
					{
						if ((xevent.xbutton.button == ButtonName.Button4) ||
						    (xevent.xbutton.button == ButtonName.Button5))
							return;
					}
					break;

				case Xsharp.Events.EventType.ButtonRelease:
					{
						// Handle mouse wheel events.

						// Sanity check
						if ((xevent.xbutton.button != ButtonName.Button4) &&
						    (xevent.xbutton.button != ButtonName.Button5))
							break;

						// Dispatch the event.
						widget = focusWidget;
						while(widget != null)
						{
							io = (widget as InputOnlyWidget);
							if (io != null)
							{
								if (io.DispatchWheelEvent (ref xevent))
								{
									return;
								}
							}
							if (widget == this)
							{
								break;
							}
							widget = widget.Parent;
						}
					}
					break;

				case Xsharp.Events.EventType.ConfigureNotify:
					{
						// The window manager may have caused us to move/resize.
						if(xevent.xconfigure.window != xevent.window)
						{
							// SubstructureNotify - not interesting to us.
							break;
						}
						if(Parent is CaptionWidget)
						{
							// Ignore configure events if we are an MDI child.
							break;
						}
						if(xevent.xconfigure.width != width ||
						   xevent.xconfigure.height != height ||
						   expectedWidth != -1)
						{
							// The size has been changed by the window manager.
							if(expectedWidth == -1)
							{
								// Resize from the window manager, not us.
								width = xevent.xconfigure.width;
								height = xevent.xconfigure.height;
							}
							else if(expectedWidth == xevent.xconfigure.width &&
									expectedHeight == xevent.xconfigure.height)
							{
								// This is the size that we were expecting.
								// Further ConfigureNotify's will be from
								// the window manager instead of from us.
								expectedWidth = -1;
								expectedHeight = -1;
							}
							if(resizeTimer == null)
							{
								resizeTimer = new Timer
									(new TimerCallback(PerformResize), null,
									 0, -1);
							}
						}
						if(xevent.send_event || !reparented)
						{
							// The window manager moved us to a new position.
							if(x != xevent.xconfigure.x ||
							   y != xevent.xconfigure.y)
							{
								x = xevent.xconfigure.x;
								y = xevent.xconfigure.y;
								OnMoveResize(x, y, width, height);
							}
						}
					}
					break;

				case Xsharp.Events.EventType.ReparentNotify:
					{
						// We may have been reparented by the window manager.
						if(xevent.xreparent.window != (XWindow)handle)
						{
							// SubstructureNotify - not interesting to us.
							break;
						}
						if(xevent.xreparent.parent !=
								(XWindow)(screen.RootWindow.handle))
						{
							// Reparented by the window manager.
							reparented = true;
						}
						else
						{
							// Window manager crashed: we are back on the root.
							reparented = false;
							x = xevent.xreparent.x;
							y = xevent.xreparent.y;
							OnMoveResize(x, y, width, height);
						}
					}
					break;

				case Xsharp.Events.EventType.MapNotify:
					{
						// The window manager mapped us to the screen.
						if(Parent is CaptionWidget)
						{
							break;
						}
						if(iconic)
						{
							iconic = false;
							OnIconicStateChanged(false);
						}
						if(!mapped)
						{
							mapped = true;
							OnMapStateChanged();
						}
					}
					break;

				case Xsharp.Events.EventType.UnmapNotify:
					{
						// We were unmapped from the screen.  If "mapped"
						// is true, then we are being iconified by the window
						// manager.  Otherwise, we asked to be withdrawn.
						if(Parent is CaptionWidget)
						{
							break;
						}
						if(!iconic && mapped)
						{
							iconic = true;
							OnIconicStateChanged(true);
						}
					}
					break;
				}
				base.DispatchEvent(ref xevent);
			}
Exemplo n.º 14
0
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.SelectionClear:
					{
						// We have lost ownership of the selection.
						formats = null;
						values = null;
					}
					break;

					case EventType.SelectionRequest:
					{
						// Bail out if we received a request from ourselves!
						if(xevent.xselectionrequest.requestor ==
								GetWidgetHandle())
						{
							break;
						}

						// Build the SelectionNotify event for the reply.
						XEvent response = new XEvent();
						response.xany.type = (int)(EventType.SelectionNotify);
						response.xselection.requestor =
							xevent.xselectionrequest.requestor;
						response.xselection.selection =
							xevent.xselectionrequest.selection;
						response.xselection.target =
							xevent.xselectionrequest.target;
						response.xselection.property = XAtom.Zero;
						response.xselection.time =
							xevent.xselectionrequest.time;

						// TODO

						// Transmit the response back to the requestor.
						try
						{
							IntPtr display = dpy.Lock();
							Xlib.XSendEvent
								(display,
								 xevent.xselectionrequest.requestor,
								 XBool.False,
								 (int)(EventMask.NoEventMask),
								 ref response);
						}
						finally
						{
							dpy.Unlock();
						}
					}
					break;
				}
				base.DispatchEvent(ref xevent);
			}
	// Dispatch a mouse wheel event to this widget from the top-level window.
	internal bool DispatchWheelEvent(ref XEvent xevent)
			{
				if(FullSensitive)
				{
					return OnButtonWheel (xevent.xbutton.x, xevent.xbutton.y,
						xevent.xbutton.button, xevent.xbutton.state,
						(xevent.xbutton.button == ButtonName.Button4 ? 120 : -120));
				}
				else
				{
					return false;
				}
			}
Exemplo n.º 16
0
	extern public static int XNextEvent(IntPtr display, out XEvent xevent);
	// Dispatch an event to this widget.
	internal override void DispatchEvent(ref XEvent xevent)
			{
				switch((EventType)(xevent.xany.type__))
				{
					case EventType.Expose:
					case EventType.GraphicsExpose:
					{
						// Add the area to the expose region.
						if(exposeRegion == null)
						{
							// This is the first rectangle in an expose.
							exposeRegion = new Region
								((int)(xevent.xexpose.x__),
								 (int)(xevent.xexpose.y__),
								 (int)(xevent.xexpose.width__),
								 (int)(xevent.xexpose.height__));

							// Queue this widget for later repainting.
							// We don't do it now or the system will be
							// very slow during opaque window drags.
							dpy.AddPendingExpose(this);
						}
						else
						{
							// This is an extra rectangle in an expose.
							exposeRegion.Union
								((int)(xevent.xexpose.x__),
								 (int)(xevent.xexpose.y__),
								 (int)(xevent.xexpose.width__),
								 (int)(xevent.xexpose.height__));
						}
					}
					break;
					
					case Xsharp.Events.EventType.ClientMessage:
					{
						if(xevent.xclient.message_type == dpy.internalBeginInvoke)
						{
							OnBeginInvokeMessage((IntPtr)xevent.xclient.l(0));
						}
					}
					break;
				}
				base.DispatchEvent(ref xevent);
			}
Exemplo n.º 18
0
	} // class WidgetEnumerator

	/// Dispatch an event to this widget.
	internal virtual void DispatchEvent(ref XEvent xevent)
			{
				// Nothing to do here: overridden by subclasses.
			}