diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-11-13 14:48:41 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-11-13 14:48:41 +0100 |
| commit | e6541b353e7a0ecfd2e514e5c9c6f6c9c1ba96b1 (patch) | |
| tree | 8f3e5ecd92e3a6b5a328e514d6c14fa703bba9e6 /src | |
| parent | 65820f61457262b631eba35283c55135aecbc5f2 (diff) | |
first try with xlib
Diffstat (limited to 'src')
| -rw-r--r-- | src/Cairo/CairoHelpers.cs | 4 | ||||
| -rw-r--r-- | src/Colors.cs | 9 | ||||
| -rw-r--r-- | src/GraphicObjects/Border.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 17 | ||||
| -rw-r--r-- | src/GraphicObjects/ScrollBar.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/Slider.cs | 9 | ||||
| -rw-r--r-- | src/GraphicObjects/Splitter.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/Trend.cs | 4 | ||||
| -rw-r--r-- | src/Interface.cs | 314 | ||||
| -rw-r--r-- | src/Mono.Cairo/Antialias.cs | 2 | ||||
| -rw-r--r-- | src/StyleReader.cs | 14 | ||||
| -rw-r--r-- | src/XLib/Display.cs | 64 | ||||
| -rw-r--r-- | src/XLib/NativeMethods.cs | 48 | ||||
| -rw-r--r-- | src/XLib/Window.cs | 62 | ||||
| -rw-r--r-- | src/XLib/X11Structs.cs | 1822 |
15 files changed, 2254 insertions, 125 deletions
diff --git a/src/Cairo/CairoHelpers.cs b/src/Cairo/CairoHelpers.cs index 44060259..3b771c38 100644 --- a/src/Cairo/CairoHelpers.cs +++ b/src/Cairo/CairoHelpers.cs @@ -107,7 +107,7 @@ namespace Crow gr.LineTo(r.TopRight); gr.Stroke(); - gr.SetSourceColor(Color.DarkGray); + gr.SetSourceColor(Color.DarkGrey); gr.MoveTo(r.TopRight); gr.LineTo(r.BottomRight); gr.LineTo(r.BottomLeft); @@ -120,7 +120,7 @@ namespace Crow gr.Save(); r.Inflate((int)-width / 2, (int)-width / 2); gr.LineWidth = width; - gr.SetSourceColor(Color.DarkGray); + gr.SetSourceColor(Color.DarkGrey); gr.MoveTo(r.BottomLeft); gr.LineTo(r.TopLeft); gr.LineTo(r.TopRight); diff --git a/src/Colors.cs b/src/Colors.cs index 0b1b3ad7..8e501b33 100644 --- a/src/Colors.cs +++ b/src/Colors.cs @@ -202,7 +202,7 @@ namespace Crow double max = Math.Max (R, Math.Max (G, B)); //Max. value of RGB double diff = max - min; //Delta RGB value - if ( diff == 0 )//This is a gray, no chroma... + if ( diff == 0 )//This is a grey, no chroma... return 0; double h = 0.0, s = diff / max; @@ -302,7 +302,6 @@ namespace Crow public static readonly Color DarkBlue = new Color(0,0,139,"DarkBlue","#00008B"); public static readonly Color DarkCyan = new Color(0,139,139,"DarkCyan","#008B8B"); public static readonly Color DarkGoldenRod = new Color(184,134,11,"DarkGoldenRod","#B8860B"); - public static readonly Color DarkGray = new Color(169,169,169,"DarkGray","#A9A9A9"); public static readonly Color DarkGrey = new Color(169,169,169,"DarkGrey","#A9A9A9"); public static readonly Color DarkGreen = new Color(0,100,0,"DarkGreen","#006400"); public static readonly Color DarkKhaki = new Color(189,183,107,"DarkKhaki","#BDB76B"); @@ -314,13 +313,11 @@ namespace Crow public static readonly Color DarkSalmon = new Color(233,150,122,"DarkSalmon","#E9967A"); public static readonly Color DarkSeaGreen = new Color(143,188,143,"DarkSeaGreen","#8FBC8F"); public static readonly Color DarkSlateBlue = new Color(72,61,139,"DarkSlateBlue","#483D8B"); - public static readonly Color DarkSlateGray = new Color(47,79,79,"DarkSlateGray","#2F4F4F"); public static readonly Color DarkSlateGrey = new Color(47,79,79,"DarkSlateGrey","#2F4F4F"); public static readonly Color DarkTurquoise = new Color(0,206,209,"DarkTurquoise","#00CED1"); public static readonly Color DarkViolet = new Color(148,0,211,"DarkViolet","#9400D3"); public static readonly Color DeepPink = new Color(255,20,147,"DeepPink","#FF1493"); public static readonly Color DeepSkyBlue = new Color(0,191,255,"DeepSkyBlue","#00BFFF"); - public static readonly Color DimGray = new Color(105,105,105,"DimGray","#696969"); public static readonly Color DimGrey = new Color(105,105,105,"DimGrey","#696969"); public static readonly Color DodgerBlue = new Color(30,144,255,"DodgerBlue","#1E90FF"); public static readonly Color FireBrick = new Color(178,34,34,"FireBrick","#B22222"); @@ -331,7 +328,6 @@ namespace Crow public static readonly Color GhostWhite = new Color(248,248,255,"GhostWhite","#F8F8FF"); public static readonly Color Gold = new Color(255,215,0,"Gold","#FFD700"); public static readonly Color GoldenRod = new Color(218,165,32,"GoldenRod","#DAA520"); - public static readonly Color Gray = new Color(128,128,128,"Gray","#808080"); public static readonly Color Grey = new Color(128,128,128,"Grey","#808080"); public static readonly Color Green = new Color(0,128,0,"Green","#008000"); public static readonly Color GreenYellow = new Color(173,255,47,"GreenYellow","#ADFF2F"); @@ -350,14 +346,12 @@ namespace Crow public static readonly Color LightCoral = new Color(240,128,128,"LightCoral","#F08080"); public static readonly Color LightCyan = new Color(224,255,255,"LightCyan","#E0FFFF"); public static readonly Color LightGoldenRodYellow = new Color(250,250,210,"LightGoldenRodYellow","#FAFAD2"); - public static readonly Color LightGray = new Color(211,211,211,"LightGray","#D3D3D3"); public static readonly Color LightGrey = new Color(211,211,211,"LightGrey","#D3D3D3"); public static readonly Color LightGreen = new Color(144,238,144,"LightGreen","#90EE90"); public static readonly Color LightPink = new Color(255,182,193,"LightPink","#FFB6C1"); public static readonly Color LightSalmon = new Color(255,160,122,"LightSalmon","#FFA07A"); public static readonly Color LightSeaGreen = new Color(32,178,170,"LightSeaGreen","#20B2AA"); public static readonly Color LightSkyBlue = new Color(135,206,250,"LightSkyBlue","#87CEFA"); - public static readonly Color LightSlateGray = new Color(119,136,153,"LightSlateGray","#778899"); public static readonly Color LightSlateGrey = new Color(119,136,153,"LightSlateGrey","#778899"); public static readonly Color LightSteelBlue = new Color(176,196,222,"LightSteelBlue","#B0C4DE"); public static readonly Color LightYellow = new Color(255,255,224,"LightYellow","#FFFFE0"); @@ -412,7 +406,6 @@ namespace Crow public static readonly Color Silver = new Color(192,192,192,"Silver","#C0C0C0"); public static readonly Color SkyBlue = new Color(135,206,235,"SkyBlue","#87CEEB"); public static readonly Color SlateBlue = new Color(106,90,205,"SlateBlue","#6A5ACD"); - public static readonly Color SlateGray = new Color(112,128,144,"SlateGray","#708090"); public static readonly Color SlateGrey = new Color(112,128,144,"SlateGrey","#708090"); public static readonly Color Snow = new Color(255,250,250,"Snow","#FFFAFA"); public static readonly Color SpringGreen = new Color(0,255,127,"SpringGreen","#00FF7F"); diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index adeb32e7..63f2c68f 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -54,8 +54,8 @@ namespace Crow #region private fields int _borderWidth; BorderStyle _borderStyle; - Fill raisedColor = Color.Gray; - Fill sunkenColor = Color.DimGray; + Fill raisedColor = Color.Grey; + Fill sunkenColor = Color.DimGrey; #endregion #region public properties diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index bc955368..49decd8d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1411,7 +1411,7 @@ namespace Crow (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); // //prevent queueing same LayoutingType for this -// layoutType &= (~RegisteredLayoutings); + layoutType &= (~RegisteredLayoutings); if (layoutType == LayoutingType.None) return; @@ -1626,9 +1626,8 @@ namespace Crow Debug.WriteLine (string.Format("RecreateCache -> {0}", this.ToString ())); #endif IsDirty = false; - if (bmp != null) - bmp.Dispose (); - bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height); + bmp?.Dispose (); + bmp = IFace.surf.CreateSimilar(Content.ColorAlpha, Slot.Width, Slot.Height); using (Context gr = new Context (bmp)) { gr.Antialias = Interface.Antialias; onDraw (gr); @@ -1701,13 +1700,13 @@ namespace Crow #region Keyboard handling public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){ - KeyDown.Raise (sender, e); + KeyDown.Raise (this, e); } public virtual void onKeyUp(object sender, KeyboardKeyEventArgs e){ - KeyUp.Raise (sender, e); + KeyUp.Raise (this, e); } public virtual void onKeyPress(object sender, KeyPressEventArgs e){ - KeyPress.Raise (sender, e); + KeyPress.Raise (this, e); } #endregion @@ -1719,7 +1718,9 @@ namespace Crow /// <returns>return true, if point is in the bounds of this control</returns> /// <param name="m">by ref point to test, init value is not kept</param> public virtual bool PointIsIn(ref Point m) - { + { + if (parent == null) + return false; if (!(Visible & isEnabled)||IsDragged) return false; if (!parent.PointIsIn(ref m)) diff --git a/src/GraphicObjects/ScrollBar.cs b/src/GraphicObjects/ScrollBar.cs index 5dac20e1..f7f03073 100644 --- a/src/GraphicObjects/ScrollBar.cs +++ b/src/GraphicObjects/ScrollBar.cs @@ -54,6 +54,10 @@ namespace Crow return; _orientation = value; NotifyValueChanged ("Orientation", _orientation); + if (_orientation == Orientation.Horizontal) + NotifyValueChanged ("ScrollBackShape", "M 0.5,5.5 L 10.5, 0.5 L 10.5,0.5 Z"); + else + NotifyValueChanged ("ScrollBackShape", "M 5.5,0.5 L 10.5,10.5 L 0.5,10.5 Z"); RegisterForGraphicUpdate (); } } diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 2bdd5b8a..64668c48 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -68,7 +68,7 @@ namespace Crow protected double unity; #region Public properties - [DefaultValue("vgradient|0:White|0,1:LightGray|0,9:LightGray|1:DimGray")] + [DefaultValue("vgradient|0:White|0,1:LightGrey|0,9:LightGrey|1:DimGrey")] public virtual Fill CursorColor { get { return _cursorColor; } set { @@ -121,6 +121,7 @@ namespace Crow protected override void onDraw (Context gr) { base.onDraw (gr); + if (Maximum <= 0) return; @@ -141,6 +142,10 @@ namespace Crow pEnd.X += 0.5; } + + Background.SetAsSource (gr,r); + gr.Rectangle (r); + gr.Fill (); DrawGraduations (gr, pStart,pEnd); @@ -184,7 +189,7 @@ namespace Crow cursor.TopLeft = new Point ((int)(p1.X - r.Width / 2), r.Top + (int)((Value - Minimum) * unity)); } - cursor.Inflate (-1); + //cursor.Inflate (-1); } Point mouseDownInit; double mouseDownInitValue; diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index 84e1ade0..3a12b784 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -141,7 +141,7 @@ namespace Crow { base.onMouseMove (sender, e); - if (!IsActive) + if (!IsActive || go1 == null || go2 == null) return; GenericStack gs = Parent as GenericStack; diff --git a/src/GraphicObjects/Trend.cs b/src/GraphicObjects/Trend.cs index e9d3c2d3..10c5422c 100644 --- a/src/GraphicObjects/Trend.cs +++ b/src/GraphicObjects/Trend.cs @@ -60,7 +60,7 @@ namespace Crow AddValue (value); } } - [XmlAttributeAttribute()][DefaultValue(100)] + [XmlAttributeAttribute()][DefaultValue(400)] public virtual int NbValues { get { return nbValues; } set { @@ -97,7 +97,7 @@ namespace Crow RegisterForRedraw (); } } - [XmlAttributeAttribute()][DefaultValue(20.0)] + [XmlAttributeAttribute()][DefaultValue(1.0)] public virtual double LowThreshold { get { return lowThreshold; } set { diff --git a/src/Interface.cs b/src/Interface.cs index cc62a1aa..69fa36f8 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -36,6 +36,9 @@ using System.Xml.Serialization; using Cairo; using System.Globalization; using Crow.IML; +using System.Runtime.InteropServices; + + namespace Crow { @@ -63,8 +66,22 @@ namespace Crow /// The resulting surface (a byte array in the OpenTK renderer) is made available and protected with the /// RenderMutex of the interface. /// </remarks> - public class Interface : ILayoutable + public class Interface : ILayoutable, IDisposable ,IValueChange { + #region IValueChange implementation + public event EventHandler<ValueChangeEventArgs> ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value); + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + internal IntPtr xHandle, xwinHnd, xDefaultRootWin, xDefaultVisual; + internal UInt32 xDefaultDepth; + internal Int32 xScreen; + XLib.XErrorHandler errorHnd; + #region CTOR static Interface(){ if (Type.GetType ("Mono.Runtime") == null) { @@ -94,18 +111,159 @@ namespace Crow FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } - public Interface(){ - CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + + public Interface(int width=800, int height=600){ + + clientRectangle = new Rectangle (0, 0, width, height); + + Init (); + + initX (); + } + private int HandleError (IntPtr display, ref XLib.XErrorEvent error_event) + { + /*if (ErrorExceptions) + throw new X11Exception (error_event.display, error_event.resourceid, + error_event.serial, error_event.error_code, + error_event.request_code, error_event.minor_code); + else + Console.WriteLine ("X11 Error encountered: {0}{1}\n", + X11Exception.GetMessage(error_event.display, error_event.resourceid, + error_event.serial, error_event.error_code, + error_event.request_code, error_event.minor_code), + WhereString());*/ + Debug.WriteLine ("XERROR {0}", error_event.error_code); + return 0; + } + #endregion + + void interfaceThread() + { + while (true) { + Update (); + + if (XLib.NativeMethods.XPending (xHandle) > 0) { + XLib.XEvent xevent = new XLib.XEvent (); + XLib.NativeMethods.XNextEvent (xHandle, ref xevent); + + switch (xevent.type) { + case XLib.XEventName.Expose: + ProcessResize (new Rectangle (0, 0, xevent.ExposeEvent.width, xevent.ExposeEvent.height)); + break; + case XLib.XEventName.KeyPress: + ProcessKeyDown (xevent.KeyEvent.keycode); + //Debug.WriteLine ("keypress: {0}", xevent.KeyEvent.keycode); + break; + case XLib.XEventName.KeyRelease: + ProcessKeyUp (xevent.KeyEvent.keycode); + //Debug.WriteLine ("keypress: {0}", xevent.KeyEvent.keycode); + break; + case XLib.XEventName.MotionNotify: + //Debug.WriteLine ("motion: ({0},{1})", xevent.MotionEvent.x, xevent.MotionEvent.y); + ProcessMouseMove (xevent.MotionEvent.x, xevent.MotionEvent.y); + break; + case XLib.XEventName.ButtonPress: + //Debug.WriteLine ("button press: {0}", xevent.ButtonEvent.button); + if (xevent.ButtonEvent.button == 4) + ProcessMouseWheelChanged (WheelIncrement); + else if(xevent.ButtonEvent.button == 5) + ProcessMouseWheelChanged (-WheelIncrement); + else + ProcessMouseButtonDown (xevent.ButtonEvent.button - 1); + break; + case XLib.XEventName.ButtonRelease: + //Debug.WriteLine ("button release: {0}", xevent.ButtonEvent.button); + ProcessMouseButtonUp (xevent.ButtonEvent.button - 1); + break; + + } + } + } + } + + #region IDisposable Support + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + //Marshal.FreeHGlobal (lastEvent); + XLib.NativeMethods.XCloseDisplay (xHandle); + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + ~Interface() { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(false); + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); } #endregion public void Init () { + CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + CurrentInterface = this; - loadCursors (); + //loadCursors (); loadStyling (); findAvailableTemplates (); - initTooltip (); - initContextMenus (); + //initTooltip (); + //initContextMenus (); + + #if MEASURE_TIME + PerfMeasures.Add (updateMeasure); + PerfMeasures.Add (drawingMeasure); + PerfMeasures.Add (layoutingMeasure); + PerfMeasures.Add (clippingMeasure); + #endif + } + + protected virtual void initX() { + XLib.NativeMethods.XInitThreads (); + xHandle = XLib.NativeMethods.XOpenDisplay(IntPtr.Zero); + if (xHandle == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to open display."); + + xScreen = XLib.NativeMethods.XDefaultScreen(xHandle); + + xDefaultRootWin = XLib.NativeMethods.XDefaultRootWindow (xHandle); + xDefaultVisual = XLib.NativeMethods.XDefaultVisual (xHandle, xScreen); + xDefaultDepth = XLib.NativeMethods.XDefaultDepth (xHandle, xScreen); + + xwinHnd = XLib.NativeMethods.XCreateSimpleWindow (xHandle, xDefaultRootWin, + 0, 0, (uint)clientRectangle.Width, (uint)clientRectangle.Height, 0, IntPtr.Zero, IntPtr.Zero); + if (xwinHnd == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to create window."); + + XLib.NativeMethods.XSelectInput (xHandle, xwinHnd, XLib.EventMask.ExposureMask | + XLib.EventMask.KeyPressMask | XLib.EventMask.KeyReleaseMask | + XLib.EventMask.PointerMotionMask | XLib.EventMask.ButtonPressMask | XLib.EventMask.ButtonReleaseMask); + + XLib.NativeMethods.XMapWindow (xHandle, xwinHnd); + + surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height); + + errorHnd = new XLib.XErrorHandler (HandleError); + XLib.NativeMethods.XSetErrorHandler (errorHnd); + + Thread t = new Thread (interfaceThread); + t.IsBackground = true; + t.Start (); + } #region Static and constants @@ -125,6 +283,7 @@ namespace Crow public static int DeviceRepeatDelay = 700; /// <summary> Time interval in millisecond between device event repeat</summary> public static int DeviceRepeatInterval = 40; + public static float WheelIncrement = 1; /// <summary>Tabulation size in Text controls</summary> public static int TabSize = 4; public static string LineBreak = "\n"; @@ -178,6 +337,9 @@ namespace Crow public event EventHandler<KeyboardKeyEventArgs> KeyboardKeyUp; #endregion + /// <summary>Main Cairo surface</summary> + public Surface surf; + #region Public Fields /// <summary>Graphic Tree of this interface</summary> public List<GraphicObject> GraphicTree = new List<GraphicObject>(); @@ -229,13 +391,11 @@ namespace Crow #region Private Fields /// <summary>Client rectangle in the host context</summary> - Rectangle clientRectangle; + protected Rectangle clientRectangle; /// <summary>Clipping rectangles on the root context</summary> Region clipping = new Region(); /// <summary>Main Cairo context</summary> Context ctx; - /// <summary>Main Cairo surface</summary> - Surface surf; #endregion #region Default values and Style loading @@ -335,7 +495,7 @@ namespace Crow if (path.StartsWith ("#")) { string resId = path.Substring (1); //try/catch added to prevent nunit error - try { + try { stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); } catch{} if (stream == null)//try to find ressource in Crow assembly @@ -644,80 +804,57 @@ namespace Crow #endif if (DragImage != null) clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); - using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { - using (ctx = new Context (surf)){ - if (!clipping.IsEmpty) { + //using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { + using (ctx = new Context (surf)){ + if (!clipping.IsEmpty) { + IsDirty = true; + + for (int i = 0; i < clipping.NumRectangles; i++) + ctx.Rectangle(clipping.GetRectangle(i)); + + ctx.ClipPreserve(); + ctx.Operator = Operator.Clear; + ctx.Fill(); + ctx.Operator = Operator.Over; - for (int i = 0; i < clipping.NumRectangles; i++) - ctx.Rectangle(clipping.GetRectangle(i)); - - ctx.ClipPreserve(); - ctx.Operator = Operator.Clear; - ctx.Fill(); - ctx.Operator = Operator.Over; + for (int i = GraphicTree.Count -1; i >= 0 ; i--){ + GraphicObject p = GraphicTree[i]; + if (!p.Visible) + continue; + if (clipping.Contains (p.Slot) == RegionOverlap.Out) + continue; - for (int i = GraphicTree.Count -1; i >= 0 ; i--){ - GraphicObject p = GraphicTree[i]; - if (!p.Visible) - continue; - if (clipping.Contains (p.Slot) == RegionOverlap.Out) - continue; + ctx.Save (); + p.Paint (ref ctx); + ctx.Restore (); + } + if (DragAndDropOperation != null) { + if (DragImage != null) { + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + DragImageX = Mouse.X - DragImageWidth / 2; + DragImageY = Mouse.Y - DragImageHeight / 2; ctx.Save (); - p.Paint (ref ctx); + ctx.ResetClip (); + ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); + ctx.PaintWithAlpha (0.8); ctx.Restore (); - } - - if (DragAndDropOperation != null) { - if (DragImage != null) { - DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - DragImageX = Mouse.X - DragImageWidth / 2; - DragImageY = Mouse.Y - DragImageHeight / 2; - ctx.Save (); - ctx.ResetClip (); - ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); - ctx.PaintWithAlpha (0.8); - ctx.Restore (); - DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - IsDirty = true; - //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); - } - } - - #if DEBUG_CLIP_RECTANGLE - clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5)); - #endif - lock (RenderMutex) { -// Array.Copy (bmp, dirtyBmp, bmp.Length); - - if (IsDirty) - DirtyRect += clipping.Extents; - else - DirtyRect = clipping.Extents; + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); IsDirty = true; - - DirtyRect.Left = Math.Max (0, DirtyRect.Left); - DirtyRect.Top = Math.Max (0, DirtyRect.Top); - DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width); - DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height); - DirtyRect.Width = Math.Max (0, DirtyRect.Width); - DirtyRect.Height = Math.Max (0, DirtyRect.Height); - - if (DirtyRect.Width > 0 && DirtyRect.Height >0) { - dirtyBmp = new byte[4 * DirtyRect.Width * DirtyRect.Height]; - for (int y = 0; y < DirtyRect.Height; y++) { - Array.Copy (bmp, - ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4, - dirtyBmp, y * DirtyRect.Width * 4, DirtyRect.Width * 4); - } - - } else - IsDirty = false; + //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); } - clipping.Dispose (); - clipping = new Region (); } + + #if DEBUG_CLIP_RECTANGLE + clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5)); + #endif + + clipping.Dispose (); + clipping = new Region (); + //} //surf.WriteToPng (@"/mnt/data/test.png"); + + //XLib.NativeMethods.XSync (xHandle, 0); } } #if MEASURE_TIME @@ -728,7 +865,7 @@ namespace Crow #region GraphicTree handling /// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary> - public void AddWidget(GraphicObject g) + public GraphicObject AddWidget(GraphicObject g) { g.Parent = this; int ptr = 0; @@ -749,6 +886,8 @@ namespace Crow g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); + + return g; } /// <summary>Set visible state of widget to false and delete if from the graphic tree</summary> public void DeleteWidget(GraphicObject g) @@ -837,13 +976,14 @@ namespace Crow /// when window resize event occurs. /// </summary> /// <param name="bounds">bounding box of the interface</param> - public void ProcessResize(Rectangle bounds){ + public virtual void ProcessResize(Rectangle bounds){ lock (UpdateMutex) { clientRectangle = bounds; - int stride = 4 * ClientRectangle.Width; - int bmpSize = Math.Abs (stride) * ClientRectangle.Height; - bmp = new byte[bmpSize]; - dirtyBmp = new byte[bmpSize]; + + /*surf.Dispose (); + surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height);*/ + (surf as XlibSurface).SetSize (clientRectangle.Width, clientRectangle.Height); + foreach (GraphicObject g in GraphicTree) g.RegisterForLayouting (LayoutingType.All); @@ -1051,6 +1191,7 @@ namespace Crow lastKeyDownEvt.IsRepeat = true; _focusedWidget.onKeyDown (this, e); + KeyboardKeyDown.Raise (this, e); // keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc); // keyboardRepeatThread.IsBackground = true; // keyboardRepeatThread.Start (); @@ -1070,6 +1211,8 @@ namespace Crow _focusedWidget.onKeyUp (this, e); + KeyboardKeyUp.Raise (this, e); + // if (keyboardRepeatThread != null) { // keyboardRepeatOn = false; // keyboardRepeatThread.Abort(); @@ -1246,10 +1389,11 @@ namespace Crow #endregion #if MEASURE_TIME - public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 100); - public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 100); - public PerformanceMeasure updateMeasure = new PerformanceMeasure("Update", 100); - public PerformanceMeasure drawingMeasure = new PerformanceMeasure("Drawing", 100); + public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 1); + public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 1); + public PerformanceMeasure updateMeasure = new PerformanceMeasure("Update", 1); + public PerformanceMeasure drawingMeasure = new PerformanceMeasure("Drawing", 1); + public List<PerformanceMeasure> PerfMeasures = new List<PerformanceMeasure>(); #endif #if DEBUG_LAYOUTING public List<LQIList> LQIsTries = new List<LQIList>(); diff --git a/src/Mono.Cairo/Antialias.cs b/src/Mono.Cairo/Antialias.cs index 9ea64f75..6c932f08 100644 --- a/src/Mono.Cairo/Antialias.cs +++ b/src/Mono.Cairo/Antialias.cs @@ -37,7 +37,7 @@ namespace Cairo { Default, None, - Gray, + Grey, Subpixel, } } diff --git a/src/StyleReader.cs b/src/StyleReader.cs index 458b7856..c50083eb 100644 --- a/src/StyleReader.cs +++ b/src/StyleReader.cs @@ -182,19 +182,5 @@ namespace Crow } } } - -// public override int Read () -// { -// int tmp = base.Read (); -// char c = (char)tmp; -// if (c == '\n') { -// line++; -// column = 1; -// } else if (c == '\t') -// column += Interface.TabSize; -// else if (c != '\r') -// column++; -// return tmp; -// } } } diff --git a/src/XLib/Display.cs b/src/XLib/Display.cs new file mode 100644 index 00000000..7e973b88 --- /dev/null +++ b/src/XLib/Display.cs @@ -0,0 +1,64 @@ +using System; +using System.Runtime.InteropServices; + +namespace XLib +{ + public class Display : IDisposable + { + internal IntPtr handle; + internal Int32 screen; + IntPtr lastEvent; + + public Display() + { + handle = NativeMethods.XOpenDisplay(IntPtr.Zero); + if (handle == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to open display."); + + screen = NativeMethods.XDefaultScreen(handle); + lastEvent = Marshal.AllocHGlobal(96); + } + + /*public IntPtr NextEvent { + get { + NativeMethods.XNextEvent(handle, lastEvent); + return lastEvent; + } + }*/ + + #region IDisposable Support + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + //Marshal.FreeHGlobal (lastEvent); + NativeMethods.XCloseDisplay (handle); + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + ~Display() { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(false); + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + #endregion + + + } +} diff --git a/src/XLib/NativeMethods.cs b/src/XLib/NativeMethods.cs new file mode 100644 index 00000000..ed6fa7d5 --- /dev/null +++ b/src/XLib/NativeMethods.cs @@ -0,0 +1,48 @@ +using System; +using System.Runtime.InteropServices; + +namespace XLib +{ + public static class NativeMethods + { + #region pinvoke + [DllImportAttribute("X11")] + public static extern int XInitThreads(); + [DllImportAttribute("X11")] + public static extern IntPtr XOpenDisplay(IntPtr displayName); + [DllImportAttribute("X11")] + public static extern IntPtr XCloseDisplay(IntPtr disp); + [DllImportAttribute("X11")] + public static extern Int32 XDefaultScreen(IntPtr disp); + [DllImportAttribute("X11")] + public static extern IntPtr XDefaultRootWindow(IntPtr disp); + [DllImportAttribute("X11")] + public static extern UInt32 XDefaultDepth (IntPtr disp, Int32 screen); + [DllImportAttribute("X11")] + public static extern IntPtr XDefaultVisual(IntPtr disp, Int32 screen); + [DllImportAttribute("X11")] + public static extern IntPtr XCreateSimpleWindow(IntPtr disp, IntPtr rootWindow, Int32 x, Int32 y, UInt32 width, UInt32 height, + UInt32 borderWidth, IntPtr border, IntPtr background); + [DllImportAttribute("X11")] + public static extern IntPtr XCreatePixmap(IntPtr disp, IntPtr rootWindow, UInt32 width, UInt32 height, UInt32 depth); + [DllImportAttribute("X11")] + public static extern IntPtr XFreePixmap(IntPtr disp, IntPtr pixmap); + [DllImportAttribute("X11")] + public static extern Int32 XSelectInput(IntPtr disp, IntPtr win, EventMask eventMask); + [DllImportAttribute("X11")] + public static extern Int32 XMapWindow(IntPtr disp, IntPtr win); + [DllImportAttribute("X11")] + public static extern int XPending (IntPtr disp); + [DllImportAttribute("X11")] + public static extern IntPtr XNextEvent(IntPtr disp, ref XEvent xevent); + [DllImportAttribute("X11")] + public static extern Int32 XSync(IntPtr disp, int discard); + [DllImportAttribute("X11")] + public static extern int XConnectionNumber(IntPtr disp); + [DllImportAttribute("X11")] + public static extern IntPtr XSetErrorHandler(XErrorHandler error_handler); + #endregion + + + } +} diff --git a/src/XLib/Window.cs b/src/XLib/Window.cs new file mode 100644 index 00000000..f74a5fdb --- /dev/null +++ b/src/XLib/Window.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.InteropServices; + +namespace XLib +{ + + public enum EventType { + KeyPress = 2, + KeyRelease, + ButtonPress, + ButtonRelease, + MotionNotify, + EnterNotify, + LeaveNotify, + FocusIn, + FocusOut, + KeymapNotify, + Expose, + GraphicsExpose, + NoExpose, + VisibilityNotify, + CreateNotify, + DestroyNotify, + UnmapNotify, + MapNotify, + MapRequest, + ReparentNotify, + ConfigureNotify, + ConfigureRequest, + GravityNotify, + ResizeRequest, + CirculateNotify, + CirculateRequest, + PropertyNotify, + SelectionClear, + SelectionRequest, + SelectionNotify, + ColormapNotify, + ClientMessage, + MappingNotify, + GenericEvent, + LASTEvent = 36 /* must be bigger than any event # */ + } + public class Window + { + IntPtr handle; + Display disp; + + public Window (Display display, UInt32 width = 800, UInt32 height = 600, Int32 x = 0, Int32 y = 0) { + disp = display; + handle = NativeMethods.XCreateSimpleWindow (disp.handle, NativeMethods.XDefaultRootWindow(disp.handle), x, y, width, height, + 0, IntPtr.Zero, IntPtr.Zero); + if (handle == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to create window."); + + NativeMethods.XSelectInput (disp.handle, handle, EventMask.ExposureMask | EventMask.KeyPressMask); + + NativeMethods.XMapWindow (disp.handle, handle); + } + + } +} diff --git a/src/XLib/X11Structs.cs b/src/XLib/X11Structs.cs new file mode 100644 index 00000000..8cf70abc --- /dev/null +++ b/src/XLib/X11Structs.cs @@ -0,0 +1,1822 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software",, to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2004 Novell, Inc. +// +// Authors: +// Peter Bartok pbartok@novell.com +// + + +// NOT COMPLETE + +using System; +using System.ComponentModel; +using System.Collections; +using System.Drawing; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Threading; + +/// X11 Version +namespace XLib { + // + // In the structures below, fields of type long are mapped to IntPtr. + // This will work on all platforms where sizeof(long)==sizeof(void*), which + // is almost all platforms except WIN64. + // + + [StructLayout(LayoutKind.Sequential)] + public struct XAnyEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XKeyEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr root; + public IntPtr subwindow; + public IntPtr time; + public int x; + public int y; + public int x_root; + public int y_root; + public int state; + public int keycode; + public bool same_screen; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XButtonEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr root; + public IntPtr subwindow; + public IntPtr time; + public int x; + public int y; + public int x_root; + public int y_root; + public int state; + public int button; + public bool same_screen; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XMotionEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr root; + public IntPtr subwindow; + public IntPtr time; + public int x; + public int y; + public int x_root; + public int y_root; + public int state; + public byte is_hint; + public bool same_screen; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XCrossingEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr root; + public IntPtr subwindow; + public IntPtr time; + public int x; + public int y; + public int x_root; + public int y_root; + public NotifyMode mode; + public NotifyDetail detail; + public bool same_screen; + public bool focus; + public int state; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XFocusChangeEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public int mode; + public NotifyDetail detail; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XKeymapEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public byte key_vector0; + public byte key_vector1; + public byte key_vector2; + public byte key_vector3; + public byte key_vector4; + public byte key_vector5; + public byte key_vector6; + public byte key_vector7; + public byte key_vector8; + public byte key_vector9; + public byte key_vector10; + public byte key_vector11; + public byte key_vector12; + public byte key_vector13; + public byte key_vector14; + public byte key_vector15; + public byte key_vector16; + public byte key_vector17; + public byte key_vector18; + public byte key_vector19; + public byte key_vector20; + public byte key_vector21; + public byte key_vector22; + public byte key_vector23; + public byte key_vector24; + public byte key_vector25; + public byte key_vector26; + public byte key_vector27; + public byte key_vector28; + public byte key_vector29; + public byte key_vector30; + public byte key_vector31; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XExposeEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public int x; + public int y; + public int width; + public int height; + public int count; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XGraphicsExposeEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr drawable; + public int x; + public int y; + public int width; + public int height; + public int count; + public int major_code; + public int minor_code; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XNoExposeEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr drawable; + public int major_code; + public int minor_code; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XVisibilityEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public int state; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XCreateWindowEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr parent; + public IntPtr window; + public int x; + public int y; + public int width; + public int height; + public int border_width; + public bool override_redirect; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XDestroyWindowEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XUnmapEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public bool from_configure; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XMapEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public bool override_redirect; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XMapRequestEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr parent; + public IntPtr window; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XReparentEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public IntPtr parent; + public int x; + public int y; + public bool override_redirect; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XConfigureEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public int x; + public int y; + public int width; + public int height; + public int border_width; + public IntPtr above; + public bool override_redirect; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XGravityEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public int x; + public int y; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XResizeRequestEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public int width; + public int height; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XConfigureRequestEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr parent; + public IntPtr window; + public int x; + public int y; + public int width; + public int height; + public int border_width; + public IntPtr above; + public int detail; + public IntPtr value_mask; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XCirculateEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr xevent; + public IntPtr window; + public int place; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XCirculateRequestEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr parent; + public IntPtr window; + public int place; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XPropertyEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr atom; + public IntPtr time; + public int state; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XSelectionClearEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr selection; + public IntPtr time; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XSelectionRequestEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr owner; + public IntPtr requestor; + public IntPtr selection; + public IntPtr target; + public IntPtr property; + public IntPtr time; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XSelectionEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr requestor; + public IntPtr selection; + public IntPtr target; + public IntPtr property; + public IntPtr time; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XColormapEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr colormap; + public bool c_new; + public int state; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XClientMessageEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public IntPtr message_type; + public int format; + public IntPtr ptr1; + public IntPtr ptr2; + public IntPtr ptr3; + public IntPtr ptr4; + public IntPtr ptr5; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XMappingEvent { + public XEventName type; + public IntPtr serial; + public bool send_event; + public IntPtr display; + public IntPtr window; + public int request; + public int first_keycode; + public int count; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XErrorEvent { + public XEventName type; + public IntPtr display; + public IntPtr resourceid; + public IntPtr serial; + public byte error_code; + public XRequest request_code; + public byte minor_code; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XEventPad { + public IntPtr pad0; + public IntPtr pad1; + public IntPtr pad2; + public IntPtr pad3; + public IntPtr pad4; + public IntPtr pad5; + public IntPtr pad6; + public IntPtr pad7; + public IntPtr pad8; + public IntPtr pad9; + public IntPtr pad10; + public IntPtr pad11; + public IntPtr pad12; + public IntPtr pad13; + public IntPtr pad14; + public IntPtr pad15; + public IntPtr pad16; + public IntPtr pad17; + public IntPtr pad18; + public IntPtr pad19; + public IntPtr pad20; + public IntPtr pad21; + public IntPtr pad22; + public IntPtr pad23; + } + + [StructLayout(LayoutKind.Explicit)] + public struct XEvent { + [ FieldOffset(0) ] public XEventName type; + [ FieldOffset(0) ] public XAnyEvent AnyEvent; + [ FieldOffset(0) ] public XKeyEvent KeyEvent; + [ FieldOffset(0) ] public XButtonEvent ButtonEvent; + [ FieldOffset(0) ] public XMotionEvent MotionEvent; + [ FieldOffset(0) ] public XCrossingEvent CrossingEvent; + [ FieldOffset(0) ] public XFocusChangeEvent FocusChangeEvent; + [ FieldOffset(0) ] public XExposeEvent ExposeEvent; + [ FieldOffset(0) ] public XGraphicsExposeEvent GraphicsExposeEvent; + [ FieldOffset(0) ] public XNoExposeEvent NoExposeEvent; + [ FieldOffset(0) ] public XVisibilityEvent VisibilityEvent; + [ FieldOffset(0) ] public XCreateWindowEvent CreateWindowEvent; + [ FieldOffset(0) ] public XDestroyWindowEvent DestroyWindowEvent; + [ FieldOffset(0) ] public XUnmapEvent UnmapEvent; + [ FieldOffset(0) ] public XMapEvent MapEvent; + [ FieldOffset(0) ] public XMapRequestEvent MapRequestEvent; + [ FieldOffset(0) ] public XReparentEvent ReparentEvent; + [ FieldOffset(0) ] public XConfigureEvent ConfigureEvent; + [ FieldOffset(0) ] public XGravityEvent GravityEvent; + [ FieldOffset(0) ] public XResizeRequestEvent ResizeRequestEvent; + [ FieldOffset(0) ] public XConfigureRequestEvent ConfigureRequestEvent; + [ FieldOffset(0) ] public XCirculateEvent CirculateEvent; + [ FieldOffset(0) ] public XCirculateRequestEvent CirculateRequestEvent; + [ FieldOffset(0) ] public XPropertyEvent PropertyEvent; + [ FieldOffset(0) ] public XSelectionClearEvent SelectionClearEvent; + [ FieldOffset(0) ] public XSelectionRequestEvent SelectionRequestEvent; + [ FieldOffset(0) ] public XSelectionEvent SelectionEvent; + [ FieldOffset(0) ] public XColormapEvent ColormapEvent; + [ FieldOffset(0) ] public XClientMessageEvent ClientMessageEvent; + [ FieldOffset(0) ] public XMappingEvent MappingEvent; + [ FieldOffset(0) ] public XErrorEvent ErrorEvent; + [ FieldOffset(0) ] public XKeymapEvent KeymapEvent; + + //[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=24)] + //[ FieldOffset(0) ] public int[] pad; + [ FieldOffset(0) ] public XEventPad Pad; + public override string ToString() { + switch (type) + { + case XEventName.ButtonPress: + case XEventName.ButtonRelease: + return ToString (ButtonEvent); + case XEventName.CirculateNotify: + case XEventName.CirculateRequest: + return ToString (CirculateEvent); + case XEventName.ClientMessage: + return ToString (ClientMessageEvent); + case XEventName.ColormapNotify: + return ToString (ColormapEvent); + case XEventName.ConfigureNotify: + return ToString (ConfigureEvent); + case XEventName.ConfigureRequest: + return ToString (ConfigureRequestEvent); + case XEventName.CreateNotify: + return ToString (CreateWindowEvent); + case XEventName.DestroyNotify: + return ToString (DestroyWindowEvent); + case XEventName.Expose: + return ToString (ExposeEvent); + case XEventName.FocusIn: + case XEventName.FocusOut: + return ToString (FocusChangeEvent); + case XEventName.GraphicsExpose: + return ToString (GraphicsExposeEvent); + case XEventName.GravityNotify: + return ToString (GravityEvent); + case XEventName.KeymapNotify: + return ToString (KeymapEvent); + case XEventName.MapNotify: + return ToString (MapEvent); + case XEventName.MappingNotify: + return ToString (MappingEvent); + case XEventName.MapRequest: + return ToString (MapRequestEvent); + case XEventName.MotionNotify: + return ToString (MotionEvent); + case XEventName.NoExpose: + return ToString (NoExposeEvent); + case XEventName.PropertyNotify: + return ToString (PropertyEvent); + case XEventName.ReparentNotify: + return ToString (ReparentEvent); + case XEventName.ResizeRequest: + return ToString (ResizeRequestEvent); + case XEventName.SelectionClear: + return ToString (SelectionClearEvent); + case XEventName.SelectionNotify: + return ToString (SelectionEvent); + case XEventName.SelectionRequest: + return ToString (SelectionRequestEvent); + case XEventName.UnmapNotify: + return ToString (UnmapEvent); + case XEventName.VisibilityNotify: + return ToString (VisibilityEvent); + case XEventName.EnterNotify: + case XEventName.LeaveNotify: + return ToString (CrossingEvent); + default: + return type.ToString (); + } + } + + public static string ToString (object ev) + { + string result = string.Empty; + Type type = ev.GetType (); + System.Reflection.FieldInfo [] fields = type.GetFields (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance); + for (int i = 0; i < fields.Length; i++) { + if (result != string.Empty) { + result += ", "; + } + object value = fields [i].GetValue (ev); + result += fields [i].Name + "=" + (value == null ? "<null>" : value.ToString ()); + } + return type.Name + " (" + result + ")"; + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct XSetWindowAttributes { + public IntPtr background_pixmap; + public IntPtr background_pixel; + public IntPtr border_pixmap; + public IntPtr border_pixel; + public Gravity bit_gravity; + public Gravity win_gravity; + public int backing_store; + public IntPtr backing_planes; + public IntPtr backing_pixel; + public bool save_under; + public IntPtr event_mask; + public IntPtr do_not_propagate_mask; + public bool override_redirect; + public IntPtr colormap; + public IntPtr cursor; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XWindowAttributes { + public int x; + public int y; + public int width; + public int height; + public int border_width; + public int depth; + public IntPtr visual; + public IntPtr root; + public int c_class; + public Gravity bit_gravity; + public Gravity win_gravity; + public int backing_store; + public IntPtr backing_planes; + public IntPtr backing_pixel; + public bool save_under; + public IntPtr colormap; + public bool map_installed; + public MapState map_state; + public IntPtr all_event_masks; + public IntPtr your_event_mask; + public IntPtr do_not_propagate_mask; + public bool override_direct; + public IntPtr screen; + + public override string ToString () + { + return XEvent.ToString (this); + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct XTextProperty { + public string value; + public IntPtr encoding; + public int format; + public IntPtr nitems; + } + + public enum XWindowClass { + InputOutput = 1, + InputOnly = 2 + } + + public enum XEventName { + KeyPress = 2, + KeyRelease = 3, + ButtonPress = 4, + ButtonRelease = 5, + MotionNotify = 6, + EnterNotify = 7, + LeaveNotify = 8, + FocusIn = 9, + FocusOut = 10, + KeymapNotify = 11, + Expose = 12, + GraphicsExpose = 13, + NoExpose = 14, + VisibilityNotify = 15, + CreateNotify = 16, + DestroyNotify = 17, + UnmapNotify = 18, + MapNotify = 19, + MapRequest = 20, + ReparentNotify = 21, + ConfigureNotify = 22, + ConfigureRequest = 23, + GravityNotify = 24, + ResizeRequest = 25, + CirculateNotify = 26, + CirculateRequest = 27, + PropertyNotify = 28, + SelectionClear = 29, + SelectionRequest = 30, + SelectionNotify = 31, + ColormapNotify = 32, + ClientMessage = 33, + MappingNotify = 34, + + LASTEvent + } + + [Flags] + public enum SetWindowValuemask { + Nothing = 0, + BackPixmap = 1, + BackPixel = 2, + BorderPixmap = 4, + BorderPixel = 8, + BitGravity = 16, + WinGravity = 32, + BackingStore = 64, + BackingPlanes = 128, + BackingPixel = 256, + OverrideRedirect = 512, + SaveUnder = 1024, + EventMask = 2048, + DontPropagate = 4096, + ColorMap = 8192, + Cursor = 16384 + } + + public enum SendEventValues { + PointerWindow = 0, + InputFocus = 1 + } + + public enum CreateWindowArgs { + CopyFromParent = 0, + ParentRelative = 1, + InputOutput = 1, + InputOnly = 2 + } + + public enum Gravity { + ForgetGravity = 0, + NorthWestGravity= 1, + NorthGravity = 2, + NorthEastGravity= 3, + WestGravity = 4, + CenterGravity = 5, + EastGravity = 6, + SouthWestGravity= 7, + SouthGravity = 8, + SouthEastGravity= 9, + StaticGravity = 10 + } + + public enum XKeySym : uint { + XK_BackSpace = 0xFF08, + XK_Tab = 0xFF09, + XK_Clear = 0xFF0B, + XK_Return = 0xFF0D, + XK_Home = 0xFF50, + XK_Left = 0xFF51, + XK_Up = 0xFF52, + XK_Right = 0xFF53, + XK_Down = 0xFF54, + XK_Page_Up = 0xFF55, + XK_Page_Down = 0xFF56, + XK_End = 0xFF57, + XK_Begin = 0xFF58, + XK_Menu = 0xFF67, + XK_Shift_L = 0xFFE1, + XK_Shift_R = 0xFFE2, + XK_Control_L = 0xFFE3, + XK_Control_R = 0xFFE4, + XK_Caps_Lock = 0xFFE5, + XK_Shift_Lock = 0xFFE6, + XK_Meta_L = 0xFFE7, + XK_Meta_R = 0xFFE8, + XK_Alt_L = 0xFFE9, + XK_Alt_R = 0xFFEA, + XK_Super_L = 0xFFEB, + XK_Super_R = 0xFFEC, + XK_Hyper_L = 0xFFED, + XK_Hyper_R = 0xFFEE, + } + + [Flags] + public enum EventMask { + NoEventMask = 0, + KeyPressMask = 1<<0, + KeyReleaseMask = 1<<1, + ButtonPressMask = 1<<2, + ButtonReleaseMask = 1<<3, + EnterWindowMask = 1<<4, + LeaveWindowMask = 1<<5, + PointerMotionMask = 1<<6, + PointerMotionHintMask = 1<<7, + Button1MotionMask = 1<<8, + Button2MotionMask = 1<<9, + Button3MotionMask = 1<<10, + Button4MotionMask = 1<<11, + Button5MotionMask = 1<<12, + ButtonMotionMask = 1<<13, + KeymapStateMask = 1<<14, + ExposureMask = 1<<15, + VisibilityChangeMask = 1<<16, + StructureNotifyMask = 1<<17, + ResizeRedirectMask = 1<<18, + SubstructureNotifyMask = 1<<19, + SubstructureRedirectMask= 1<<20, + FocusChangeMask = 1<<21, + PropertyChangeMask = 1<<22, + ColormapChangeMask = 1<<23, + OwnerGrabButtonMask = 1<<24 + } + + public enum GrabMode { + GrabModeSync = 0, + GrabModeAsync = 1 + } + + [StructLayout(LayoutKind.Sequential)] + public struct XStandardColormap { + public IntPtr colormap; + public IntPtr red_max; + public IntPtr red_mult; + public IntPtr green_max; + public IntPtr green_mult; + public IntPtr blue_max; + public IntPtr blue_mult; + public IntPtr base_pixel; + public IntPtr visualid; + public IntPtr killid; + } + + [StructLayout(LayoutKind.Sequential, Pack=2)] + public struct XColor { + public IntPtr pixel; + public ushort red; + public ushort green; + public ushort blue; + public byte flags; + public byte pad; + } + + public enum Atom { + AnyPropertyType = 0, + XA_PRIMARY = 1, + XA_SECONDARY = 2, + XA_ARC = 3, + XA_ATOM = 4, + XA_BITMAP = 5, + XA_CARDINAL = 6, + XA_COLORMAP = 7, + XA_CURSOR = 8, + XA_CUT_BUFFER0 = 9, + XA_CUT_BUFFER1 = 10, + XA_CUT_BUFFER2 = 11, + XA_CUT_BUFFER3 = 12, + XA_CUT_BUFFER4 = 13, + XA_CUT_BUFFER5 = 14, + XA_CUT_BUFFER6 = 15, + XA_CUT_BUFFER7 = 16, + XA_DRAWABLE = 17, + XA_FONT = 18, + XA_INTEGER = 19, + XA_PIXMAP = 20, + XA_POINT = 21, + XA_RECTANGLE = 22, + XA_RESOURCE_MANAGER = 23, + XA_RGB_COLOR_MAP = 24, + XA_RGB_BEST_MAP = 25, + XA_RGB_BLUE_MAP = 26, + XA_RGB_DEFAULT_MAP = 27, + XA_RGB_GRAY_MAP = 28, + XA_RGB_GREEN_MAP = 29, + XA_RGB_RED_MAP = 30, + XA_STRING = 31, + XA_VISUALID = 32, + XA_WINDOW = 33, + XA_WM_COMMAND = 34, + XA_WM_HINTS = 35, + XA_WM_CLIENT_MACHINE = 36, + XA_WM_ICON_NAME = 37, + XA_WM_ICON_SIZE = 38, + XA_WM_NAME = 39, + XA_WM_NORMAL_HINTS = 40, + XA_WM_SIZE_HINTS = 41, + XA_WM_ZOOM_HINTS = 42, + XA_MIN_SPACE = 43, + XA_NORM_SPACE = 44, + XA_MAX_SPACE = 45, + XA_END_SPACE = 46, + XA_SUPERSCRIPT_X = 47, + XA_SUPERSCRIPT_Y = 48, + XA_SUBSCRIPT_X = 49, + XA_SUBSCRIPT_Y = 50, + XA_UNDERLINE_POSITION = 51, + XA_UNDERLINE_THICKNESS = 52, + XA_STRIKEOUT_ASCENT = 53, + XA_STRIKEOUT_DESCENT = 54, + XA_ITALIC_ANGLE = 55, + XA_X_HEIGHT = 56, + XA_QUAD_WIDTH = 57, + XA_WEIGHT = 58, + XA_POINT_SIZE = 59, + XA_RESOLUTION = 60, + XA_COPYRIGHT = 61, + XA_NOTICE = 62, + XA_FONT_NAME = 63, + XA_FAMILY_NAME = 64, + XA_FULL_NAME = 65, + XA_CAP_HEIGHT = 66, + XA_WM_CLASS = 67, + XA_WM_TRANSIENT_FOR = 68, + + XA_LAST_PREDEFINED = 68 + } + + [StructLayout(LayoutKind.Sequential)] + public struct XScreen { + public IntPtr ext_data; + public IntPtr display; + public IntPtr root; + public int width; + public int height; + public int mwidth; + public int mheight; + public int ndepths; + public IntPtr depths; + public int root_depth; + public IntPtr root_visual; + public IntPtr default_gc; + public IntPtr cmap; + public IntPtr white_pixel; + public IntPtr black_pixel; + public int max_maps; + public int min_maps; + public int backing_store; + public bool save_unders; + public IntPtr root_input_mask; + } + + [Flags] + public enum ChangeWindowFlags { + CWX = 1<<0, + CWY = 1<<1, + CWWidth = 1<<2, + CWHeight = 1<<3, + CWBorderWidth = 1<<4, + CWSibling = 1<<5, + CWStackMode = 1<<6 + } + + public enum StackMode { + Above = 0, + Below = 1, + TopIf = 2, + BottomIf = 3, + Opposite = 4 + } + + [StructLayout(LayoutKind.Sequential)] + public struct XWindowChanges { + public int x; + public int y; + public int width; + public int height; + public int border_width; + public IntPtr sibling; + public StackMode stack_mode; + } + + [Flags] + public enum ColorFlags { + DoRed = 1<<0, + DoGreen = 1<<1, + DoBlue = 1<<2 + } + + public enum NotifyMode { + NotifyNormal = 0, + NotifyGrab = 1, + NotifyUngrab = 2 + } + + public enum NotifyDetail { + NotifyAncestor = 0, + NotifyVirtual = 1, + NotifyInferior = 2, + NotifyNonlinear = 3, + NotifyNonlinearVirtual = 4, + NotifyPointer = 5, + NotifyPointerRoot = 6, + NotifyDetailNone = 7 + } + + [StructLayout(LayoutKind.Sequential)] + public struct MotifWmHints { + public IntPtr flags; + public IntPtr functions; + public IntPtr decorations; + public IntPtr input_mode; + public IntPtr status; + + public override string ToString () + { + return string.Format("MotifWmHints <flags={0}, functions={1}, decorations={2}, input_mode={3}, status={4}", (MotifFlags) flags.ToInt32 (), (MotifFunctions) functions.ToInt32 (), (MotifDecorations) decorations.ToInt32 (), (MotifInputMode) input_mode.ToInt32 (), status.ToInt32 ()); + } + } + + [Flags] + public enum MotifFlags { + Functions = 1, + Decorations = 2, + InputMode = 4, + Status = 8 + } + + [Flags] + public enum MotifFunctions { + All = 0x01, + Resize = 0x02, + Move = 0x04, + Minimize = 0x08, + Maximize = 0x10, + Close = 0x20 + } + + [Flags] + public enum MotifDecorations { + All = 0x01, + Border = 0x02, + ResizeH = 0x04, + Title = 0x08, + Menu = 0x10, + Minimize = 0x20, + Maximize = 0x40, + + } + + [Flags] + public enum MotifInputMode { + Modeless = 0, + ApplicationModal = 1, + SystemModal = 2, + FullApplicationModal = 3 + } + + [Flags] + public enum KeyMasks { + ShiftMask = (1 << 0), + LockMask = (1 << 1), + ControlMask = (1 << 2), + Mod1Mask = (1 << 3), + Mod2Mask = (1 << 4), + Mod3Mask = (1 << 5), + Mod4Mask = (1 << 6), + Mod5Mask = (1 << 7), + + ModMasks = Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask + } + + [Flags] + public enum MouseKeyMasks { + Button1Mask = (1 << 8), + Button2Mask = (1 << 9), + Button3Mask = (1 << 10), + Button4Mask = (1 << 11), + Button5Mask = (1 << 12), + } + + [StructLayout (LayoutKind.Sequential)] + public struct XModifierKeymap { + public int max_keypermod; + public IntPtr modifiermap; + } + + public enum PropertyMode { + Replace = 0, + Prepend = 1, + Append = 2 + } + + [StructLayout (LayoutKind.Sequential)] + public struct XKeyBoardState { + public int key_click_percent; + public int bell_percent; + public uint bell_pitch, bell_duration; + public IntPtr led_mask; + public int global_auto_repeat; + public AutoRepeats auto_repeats; + + [StructLayout (LayoutKind.Explicit)] + public struct AutoRepeats { + [FieldOffset (0)] + public byte first; + + [FieldOffset (31)] + public byte last; + } + } + + [Flags] + public enum GCFunction { + GCFunction = 1<<0, + GCPlaneMask = 1<<1, + GCForeground = 1<<2, + GCBackground = 1<<3, + GCLineWidth = 1<<4, + GCLineStyle = 1<<5, + GCCapStyle = 1<<6, + GCJoinStyle = 1<<7, + GCFillStyle = 1<<8, + GCFillRule = 1<<9, + GCTile = 1<<10, + GCStipple = 1<<11, + GCTileStipXOrigin = 1<<12, + GCTileStipYOrigin = 1<<13, + GCFont = 1<<14, + GCSubwindowMode = 1<<15, + GCGraphicsExposures = 1<<16, + GCClipXOrigin = 1<<17, + GCClipYOrigin = 1<<18, + GCClipMask = 1<<19, + GCDashOffset = 1<<20, + GCDashList = 1<<21, + GCArcMode = 1<<22 + } + + public enum GCJoinStyle { + JoinMiter = 0, + JoinRound = 1, + JoinBevel = 2 + } + + public enum GCLineStyle { + LineSolid = 0, + LineOnOffDash = 1, + LineDoubleDash = 2 + } + + public enum GCCapStyle { + CapNotLast = 0, + CapButt = 1, + CapRound = 2, + CapProjecting = 3 + } + + public enum GCFillStyle { + FillSolid = 0, + FillTiled = 1, + FillStippled = 2, + FillOpaqueStppled = 3 + } + + public enum GCFillRule { + EvenOddRule = 0, + WindingRule = 1 + } + + public enum GCArcMode { + ArcChord = 0, + ArcPieSlice = 1 + } + + public enum GCSubwindowMode { + ClipByChildren = 0, + IncludeInferiors = 1 + } + + [StructLayout (LayoutKind.Sequential)] + public struct XGCValues { + public GXFunction function; + public IntPtr plane_mask; + public IntPtr foreground; + public IntPtr background; + public int line_width; + public GCLineStyle line_style; + public GCCapStyle cap_style; + public GCJoinStyle join_style; + public GCFillStyle fill_style; + public GCFillRule fill_rule; + public GCArcMode arc_mode; + public IntPtr tile; + public IntPtr stipple; + public int ts_x_origin; + public int ts_y_origin; + public IntPtr font; + public GCSubwindowMode subwindow_mode; + public bool graphics_exposures; + public int clip_x_origin; + public int clib_y_origin; + public IntPtr clip_mask; + public int dash_offset; + public byte dashes; + } + + public enum GXFunction { + GXclear = 0x0, /* 0 */ + GXand = 0x1, /* src AND dst */ + GXandReverse = 0x2, /* src AND NOT dst */ + GXcopy = 0x3, /* src */ + GXandInverted = 0x4, /* NOT src AND dst */ + GXnoop = 0x5, /* dst */ + GXxor = 0x6, /* src XOR dst */ + GXor = 0x7, /* src OR dst */ + GXnor = 0x8, /* NOT src AND NOT dst */ + GXequiv = 0x9, /* NOT src XOR dst */ + GXinvert = 0xa, /* NOT dst */ + GXorReverse = 0xb, /* src OR NOT dst */ + GXcopyInverted = 0xc, /* NOT src */ + GXorInverted = 0xd, /* NOT src OR dst */ + GXnand = 0xe, /* NOT src OR NOT dst */ + GXset = 0xf /* 1 */ + } + + public enum NetWindowManagerState { + Remove = 0, + Add = 1, + Toggle = 2 + } + + public enum RevertTo { + None = 0, + PointerRoot = 1, + Parent = 2 + } + + public enum MapState { + IsUnmapped = 0, + IsUnviewable = 1, + IsViewable = 2 + } + + public enum CursorFontShape { + XC_X_cursor = 0, + XC_arrow = 2, + XC_based_arrow_down = 4, + XC_based_arrow_up = 6, + XC_boat = 8, + XC_bogosity = 10, + XC_bottom_left_corner = 12, + XC_bottom_right_corner = 14, + XC_bottom_side = 16, + XC_bottom_tee = 18, + XC_box_spiral = 20, + XC_center_ptr = 22, + + XC_circle = 24, + XC_clock = 26, + XC_coffee_mug = 28, + XC_cross = 30, + XC_cross_reverse = 32, + XC_crosshair = 34, + XC_diamond_cross = 36, + XC_dot = 38, + XC_dotbox = 40, + XC_double_arrow = 42, + XC_draft_large = 44, + XC_draft_small = 46, + + XC_draped_box = 48, + XC_exchange = 50, + XC_fleur = 52, + XC_gobbler = 54, + XC_gumby = 56, + XC_hand1 = 58, + XC_hand2 = 60, + XC_heart = 62, + XC_icon = 64, + XC_iron_cross = 66, + XC_left_ptr = 68, + XC_left_side = 70, + + XC_left_tee = 72, + XC_left_button = 74, + XC_ll_angle = 76, + XC_lr_angle = 78, + XC_man = 80, + XC_middlebutton = 82, + XC_mouse = 84, + XC_pencil = 86, + XC_pirate = 88, + XC_plus = 90, + XC_question_arrow = 92, + XC_right_ptr = 94, + + XC_right_side = 96, + XC_right_tee = 98, + XC_rightbutton = 100, + XC_rtl_logo = 102, + XC_sailboat = 104, + XC_sb_down_arrow = 106, + XC_sb_h_double_arrow = 108, + XC_sb_left_arrow = 110, + XC_sb_right_arrow = 112, + XC_sb_up_arrow = 114, + XC_sb_v_double_arrow = 116, + XC_sb_shuttle = 118, + + XC_sizing = 120, + XC_spider = 122, + XC_spraycan = 124, + XC_star = 126, + XC_target = 128, + XC_tcross = 130, + XC_top_left_arrow = 132, + XC_top_left_corner = 134, + XC_top_right_corner = 136, + XC_top_side = 138, + XC_top_tee = 140, + XC_trek = 142, + + XC_ul_angle = 144, + XC_umbrella = 146, + XC_ur_angle = 148, + XC_watch = 150, + XC_xterm = 152, + XC_num_glyphs = 154 + } + + public enum SystrayRequest { + SYSTEM_TRAY_REQUEST_DOCK = 0, + SYSTEM_TRAY_BEGIN_MESSAGE = 1, + SYSTEM_TRAY_CANCEL_MESSAGE = 2 + } + + public enum NetWmStateRequest { + _NET_WM_STATE_REMOVE = 0, + _NET_WM_STATE_ADD = 1, + _NET_WM_STATE_TOGGLE = 2 + } + + public enum NetWmMoveResize { + _NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0, + _NET_WM_MOVERESIZE_SIZE_TOP = 1, + _NET_WM_MOVERESIZE_SIZE_TOPRIGHT = 2, + _NET_WM_MOVERESIZE_SIZE_RIGHT = 3, + _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4, + _NET_WM_MOVERESIZE_SIZE_BOTTOM = 5, + _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6, + _NET_WM_MOVERESIZE_SIZE_LEFT = 7, + _NET_WM_MOVERESIZE_MOVE = 8, + _NET_WM_MOVERESIZE_SIZE_KEYBOARD = 9, + _NET_WM_MOVERESIZE_MOVE_KEYBOARD = 10, + _NET_WM_MOVERESIZE_CANCEL = 11 + } + + [Flags] + public enum XSizeHintsFlags { + USPosition = (1 << 0), + USSize = (1 << 1), + PPosition = (1 << 2), + PSize = (1 << 3), + PMinSize = (1 << 4), + PMaxSize = (1 << 5), + PResizeInc = (1 << 6), + PAspect = (1 << 7), + PAllHints = (PPosition | PSize | PMinSize | PMaxSize | PResizeInc | PAspect), + PBaseSize = (1 << 8), + PWinGravity = (1 << 9), + } + + [StructLayout(LayoutKind.Sequential)] + public struct XSizeHints { + public IntPtr flags; + public int x; + public int y; + public int width; + public int height; + public int min_width; + public int min_height; + public int max_width; + public int max_height; + public int width_inc; + public int height_inc; + public int min_aspect_x; + public int min_aspect_y; + public int max_aspect_x; + public int max_aspect_y; + public int base_width; + public int base_height; + public int win_gravity; + } + + [Flags] + public enum XWMHintsFlags { + InputHint = (1 << 0), + StateHint = (1 << 1), + IconPixmapHint = (1 << 2), + IconWindowHint = (1 << 3), + IconPositionHint = (1 << 4), + IconMaskHint = (1 << 5), + WindowGroupHint = (1 << 6), + AllHints = (InputHint | StateHint | IconPixmapHint | IconWindowHint | IconPositionHint | IconMaskHint | WindowGroupHint) + } + + public enum XInitialState { + DontCareState = 0, + NormalState = 1, + ZoomState = 2, + IconicState = 3, + InactiveState = 4 + } + + [StructLayout(LayoutKind.Sequential)] + public struct XWMHints { + public IntPtr flags; + public bool input; + public XInitialState initial_state; + public IntPtr icon_pixmap; + public IntPtr icon_window; + public int icon_x; + public int icon_y; + public IntPtr icon_mask; + public IntPtr window_group; + } + + [StructLayout(LayoutKind.Sequential)] + public struct XIconSize { + public int min_width; + public int min_height; + public int max_width; + public int max_height; + public int width_inc; + public int height_inc; + } + + public struct CaretStruct { + public Timer Timer; // Blink interval + public IntPtr Hwnd; // Window owning the caret + public IntPtr Window; // Actual X11 handle of the window + public int X; // X position of the caret + public int Y; // Y position of the caret + public int Width; // Width of the caret; if no image used + public int Height; // Height of the caret, if no image used + public bool Visible; // Is caret visible? + public bool On; // Caret blink display state: On/Off + public IntPtr gc; // Graphics context + public bool Paused; // Don't update right now + } + + public struct HoverStruct { + public Timer Timer; // for hovering + public IntPtr Window; // Last window we entered; used to generate WM_MOUSEHOVER (handle is X11 handle) + public int X; // Last MouseMove X coordinate; used to generate WM_MOUSEHOVER + public int Y; // Last MouseMove Y coordinate; used to generate WM_MOUSEHOVER + public Size Size; // Size of the rectangle the mouse has to stay in to generate hover + public int Interval; // in milliseconds, how long to hold before hover is generated + public IntPtr Atom; // X Atom + } + + /*public struct ClickStruct { + public IntPtr Hwnd; // + public Msg Message; // + public IntPtr wParam; // + public IntPtr lParam; // + public long Time; // Last time we received a mouse click + public bool Pending; // True if we haven't sent the last mouse click + }*/ + + public struct GrabStruct { + public bool Confined; // Is the current grab (if any) confined to grab_area? + public IntPtr Hwnd; // The window that is grabbed + public Rectangle Area; // The area the current grab is confined to + } + + public delegate int XErrorHandler(IntPtr DisplayHandle, ref XErrorEvent error_event); + + public enum XRequest : byte { + X_CreateWindow = 1, + X_ChangeWindowAttributes = 2, + X_GetWindowAttributes = 3, + X_DestroyWindow = 4, + X_DestroySubwindows = 5, + X_ChangeSaveSet = 6, + X_ReparentWindow = 7, + X_MapWindow = 8, + X_MapSubwindows = 9, + X_UnmapWindow = 10, + X_UnmapSubwindows = 11, + X_ConfigureWindow = 12, + X_CirculateWindow = 13, + X_GetGeometry = 14, + X_QueryTree = 15, + X_InternAtom = 16, + X_GetAtomName = 17, + X_ChangeProperty = 18, + X_DeleteProperty = 19, + X_GetProperty = 20, + X_ListProperties = 21, + X_SetSelectionOwner = 22, + X_GetSelectionOwner = 23, + X_ConvertSelection = 24, + X_SendEvent = 25, + X_GrabPointer = 26, + X_UngrabPointer = 27, + X_GrabButton = 28, + X_UngrabButton = 29, + X_ChangeActivePointerGrab = 30, + X_GrabKeyboard = 31, + X_UngrabKeyboard = 32, + X_GrabKey = 33, + X_UngrabKey = 34, + X_AllowEvents = 35, + X_GrabServer = 36, + X_UngrabServer = 37, + X_QueryPointer = 38, + X_GetMotionEvents = 39, + X_TranslateCoords = 40, + X_WarpPointer = 41, + X_SetInputFocus = 42, + X_GetInputFocus = 43, + X_QueryKeymap = 44, + X_OpenFont = 45, + X_CloseFont = 46, + X_QueryFont = 47, + X_QueryTextExtents = 48, + X_ListFonts = 49, + X_ListFontsWithInfo = 50, + X_SetFontPath = 51, + X_GetFontPath = 52, + X_CreatePixmap = 53, + X_FreePixmap = 54, + X_CreateGC = 55, + X_ChangeGC = 56, + X_CopyGC = 57, + X_SetDashes = 58, + X_SetClipRectangles = 59, + X_FreeGC = 60, + X_ClearArea = 61, + X_CopyArea = 62, + X_CopyPlane = 63, + X_PolyPoint = 64, + X_PolyLine = 65, + X_PolySegment = 66, + X_PolyRectangle = 67, + X_PolyArc = 68, + X_FillPoly = 69, + X_PolyFillRectangle = 70, + X_PolyFillArc = 71, + X_PutImage = 72, + X_GetImage = 73, + X_PolyText8 = 74, + X_PolyText16 = 75, + X_ImageText8 = 76, + X_ImageText16 = 77, + X_CreateColormap = 78, + X_FreeColormap = 79, + X_CopyColormapAndFree = 80, + X_InstallColormap = 81, + X_UninstallColormap = 82, + X_ListInstalledColormaps = 83, + X_AllocColor = 84, + X_AllocNamedColor = 85, + X_AllocColorCells = 86, + X_AllocColorPlanes = 87, + X_FreeColors = 88, + X_StoreColors = 89, + X_StoreNamedColor = 90, + X_QueryColors = 91, + X_LookupColor = 92, + X_CreateCursor = 93, + X_CreateGlyphCursor = 94, + X_FreeCursor = 95, + X_RecolorCursor = 96, + X_QueryBestSize = 97, + X_QueryExtension = 98, + X_ListExtensions = 99, + X_ChangeKeyboardMapping = 100, + X_GetKeyboardMapping = 101, + X_ChangeKeyboardControl = 102, + X_GetKeyboardControl = 103, + X_Bell = 104, + X_ChangePointerControl = 105, + X_GetPointerControl = 106, + X_SetScreenSaver = 107, + X_GetScreenSaver = 108, + X_ChangeHosts = 109, + X_ListHosts = 110, + X_SetAccessControl = 111, + X_SetCloseDownMode = 112, + X_KillClient = 113, + X_RotateProperties = 114, + X_ForceScreenSaver = 115, + X_SetPointerMapping = 116, + X_GetPointerMapping = 117, + X_SetModifierMapping = 118, + X_GetModifierMapping = 119, + X_NoOperation = 127 + } + + [Flags] + public enum XIMProperties { + XIMPreeditArea = 0x0001, + XIMPreeditCallbacks = 0x0002, + XIMPreeditPosition = 0x0004, + XIMPreeditNothing = 0x0008, + XIMPreeditNone = 0x0010, + XIMStatusArea = 0x0100, + XIMStatusCallbacks = 0x0200, + XIMStatusNothing = 0x0400, + XIMStatusNone = 0x0800, + } + + [Flags] + public enum WindowType { + Client = 1, + Whole = 2, + Both = 3 + } + + public enum XEmbedMessage { + EmbeddedNotify = 0, + WindowActivate = 1, + WindowDeactivate = 2, + RequestFocus = 3, + FocusIn = 4, + FocusOut = 5, + FocusNext = 6, + FocusPrev = 7, + /* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */ + ModalityOn = 10, + ModalityOff = 11, + RegisterAccelerator = 12, + UnregisterAccelerator = 13, + ActivateAccelerator = 14 + } + + [StructLayout (LayoutKind.Sequential)] + public struct XcursorImage + { + private int version; + public int size; /* nominal size for matching */ + public int width; /* actual width */ + public int height; /* actual height */ + public int xhot; /* hot spot x (must be inside image) */ + public int yhot; /* hot spot y (must be inside image) */ + public int delay; /* hot spot y (must be inside image) */ + public IntPtr pixels; /* pointer to pixels */ + + public override string ToString () + { + return string.Format ("XCursorImage (version: {0}, size: {1}, width: {2}, height: {3}, xhot: {4}, yhot: {5}, delay: {6}, pixels: {7}", + version, size, width, height, xhot, yhot, delay, pixels); + } + } ; + + [StructLayout (LayoutKind.Sequential)] + public struct XcursorImages + { + public int nimage; /* number of images */ + public IntPtr images; /* array of XcursorImage pointers */ + } + + [StructLayout (LayoutKind.Sequential)] + public struct XIMStyles + { + public ushort count_styles; + public IntPtr supported_styles; + } + + [StructLayout (LayoutKind.Sequential)] + [Serializable] + public class XPoint + { + public short X; + public short Y; + } + + [StructLayout (LayoutKind.Sequential)] + [Serializable] + public class XIMCallback + { + public IntPtr client_data; + public XIMProc callback; + [NonSerialized] + GCHandle gch; + + public XIMCallback (IntPtr clientData, XIMProc proc) + { + this.client_data = clientData; + this.gch = GCHandle.Alloc (proc); + this.callback = proc; + } + + ~XIMCallback () + { + gch.Free (); + } + } + + public enum XIMFeedback + { + Reverse = 1, + Underline = 2, + Highlight = 4, + Primary = 32, + Secondary = 64, + Tertiary = 128, + } + + public struct XIMFeedbackStruct + { + public byte FeedbackMask; // one or more of XIMFeedback enum + } + + public struct XIMText + { + public ushort Length; + public IntPtr Feedback; // to XIMFeedbackStruct + public bool EncodingIsWChar; + public IntPtr String; // it could be either char* or wchar_t* + } + + public struct XIMPreeditDrawCallbackStruct + { + public int Caret; + public int ChangeFirst; + public int ChangeLength; + public IntPtr Text; // to XIMText + } + + public enum XIMCaretDirection + { + XIMForwardChar, + XIMBackwardChar, + XIMForwardWord, + XIMBackwardWord, + XIMCaretUp, + XIMCaretDown, + XIMNextLine, + XIMPreviousLine, + XIMLineStart, + XIMLineEnd, + XIMAbsolutePosition, + XIMDontChange + } + + public enum XIMCaretStyle + { + IsInvisible, + IsPrimary, + IsSecondary + } + + public struct XIMPreeditCaretCallbackStruct + { + public int Position; + public XIMCaretDirection Direction; + public XIMCaretStyle Style; + } + + // only PreeditStartCallback requires return value though. + public delegate int XIMProc (IntPtr xim, IntPtr clientData, IntPtr callData); + + public static class XNames + { + public const string XNVaNestedList = "XNVaNestedList"; + public const string XNQueryInputStyle = "queryInputStyle"; + public const string XNClientWindow = "clientWindow"; + public const string XNInputStyle = "inputStyle"; + public const string XNFocusWindow = "focusWindow"; + + // XIMPreeditCallbacks delegate names. + public const string XNPreeditStartCallback = "preeditStartCallback"; + public const string XNPreeditDoneCallback = "preeditDoneCallback"; + public const string XNPreeditDrawCallback = "preeditDrawCallback"; + public const string XNPreeditCaretCallback = "preeditCaretCallback"; + public const string XNPreeditStateNotifyCallback = "preeditStateNotifyCallback"; + public const string XNPreeditAttributes = "preeditAttributes"; + // XIMStatusCallbacks delegate names. + public const string XNStatusStartCallback = "statusStartCallback"; + public const string XNStatusDoneCallback = "statusDoneCallback"; + public const string XNStatusDrawCallback = "statusDrawCallback"; + public const string XNStatusAttributes = "statusAttributes"; + + public const string XNArea = "area"; + public const string XNAreaNeeded = "areaNeeded"; + public const string XNSpotLocation = "spotLocation"; + public const string XNFontSet = "fontSet"; + } + + [StructLayout (LayoutKind.Sequential)] + public struct XineramaScreenInfo + { + public int screen_number; + public short x_org; + public short y_org; + public short width; + public short height; + } +} |