]> O.S.I.I.S - jp/crow.git/commitdiff
showcase test
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 27 May 2017 08:16:57 +0000 (10:16 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 27 May 2017 08:16:57 +0000 (10:16 +0200)
16 files changed:
CrowIDE/CrowIDE.csproj
Tests/InterfaceControler.cs
Tests/Tests.csproj
testDrm/Main.cs
testDrm/Showcase.cs [new file with mode: 0644]
testDrm/TestCrow.cs
testDrm/src/BlittableValueType.cs [deleted file]
testDrm/src/DRMContext.cs [deleted file]
testDrm/src/DisplayResolution.cs [deleted file]
testDrm/src/Linux/Bindings/EvdevClass.cs
testDrm/src/Linux/DRIControler.cs
testDrm/src/MouseCursor.cs [deleted file]
testDrm/src/WindowIcon.cs [deleted file]
testDrm/testDrm.csproj
testDrm/ui/perfMeasures.crow
testDrm/ui/showcase.crow [new file with mode: 0755]

index 4aae4fce1d3e396cd406233ecebd9baf49ae4275..c18bc528bf3140cfce6111b347a38cc253616a2f 100644 (file)
@@ -70,9 +70,6 @@
     <Compile Include="..\testDrm\src\Application.cs">
       <Link>src\Application.cs</Link>
     </Compile>
-    <Compile Include="..\testDrm\src\BlittableValueType.cs">
-      <Link>src\BlittableValueType.cs</Link>
-    </Compile>
     <Compile Include="..\testDrm\src\Linux\Bindings\EvdevClass.cs">
       <Link>src\Bindings\EvdevClass.cs</Link>
     </Compile>
index 4d988c10b63b51c88c25370b10bc1db0dac99177..869c389679632e247e350cb7a82f3126160b2be8 100644 (file)
@@ -162,7 +162,7 @@ namespace Crow
 
                        while (true) {
                                CrowInterface.Update ();
-                               //Thread.Sleep (1);
+                               Thread.Sleep (3);
                        }
                }
 
index 04344a40e3b76949110f59e29e198d9b3d088f6f..9eb845a19ae093a39e2a98585c49a5ec398a33ca 100644 (file)
@@ -27,7 +27,7 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <DefineConstants>DEBUG;TRACE;MEASURE_TIME</DefineConstants>
+    <DefineConstants>DEBUG;TRACE;MEASURE_TIME0</DefineConstants>
     <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
     <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
index eb15fcc3458ced4de56c7aeec8ddcbbe413d5038..45a95d63d5037b4166ebe142047df1772e549810 100644 (file)
@@ -219,7 +219,9 @@ namespace testDrm
                        int width = 19;
                        int height = 19;
                        using (Cairo.ImageSurface img = new Cairo.ImageSurface (Cairo.Format.Argb32, gpu.Width, gpu.Height)) {
+                               #if MEASURE_TIME
                                glDrawMeasure.StartCycle ();
+                               #endif
                                using (Cairo.Context ctx = new Cairo.Context (img)) {
                                        for (int x = 100; x < 800; x += 20) {
                                                for (int y = 100; y < 800; y += 20) {
@@ -229,7 +231,9 @@ namespace testDrm
                                                }
                                        }
                                }
+                               #if MEASURE_TIME
                                glDrawMeasure.StopCycle ();
+                               #endif
                                using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
                                        ctx.SetSourceSurface (img, 0, 0);
                                        ctx.Paint ();
diff --git a/testDrm/Showcase.cs b/testDrm/Showcase.cs
new file mode 100644 (file)
index 0000000..3cc1c72
--- /dev/null
@@ -0,0 +1,210 @@
+//
+// UIEditor.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// 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.
+
+using System;
+using Crow;
+using System.IO;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Linq;
+
+namespace Tests
+{
+       class Showcase : Application, IValueChange 
+       {
+               [STAThread]
+               static void Main ()
+               {
+                       try {
+                               using (Showcase crowApp = new Showcase ())                                      
+                                       crowApp.Run ();
+                       } catch (Exception ex) {
+                               Console.WriteLine (ex.ToString ());
+                       }
+               }
+
+               #region IValueChange implementation
+               public event EventHandler<ValueChangeEventArgs> ValueChanged;
+               public virtual void NotifyValueChanged(string MemberName, object _value)
+               {                       
+                       ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+               }
+               #endregion
+
+
+               public Command CMDViewPerf, CMDViewCfg, CMDViewTest0, CMDOpen;
+
+               public Showcase () : base () {                  
+                       CMDViewPerf = new Command(new Action(() => Load ("#testDrm.ui.perfMeasures.crow").DataSource = this)) { Caption = "Performances"};
+                       CMDViewCfg = new Command(new Action(() => Load ("#testDrm.ui.2.crow").DataSource = this)) { Caption = "Configuration"};
+                       CMDViewTest0 = new Command(new Action(() => Load ("#testDrm.ui.0.crow").DataSource = this)) { Caption = "Test view 0"};
+                       CMDOpen = new Command(new Action(() => { 
+                               lock (CrowInterface.UpdateMutex) CrowInterface.AddWidget(new FileDialog());})) { Caption = "Open"};
+
+                       GraphicObject g = Load ("#testDrm.ui.showcase.crow");
+                       g.DataSource = this;
+                       crowContainer = g.FindByName ("CrowContainer") as Container;
+                       //I set an empty object as datasource at this level to force update when new
+                       //widgets are added to the interface
+                       crowContainer.DataSource = new object ();
+               }
+
+               Container crowContainer;
+
+
+               void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
+               {
+                       FileSystemInfo fi = e.NewValue as FileSystemInfo;
+                       if (fi == null)
+                               return;                 
+                       lock (CrowInterface.UpdateMutex) {
+                               GraphicObject g = CrowInterface.Load (fi.FullName);
+                               crowContainer.SetChild (g);
+                               g.DataSource = this;
+                       }
+
+                       string source = "";
+                       using (Stream s = new FileStream (fi.FullName, FileMode.Open)) {
+                               using (StreamReader sr = new StreamReader (s)) {
+                                       source = sr.ReadToEnd ();
+                               }
+                       }
+                       NotifyValueChanged ("source", source);
+               }
+
+               void Tb_TextChanged (object sender, TextChangeEventArgs e)
+               {
+                       GraphicObject g = null;
+                       try {
+                               lock (CrowInterface.UpdateMutex) {
+                                       Instantiator inst = null;
+                                       using (MemoryStream ms = new MemoryStream (System.Text.Encoding.Unicode.GetBytes (e.Text))){
+                                               inst = new Instantiator (ms);
+                                       }
+                                       g = inst.CreateInstance (CrowInterface);
+                                       crowContainer.SetChild (g);
+
+                               }                               
+                       } catch (Exception ex) {
+                               System.Diagnostics.Debug.WriteLine (ex.ToString ());
+                       }
+                       g.DataSource = this;
+               }
+
+               #region Test values for Binding
+               public int intValue = 500;
+               DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+               //DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
+               public FileSystemInfo[] CurDirectory {
+                       get { return curDir.GetFileSystemInfos (); }
+               }
+               public int IntValue {
+                       get {
+                               return intValue;
+                       }
+                       set {
+                               intValue = value;
+                               NotifyValueChanged ("IntValue", intValue);
+                       }
+               }
+               void onSpinnerValueChange(object sender, ValueChangeEventArgs e){
+                       if (e.MemberName != "Value")
+                               return;
+                       intValue = Convert.ToInt32(e.NewValue);
+               }
+               void change_alignment(object sender, EventArgs e){
+                       RadioButton rb = sender as RadioButton;
+                       if (rb == null)
+                               return;
+                       NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
+               }
+               public IList<String> List2 = new List<string>(new string[]
+                       {
+                               "string1",
+                               "string2",
+                               "string3",
+                               //                              "string4",
+                               //                              "string5",
+                               //                              "string6",
+                               //                              "string7",
+                               //                              "string8",
+                               //                              "string8",
+                               //                              "string8",
+                               //                              "string8",
+                               //                              "string8",
+                               //                              "string8",
+                               //                              "string9"
+                       }
+               );
+               public IList<String> TestList2 {
+                       set{
+                               List2 = value;
+                               NotifyValueChanged ("TestList2", testList);
+                       }
+                       get { return List2; }
+               }
+               IList<Color> testList = Color.ColorDic.ToList();
+               public IList<Color> TestList {
+                       set{
+                               testList = value;
+                               NotifyValueChanged ("TestList", testList);
+                       }
+                       get { return testList; }
+               }
+               string curSources = "";
+               public string CurSources {
+                       get { return curSources; }
+                       set {
+                               if (value == curSources)
+                                       return;
+                               curSources = value;
+                               NotifyValueChanged ("CurSources", curSources);
+                       }
+               }
+               bool boolVal = true;
+               public bool BoolVal {
+                       get { return boolVal; }
+                       set {
+                               if (boolVal == value)
+                                       return;
+                               boolVal = value;
+                               NotifyValueChanged ("BoolVal", boolVal);
+                       }
+               }
+
+               #endregion
+
+               void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
+
+               void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
+               void onQuitClick(object send, Crow.MouseButtonEventArgs e)
+               {
+                       Running = false;
+               }
+       }
+
+
+}
\ No newline at end of file
index 78b76eee765a0d1d4c3fcf456a811b2ae21f5304..cfacae836191d4e885eacb8b66ff21b73a1dd863 100644 (file)
 // THE SOFTWARE.
 using System;
 using Crow;
+using System.Runtime.InteropServices;
 
 namespace testDrm
 {
        public class TestCrow
        {
-               static void Main(){
-                       Rectangle bounds = new Rectangle(0,0,1024,768);
-                       Interface iface = new Interface();
-                       iface.ProcessResize (bounds);
+               const string lib = "/home/jp/devel/testsharedlib/bin/Debug/libcrow.so";
 
-                       iface.LoadInterface ("#testDrm.ui.go.crow");
+               [DllImport(lib)]
+               unsafe static extern Rectangle* allocate();
 
-                       while (true)
-                               iface.Update ();
+               [DllImport(lib)]
+               public static extern void update (int w, int h);
+
+
+               unsafe static Rectangle* rect;
+
+               unsafe static void Main(){
+                       rect = allocate();
+                       update (150, 160);
+                       Console.WriteLine (rect->Height);
+                       rect->Height = 200;
+                       Console.WriteLine (rect->Height);
+//                     Rectangle bounds = new Rectangle(0,0,1024,768);
+//                     Interface iface = new Interface();
+//                     iface.ProcessResize (bounds);
+//
+//                     iface.LoadInterface ("#testDrm.ui.go.crow");
+//
+//                     while (true)
+//                             iface.Update ();
                }
        }
 }
diff --git a/testDrm/src/BlittableValueType.cs b/testDrm/src/BlittableValueType.cs
deleted file mode 100644 (file)
index 81ce16a..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-#region License
-//
-// The Open Toolkit Library License
-//
-// Copyright (c) 2006 - 2010 the Open Toolkit library.
-//
-// 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.
-//
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-using System.Reflection;
-
-namespace Linux
-{
-    #region BlittableValueType<T>
-
-    /// <summary>
-    /// Checks whether the specified type parameter is a blittable value type.
-    /// </summary>
-    /// <remarks>
-    /// A blittable value type is a struct that only references other value types recursively,
-    /// which allows it to be passed to unmanaged code directly.
-    /// </remarks>
-    public static class BlittableValueType<T>
-    {
-        #region Fields
-
-        static readonly Type Type;
-        static readonly int stride;
-
-        #endregion
-
-        #region Constructors
-
-        static BlittableValueType()
-        {
-            Type = typeof(T);
-            if (Type.IsValueType && !Type.IsGenericType)
-            {
-                // Does this support generic types? On Mono 2.4.3 it does
-                // On .Net it doesn't.
-                // http://msdn.microsoft.com/en-us/library/5s4920fa.aspx
-                stride = Marshal.SizeOf(typeof(T));
-            }
-        }
-
-        #endregion
-
-        #region Public Members
-
-        /// <summary>
-        /// Gets the size of the type in bytes or 0 for non-blittable types.
-        /// </summary>
-        /// <remarks>
-        /// This property returns 0 for non-blittable types.
-        /// </remarks>
-        public static int Stride { get { return stride; } }
-
-        #region Check
-
-        /// <summary>
-        /// Checks whether the current typename T is blittable.
-        /// </summary>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        public static bool Check()
-        {
-            return Check(Type);
-        }
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">A System.Type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        public static bool Check(Type type)
-        {
-            if (!CheckStructLayoutAttribute(type))
-                Debug.Print("Warning: type {0} does not specify a StructLayoutAttribute with Pack=1. The memory layout of the struct may change between platforms.", type.Name);
-
-            return CheckType(type);
-        }
-
-        #endregion
-
-        #endregion
-
-        #region Private Members
-
-        // Checks whether the parameter is a primitive type or consists of primitive types recursively.
-        // Throws a NotSupportedException if it is not.
-        static bool CheckType(Type type)
-        {
-            //Debug.Print("Checking type {0} (size: {1} bytes).", type.Name, Marshal.SizeOf(type));
-            if (type.IsPrimitive)
-                return true;
-
-            if (!type.IsValueType)
-                return false;
-
-            FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-            Debug.Indent();
-            foreach (FieldInfo field in fields)
-            {
-                if (!CheckType(field.FieldType))
-                    return false;
-            }
-            Debug.Unindent();
-
-            return Stride != 0;
-        }
-
-        // Checks whether the specified struct defines [StructLayout(LayoutKind.Sequential, Pack=1)]
-        // or [StructLayout(LayoutKind.Explicit)]
-        static bool CheckStructLayoutAttribute(Type type)
-        {
-            StructLayoutAttribute[] attr = (StructLayoutAttribute[])
-                type.GetCustomAttributes(typeof(StructLayoutAttribute), true);
-
-            if ((attr == null) ||
-                (attr != null && attr.Length > 0 && attr[0].Value != LayoutKind.Explicit && attr[0].Pack != 1))
-                return false;
-
-            return true;
-        }
-
-        #endregion
-    }
-
-    #endregion
-
-    #region BlittableValueType
-
-    /// <summary>
-    /// Checks whether the specified type parameter is a blittable value type.
-    /// </summary>
-    /// <remarks>
-    /// A blittable value type is a struct that only references other value types recursively,
-    /// which allows it to be passed to unmanaged code directly.
-    /// </remarks>
-    public static class BlittableValueType
-    {
-        #region Check
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">An instance of the type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        public static bool Check<T>(T type)
-        {
-            return BlittableValueType<T>.Check();
-        }
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">An instance of the type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        [CLSCompliant(false)]
-        public static bool Check<T>(T[] type)
-        {
-            return BlittableValueType<T>.Check();
-        }
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">An instance of the type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        [CLSCompliant(false)]
-        public static bool Check<T>(T[,] type)
-        {
-            return BlittableValueType<T>.Check();
-        }
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">An instance of the type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        [CLSCompliant(false)]
-        public static bool Check<T>(T[, ,] type)
-        {
-            return BlittableValueType<T>.Check();
-        }
-
-        /// <summary>
-        /// Checks whether type is a blittable value type.
-        /// </summary>
-        /// <param name="type">An instance of the type to check.</param>
-        /// <returns>True if T is blittable; false otherwise.</returns>
-        [CLSCompliant(false)]
-        public static bool Check<T>(T[][] type)
-        {
-            return BlittableValueType<T>.Check();
-        }
-
-        #endregion
-
-        #region StrideOf
-
-        /// <summary>
-        /// Returns the size of the specified value type in bytes or 0 if the type is not blittable.
-        /// </summary>
-        /// <typeparam name="T">The value type. Must be blittable.</typeparam>
-        /// <param name="type">An instance of the value type.</param>
-        /// <returns>An integer, specifying the size of the type in bytes.</returns>
-        /// <exception cref="System.ArgumentException">Occurs when type is not blittable.</exception>
-        public static int StrideOf<T>(T type)
-        {
-            if (!Check(type))
-                throw new ArgumentException("type");
-
-            return BlittableValueType<T>.Stride;
-        }
-
-        /// <summary>
-        /// Returns the size of a single array element in bytes  or 0 if the element is not blittable.
-        /// </summary>
-        /// <typeparam name="T">The value type.</typeparam>
-        /// <param name="type">An instance of the value type.</param>
-        /// <returns>An integer, specifying the size of the type in bytes.</returns>
-        /// <exception cref="System.ArgumentException">Occurs when type is not blittable.</exception>
-        [CLSCompliant(false)]
-        public static int StrideOf<T>(T[] type)
-        {
-            if (!Check(type))
-                throw new ArgumentException("type");
-
-            return BlittableValueType<T>.Stride;
-        }
-
-        /// <summary>
-        /// Returns the size of a single array element in bytes or 0 if the element is not blittable.
-        /// </summary>
-        /// <typeparam name="T">The value type.</typeparam>
-        /// <param name="type">An instance of the value type.</param>
-        /// <returns>An integer, specifying the size of the type in bytes.</returns>
-        /// <exception cref="System.ArgumentException">Occurs when type is not blittable.</exception>
-        [CLSCompliant(false)]
-        public static int StrideOf<T>(T[,] type)
-        {
-            if (!Check(type))
-                throw new ArgumentException("type");
-
-            return BlittableValueType<T>.Stride;
-        }
-
-        /// <summary>
-        /// Returns the size of a single array element in bytes or 0 if the element is not blittable.
-        /// </summary>
-        /// <typeparam name="T">The value type.</typeparam>
-        /// <param name="type">An instance of the value type.</param>
-        /// <returns>An integer, specifying the size of the type in bytes.</returns>
-        /// <exception cref="System.ArgumentException">Occurs when type is not blittable.</exception>
-        [CLSCompliant(false)]
-        public static int StrideOf<T>(T[, ,] type)
-        {
-            if (!Check(type))
-                throw new ArgumentException("type");
-
-            return BlittableValueType<T>.Stride;
-        }
-
-        #endregion
-    }
-
-    #endregion
-}
diff --git a/testDrm/src/DRMContext.cs b/testDrm/src/DRMContext.cs
deleted file mode 100644 (file)
index b945195..0000000
+++ /dev/null
@@ -1,835 +0,0 @@
-//
-// DRMDevice.cs
-//
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// 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.
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
-using OpenTK;
-using OpenTK.Platform.Linux;
-using System.IO.Compression;
-
-namespace Linux
-{
-       
-       internal class DRMContext : IDisposable
-       {
-               Stopwatch drmTimeOut;
-
-               public Interface CrowInterface;
-               int fd_gpu = 0;
-
-               IntPtr gbm_device, gbm_surface, egl_display, egl_config, egl_surface, egl_ctx;
-
-               ModeInfo originalMode, currentMode;
-               public int width, height;
-
-               volatile bool run = true;
-
-               public IntPtr Connector, Crtc, Encoder;
-               unsafe ModeCrtc* saved_crtc;
-               unsafe ModeConnector* pConnector { get { return (ModeConnector*)Connector; } }
-               unsafe ModeCrtc* pCrtc { get { return (ModeCrtc*)Crtc; } }
-               unsafe ModeEncoder* pEncoder { get { return (ModeEncoder*)Encoder; } }
-
-               Cairo.EGLDevice cairoDev;
-               Cairo.GLSurface cairoSurf;
-
-               Dictionary<KeyModifiers, string[]> keymap;
-
-               int previousVT = 0, appVT;
-
-               public DRMContext(string gpu_path = "/dev/dri/card0"){
-                       drmTimeOut = new Stopwatch();
-
-                       DestroyFB = HandleDestroyFB;
-                       DestroyFBPtr = Marshal.GetFunctionPointerForDelegate(DestroyFB);
-                       PageFlip = HandlePageFlip;
-                       PageFlipPtr = Marshal.GetFunctionPointerForDelegate(PageFlip);
-
-                       gbm_device = IntPtr.Zero;
-                       egl_display = IntPtr.Zero;
-
-                       fd_gpu = Libc.open(gpu_path, OpenFlags.ReadWrite | OpenFlags.CloseOnExec);
-                       if (fd_gpu < 0)
-                               throw new NotSupportedException("[KMS] Failed to open gpu");                    
-                       Console.WriteLine("[KMS] GPU '{0}' opened as fd:{1}", gpu_path, fd_gpu);
-
-                       initDrm ();
-
-                       initGbm ();
-
-                       setNewMode ();
-
-                       initEgl ();
-
-                       initCairo ();
-
-                       initInput ();
-               }
-
-               #region init
-               unsafe void initDrm(){                  
-                       ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd_gpu);
-                       if (resources == null)
-                               throw new NotSupportedException("[KMS] Drm.ModeGetResources failed.");
-
-                       ModeConnector* connector = null;
-                       for (int i = 0; i < resources->count_connectors; i++) {
-                               connector = (ModeConnector*)Drm.ModeGetConnector (fd_gpu, *(resources->connectors + i));
-                               if (connector != null) {
-                                       if (connector->connection == ModeConnection.Connected && connector->count_encoders > 0)
-                                               break;
-                                       Drm.ModeFreeConnector ((IntPtr)connector);
-                                       connector = null;
-                               }
-                       }
-                       if (connector == null)
-                               throw new NotSupportedException("[KMS] No connected screen found");
-
-                       Connector = (IntPtr)connector;
-                       Encoder = Drm.ModeGetEncoder (fd_gpu, connector->encoder_id);
-                       Crtc = Drm.ModeGetCrtc(fd_gpu, pEncoder->crtc_id);
-                       saved_crtc = (ModeCrtc*) Drm.ModeGetCrtc (fd_gpu, pEncoder->crtc_id);
-
-                       originalMode = pCrtc->mode;
-                       width = 1600;
-                       height = 900;
-
-                       //                      Console.WriteLine ("[DRM]: current mode = {0} X {1} at {2} Hz", width, height, currentMode.vrefresh);
-               }
-               void initGbm (){
-                       gbm_device = Gbm.CreateDevice(fd_gpu);
-                       if (gbm_device == IntPtr.Zero)
-                               throw new NotSupportedException("[GBM] Failed to create GBM device");                   
-
-                       gbm_surface =  Gbm.CreateSurface(gbm_device, width, height, SurfaceFormat.ARGB8888, SurfaceFlags.Rendering | SurfaceFlags.Scanout);
-                       if (gbm_surface == IntPtr.Zero)
-                               throw new NotSupportedException("[GBM] Failed to create GBM surface for rendering");                                            
-               }
-
-               void setNewMode (){
-                       //118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
-                       //currentMode = pCrtc->mode;
-                       currentMode.clock = 118250;
-                       currentMode.hdisplay = 1600;
-                       currentMode.hsync_start = 1696;
-                       currentMode.hsync_end = 1856;
-                       currentMode.htotal = 2112;
-                       currentMode.vdisplay = 900;
-                       currentMode.vsync_start = 903;
-                       currentMode.vsync_end = 908;
-                       currentMode.vtotal = 934;
-                       currentMode.flags |= (uint)ModeFlags.NHSYNC;
-                       currentMode.flags |= (uint)ModeFlags.PVSYNC;
-                       //                      byte[] tmp = System.Text.Encoding.ASCII.GetBytes ("1600x900");
-                       //                      for (int i = 0; i < tmp.Length; i++) {
-                       //                              currentMode.name [i] = (sbyte)tmp [i];
-                       //                      }
-
-                       unsafe
-                       {
-                               pCrtc->mode = currentMode;
-                               ModeInfo* mode = (ModeInfo*)Marshal.AllocHGlobal (sizeof(ModeInfo));// pConnector->modes;
-                               *mode = currentMode;
-                               int connector_id = pConnector->connector_id;
-                               int crtc_id = pEncoder->crtc_id;
-                               BufferObject bo = Gbm.CreateBuffer(
-                                       gbm_device, width, height, SurfaceFormat.ARGB8888, SurfaceFlags.Scanout);
-                               int nfb = getFbFromBo (bo);
-                               int ret = Drm.ModeSetCrtc (fd_gpu, crtc_id, nfb, 0, 0, &connector_id, 1, mode);
-
-                               if (ret != 0)
-                                       Console.WriteLine("[KMS] Drm.ModeSetCrtc failed. Error: " + ret);                               
-                       }
-                       //                      width = currentMode.hdisplay;
-                       //                      height = currentMode.vdisplay;                  
-               }
-
-               unsafe void initEgl () {
-                       int major, minor;
-                       IntPtr[] configs = new IntPtr[1];
-
-                       int[] contextAttrib = new int[] {
-                               Egl.CONTEXT_CLIENT_VERSION, 2,
-                               Egl.NONE
-                       };
-                       int[] attribList = new int[] 
-                       {                               
-                               Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
-                               Egl.RENDERABLE_TYPE, Egl.OPENGL_BIT,
-                               Egl.RED_SIZE, 1, 
-                               Egl.GREEN_SIZE, 1, 
-                               Egl.BLUE_SIZE, 1,
-                               Egl.ALPHA_SIZE, 0,
-                               //Egl.DEPTH_SIZE, 24,
-                               //Egl.STENCIL_SIZE, 0,
-                               //Egl.SAMPLE_BUFFERS, 2,
-                               //Egl.SAMPLES, 0,
-                               Egl.NONE
-                       };
-                       int num_configs;
-
-                       egl_display = Egl.GetDisplay(gbm_device);
-
-                       if (egl_display == IntPtr.Zero)
-                               throw new NotSupportedException("[KMS] Failed to create EGL display");
-                       Console.WriteLine("[EGL] EGL display {0:x} created successfully", egl_display);
-
-                       if (!Egl.Initialize(egl_display, out major, out minor))
-                               throw new NotSupportedException("[EGL] Failed to initialize EGL display. Error code: " + Egl.GetError());
-
-                       if (!Egl.BindAPI (RenderApi.GL))
-                               throw new NotSupportedException("[EGL] Failed to bind EGL Api: " + Egl.GetError());
-
-                       Console.WriteLine ("[EGL] Version: " +  Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VERSION)));
-                       Console.WriteLine ("[EGL] Vendor: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VENDOR)));
-                       Console.WriteLine ("[EGL] Extensions: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.EXTENSIONS)));
-                       Console.WriteLine ("                  " + Marshal.PtrToStringAuto (Egl.QueryString(IntPtr.Zero, Egl.EXTENSIONS)));
-
-                       if (!Egl.ChooseConfig(egl_display, attribList, configs, configs.Length, out num_configs) || num_configs == 0)
-                               throw new NotSupportedException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
-
-                       egl_config = configs[0];
-                       egl_ctx = Egl.CreateContext(egl_display, egl_config, IntPtr.Zero, contextAttrib);
-                       egl_surface = Egl.CreateWindowSurface(egl_display, egl_config, gbm_surface, IntPtr.Zero);
-
-                       if (egl_surface==IntPtr.Zero)
-                               throw new NotSupportedException(String.Format("[EGL] Failed to create window surface, error {0}.", Egl.GetError()));
-
-                       // See what we really got
-                       int r, g, b, a, d, s, sample_buffers, samples;
-                       IntPtr active_config = configs[0];
-
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.RED_SIZE, out r);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.GREEN_SIZE, out g);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.BLUE_SIZE, out b);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.ALPHA_SIZE, out a);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.DEPTH_SIZE, out d);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.STENCIL_SIZE, out s);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLE_BUFFERS, out sample_buffers);
-                       Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLES, out samples);
-                       Console.WriteLine ("EGL context: {0},{1},{2},{3} depth={4} stencil={5} samples={6} sample buffers={7}",
-                                                       r, g, b, a, d, s, samples, sample_buffers);
-
-
-                       if (!Egl.MakeCurrent(egl_display, egl_surface, egl_surface, egl_ctx))
-                               throw new NotSupportedException(string.Format("Failed to make context {0} current. Error: {1}", gbm_surface, Egl.GetError()));
-               }
-
-               void initCairo (){
-                       cairoDev = new Cairo.EGLDevice (egl_display, egl_ctx);
-
-                       cairoSurf = new Cairo.GLSurface (cairoDev, egl_surface, width, height);
-                       //cairoSurf = new Cairo.EGLSurface (cairoDev, egl_surface, 1600, 900);
-
-                       cairoDev.SetThreadAware (false);
-
-                       if (cairoDev.Acquire () != Cairo.Status.Success)
-                               Console.WriteLine ("[Cairo]: Failed to acquire egl device.");
-               }
-               #endregion
-
-               #region cursor
-               BufferObject boMouseCursor = BufferObject.Zero;
-
-               internal void updateCursor (XCursor cursor) {
-                       uint width = 64, height = 64;
-                       if (cursor.Width > width || cursor.Height > height){
-                               Debug.Print("[DRM] Cursor size {0}x{1} unsupported. Maximum is 64x64.",
-                                       cursor.Width, cursor.Height);
-                               return;
-                       }
-
-                       if (boMouseCursor != BufferObject.Zero)
-                               Gbm.DestroyBuffer (boMouseCursor);
-
-                       boMouseCursor = Gbm.CreateBuffer (gbm_device, (int)width, (int)height,
-                               SurfaceFormat.ARGB8888, SurfaceFlags.Cursor64x64 | SurfaceFlags.Write);
-
-                       if (boMouseCursor == BufferObject.Zero)
-                       {
-                               Debug.Print("[DRM] Failed to create buffer for mouse cursor.");
-                               return;
-                       }
-
-                       // Copy cursor.Data into a new buffer of the correct size
-                       byte[] cursor_data = new byte[width * height * 4];
-                       for (uint y = 0; y < cursor.Height; y++)
-                       {
-                               uint dst_offset = y * width * 4;
-                               uint src_offset = y * cursor.Width * 4;
-                               uint src_length = cursor.Width * 4;
-                               Array.Copy(
-                                       cursor.data, src_offset,
-                                       cursor_data, dst_offset,
-                                       src_length);
-                       }
-
-                       boMouseCursor.Write(cursor_data);
-
-                       unsafe {                                
-                               Drm.SetCursor (fd_gpu, pEncoder->crtc_id,
-                                       boMouseCursor.Handle, boMouseCursor.Width, boMouseCursor.Height, (int)cursor.Xhot, (int)cursor.Yhot);
-                       }
-               }
-               #endregion
-
-               int getFbFromBo (BufferObject bo){
-                       int width = bo.Width;
-                       int height = bo.Height;
-                       int bpp = 32;
-                       int depth = 24;
-                       int stride = bo.Stride;
-                       int hndBO = bo.Handle;
-
-                       int fb;
-                       int ret = Drm.ModeAddFB (fd_gpu, width, height,(byte)depth, (byte)bpp, stride, hndBO, out fb);
-                       if (ret != 0)
-                               throw new Exception ("[DRM]: ModeAddFB failed.");
-                       bo.SetUserData ((IntPtr)fb, DestroyFBPtr);
-                       return fb;
-               }
-
-               public void Run(){
-                       BufferObject bo;
-                       int fb;
-
-                       PollFD fds = new PollFD();
-                       fds.fd = fd_gpu;
-                       fds.events = PollFlags.In;
-
-                       EventContext evctx = new EventContext();
-                       evctx.version = EventContext.Version;
-                       evctx.page_flip_handler = PageFlipPtr;
-
-                       int timeout = -1;//block ? -1 : 0;
-
-                       using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
-                               ctx.Rectangle (0, 0, width, height);
-                               ctx.SetSourceRGB (0, 0, 0);
-                               ctx.Fill ();
-                       }
-
-                       cairoSurf.SwapBuffers ();
-
-                       bo = Gbm.LockFrontBuffer (gbm_surface);
-                       fb = getFbFromBo (bo);
-
-                       SetScanoutRegion (fb);
-                       drmTimeOut.Restart();
-
-                       while (run && drmTimeOut.ElapsedMilliseconds < 10000){                          
-                               BufferObject next_bo;
-                               bool update = false;
-
-                               if (updateMousePos) {
-                                       lock (Sync) {
-                                               updateMousePos = false;
-                                               unsafe {        
-                                                       Drm.MoveCursor (fd_gpu, pEncoder->crtc_id, MouseX-8, MouseY-4);
-                                               }
-                                       }
-                               }
-
-                               if (Monitor.TryEnter (CrowInterface.RenderMutex)) {
-                                       if (CrowInterface.IsDirty) {
-                                               CrowInterface.IsDirty = false;
-                                               update = true;
-                                               using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
-                                                       using (Cairo.Surface d = new Cairo.ImageSurface (CrowInterface.dirtyBmp, Cairo.Format.Argb32,
-                                                               width, height, width * 4)) {
-                                                               ctx.SetSourceSurface (d, 0, 0);
-                                                               ctx.Operator = Cairo.Operator.Source;
-                                                               ctx.Paint ();
-                                                       }
-                                               }
-                                       }
-                                       Monitor.Exit (CrowInterface.RenderMutex);
-                               }
-
-                               if (!update)
-                                       continue;
-                               update = false;
-
-                               cairoSurf.Flush ();
-                               cairoSurf.SwapBuffers ();
-
-                               if (Gbm.HasFreeBuffers (gbm_surface) == 0)
-                                       throw new Exception ("[GBM]: Out of free buffers.");
-
-                               next_bo = Gbm.LockFrontBuffer (gbm_surface);
-                               if (next_bo == BufferObject.Zero)
-                                       throw new Exception ("[GBM]: Failed to lock front buffer.");
-
-                               fb = getFbFromBo (next_bo);
-
-                               unsafe{
-                                       int is_flip_queued = 1;
-
-                                       while (Drm.ModePageFlip (fd_gpu, pEncoder->crtc_id, fb, PageFlipFlags.FlipEvent, ref is_flip_queued) < 0) {
-                                               //Console.WriteLine ("[DRM] Failed to enqueue framebuffer flip.");                              
-                                               continue;
-                                       }
-
-                                       while (is_flip_queued != 0)
-                                       {
-                                               fds.revents = 0;
-                                               if (Libc.poll (ref fds, 1, timeout) < 0)
-                                                       break;                                          
-
-                                               if ((fds.revents & (PollFlags.Hup | PollFlags.Error)) != 0)
-                                                       break;
-
-                                               if ((fds.revents & PollFlags.In) != 0)
-                                                       Drm.HandleEvent (fd_gpu, ref evctx);
-                                               else
-                                                       break;
-                                               Thread.Sleep (1);
-                                       }
-                                       if (is_flip_queued != 0)
-                                               Console.WriteLine ("flip canceled");
-
-                                       Gbm.ReleaseBuffer (gbm_surface, bo);
-                                       //Drm.ModeRmFB(fd_gpu, fb);
-
-                                       bo = next_bo;
-                                       next_bo = BufferObject.Zero;
-
-                               }
-                       }
-               }
-
-               #region rendering
-
-
-
-               // We only support a SwapInterval of 0 (immediate)
-               // or 1 (vsynced).
-               // Todo: add support for SwapInterval of -1 (adaptive).
-               // This requires a small change in WaitFlip().
-               int swap_interval=0;
-
-               readonly IntPtr PageFlipPtr;
-               readonly PageFlipCallback PageFlip;
-
-               readonly IntPtr DestroyFBPtr;
-               readonly DestroyUserDataCallback DestroyFB;
-
-               void HandlePageFlip(int fd,     int sequence, int tv_sec, int tv_usec, ref int user_data)
-               {
-                       user_data = 0;
-               }
-
-
-               void HandleDestroyFB(BufferObject bo, IntPtr data)
-               {
-                       Console.WriteLine ("DestroyFB");
-                       IntPtr gbm = bo.Device;
-                       int fb = data.ToInt32();
-
-                       if (fb != 0)
-                               Drm.ModeRmFB(fd_gpu, fb);
-               }
-
-               void SetScanoutRegion(int buffer)
-               {                       
-                       unsafe
-                       {
-                               ModeInfo* mode = pConnector->modes;
-                               int connector_id = pConnector->connector_id;
-                               int crtc_id = pEncoder->crtc_id;
-
-                               int ret = Drm.ModeSetCrtc (fd_gpu, crtc_id, buffer, 0, 0, &connector_id, 1, mode);
-
-                               if (ret != 0)
-                                       Debug.Print("[KMS] Drm.ModeSetCrtc{0}, {1}, {2} failed. Error: {3}",
-                                               fd_gpu, crtc_id, buffer, ret);                          
-                               Console.WriteLine ("scanout region set: {0}x{1}", mode->hdisplay, mode->vdisplay);
-                       }
-               }
-               #endregion
-
-               #region IDisposable implementation
-               public void Dispose ()
-               {
-                       cairoDev.Release ();
-                       cairoSurf.Dispose ();
-                       cairoDev.Dispose ();
-
-                       //                      if (fb != 0)
-                       //                              Drm.ModeRmFB (fd_gpu, fb);
-                       //                      if (bo != BufferObject.Zero)
-                       //                              Gbm.ReleaseBuffer (gbm_surface, bo);                    
-                       //                      if (next_fb != 0)
-                       //                              Drm.ModeRmFB (fd_gpu, next_fb);
-                       //                      if (next_bo != BufferObject.Zero)
-                       //                              Gbm.ReleaseBuffer (gbm_surface, next_bo);                       
-
-                       if (Egl.GetCurrentContext () == egl_ctx) {
-                               Console.WriteLine ("destroying context");
-                               Egl.DestroyContext (egl_display, egl_ctx);
-                       }else
-                               Console.WriteLine ("not current");
-
-                       cairoDev.Dispose ();
-
-                       unsafe{
-                               Drm.ModeSetCrtc (fd_gpu, saved_crtc->crtc_id, saved_crtc->buffer_id,
-                                       saved_crtc->x, saved_crtc->y, &pConnector->connector_id, 1, &saved_crtc->mode);
-                               Drm.ModeFreeCrtc ((IntPtr)saved_crtc);
-                       }
-
-                       Drm.ModeFreeCrtc (Crtc);
-                       Drm.ModeFreeConnector(Connector);
-                       Drm.ModeFreeEncoder(Encoder);
-                       Libc.close(fd_gpu);
-
-//                     using(VTControler master = new VTControler()){
-//                             master.CurrentMode = TTY.Mode.TEXT;
-//                             if (master.CurrentVT != previousVT) {
-//                                     master.SwitchTo (previousVT);
-//                             }
-//                     }
-               }
-               #endregion
-
-               #region INPUT
-               Thread input_thread;
-               long exit;
-
-               static readonly object Sync = new object();
-               static readonly Crow.Key[] KeyMap = Evdev.KeyMap;
-               static long DeviceFDCount;
-
-               IntPtr udev;
-               IntPtr input_context;
-
-               int input_fd = 0;
-
-               InputInterface input_interface = new InputInterface(
-                       OpenRestricted, CloseRestricted);
-               static CloseRestrictedCallback CloseRestricted = CloseRestrictedHandler;
-               static void CloseRestrictedHandler(int fd, IntPtr data)
-               {
-                       Debug.Print("[Input] Closing fd {0}", fd);
-                       int ret = Libc.close(fd);
-
-                       if (ret < 0)
-                       {
-                               Debug.Print("[Input] Failed to close fd {0}. Error: {1}", fd, ret);
-                       }
-                       else
-                       {
-                               Interlocked.Decrement(ref DeviceFDCount);
-                       }
-               }
-
-               static OpenRestrictedCallback OpenRestricted = OpenRestrictedHandler;
-               static int OpenRestrictedHandler(IntPtr path, int flags, IntPtr data) 
-               {
-                       int fd = Libc.open(path, (OpenFlags)flags);
-                       Debug.Print("[Input] Opening '{0}' with flags {1}. fd:{2}",
-                               Marshal.PtrToStringAnsi(path), (OpenFlags)flags, fd);
-
-                       if (fd >= 0)
-                       {
-                               Interlocked.Increment(ref DeviceFDCount);
-                       }
-
-                       return fd;
-               }
-
-               void initInput (){
-                       Semaphore ready = new Semaphore(0, 1);
-                       input_thread = new Thread (InputThreadLoop);
-                       input_thread.IsBackground = true;
-                       input_thread.Start(ready);
-               }
-
-               void InputThreadLoop(object semaphore)
-               {
-                       Debug.Print("[Input] Running on thread {0}", Thread.CurrentThread.ManagedThreadId);
-                       Setup();
-
-                       // Inform the parent thread that initialization has completed successfully
-                       (semaphore as Semaphore).Release();
-                       Debug.Print("[Input] Released main thread.", input_context);
-
-                       // Use a blocking poll for input messages, in order to reduce CPU usage
-                       PollFD poll_fd = new PollFD();
-                       poll_fd.fd = input_fd;
-                       poll_fd.events = PollFlags.In;
-                       Debug.Print("[Input] Created PollFD({0}, {1})", poll_fd.fd, poll_fd.events);
-
-                       Debug.Print("[Input] Entering input loop.", poll_fd.fd, poll_fd.events);
-                       while (Interlocked.Read(ref exit) == 0)
-                       {
-                               drmTimeOut.Restart ();
-
-                               int ret = Libc.poll(ref poll_fd, 1, -1);
-                               ErrorNumber error = (ErrorNumber)Marshal.GetLastWin32Error();
-                               bool is_error =
-                                       ret < 0 && !(error == ErrorNumber.Again || error == ErrorNumber.Interrupted) ||
-                                       (poll_fd.revents & (PollFlags.Hup | PollFlags.Error | PollFlags.Invalid)) != 0;
-
-                               if (ret > 0 && (poll_fd.revents & (PollFlags.In | PollFlags.Pri)) != 0)
-                                       ProcessEvents(input_context);
-
-                               if (is_error)
-                               {
-                                       Debug.Print("[Input] Exiting input loop {0} due to poll error [ret:{1} events:{2}]. Error: {3}.",
-                                               input_thread.ManagedThreadId, ret, poll_fd.revents, error);
-                                       Interlocked.Increment(ref exit);
-                               }
-                       }
-                       Debug.Print("[Input] Exited input loop.", poll_fd.fd, poll_fd.events);
-               }
-
-               void Setup()
-               {
-                       // Todo: add static path fallback when udev is not installed.
-                       udev = Udev.New();
-                       if (udev == IntPtr.Zero)
-                       {
-                               Debug.Print("[Input] Udev.New() failed.");
-                               Interlocked.Increment(ref exit);
-                               return;
-                       }
-                       Debug.Print("[Input] Udev.New() = {0:x}", udev);
-
-                       input_context = LibInput.CreateContext(input_interface, IntPtr.Zero, udev);
-                       if (input_context == IntPtr.Zero)
-                       {
-                               Debug.Print("[Input] LibInput.CreateContext({0:x}) failed.", udev);
-                               Interlocked.Increment(ref exit);
-                               return;
-                       }
-                       Debug.Print("[Input] LibInput.CreateContext({0:x}) = {1:x}", udev, input_context);
-
-                       string seat_id = "seat0";
-                       int seat_assignment = LibInput.AssignSeat(input_context, seat_id);
-                       if (seat_assignment == -1)
-                       {
-                               Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1} failed.", input_context, seat_id);
-                               Interlocked.Increment(ref exit);
-                               return;
-                       }
-                       Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1}", input_context, seat_id);
-
-                       input_fd = LibInput.GetFD(input_context);
-                       if (input_fd < 0)
-                       {
-                               Debug.Print("[Input] LibInput.GetFD({0:x}) failed.", input_context);
-                               Interlocked.Increment(ref exit);
-                               return;
-                       }
-                       Debug.Print("[Input] LibInput.GetFD({0:x}) = {1}.", input_context, input_fd);
-
-                       ProcessEvents(input_context);
-                       LibInput.Resume(input_context);
-                       Debug.Print("[Input] LibInput.Resume({0:x})", input_context);
-
-                       if (Interlocked.Read(ref DeviceFDCount) <= 0)
-                       {
-                               Debug.Print("[Error] Failed to open any input devices.");
-                               Debug.Print("[Error] Ensure that you have access to '/dev/input/event*'.");
-                               Interlocked.Increment(ref exit);
-                       }
-               }
-
-               void ProcessEvents(IntPtr input_context)
-               {
-                       // Process all events in the event queue
-                       while (true)
-                       {                               
-                               // Data available
-                               int ret = LibInput.Dispatch(input_context);
-                               if (ret != 0)
-                               {
-                                       Debug.Print("[Input] LibInput.Dispatch({0:x}) failed. Error: {1}",
-                                               input_context, ret);
-                                       break;
-                               }
-
-                               IntPtr pevent = LibInput.GetEvent(input_context);
-                               if (pevent == IntPtr.Zero)
-                               {
-                                       break;
-                               }
-
-                               IntPtr device = LibInput.GetDevice(pevent);
-                               InputEventType type = LibInput.GetEventType(pevent);
-
-                               lock (Sync)
-                               {
-                                       switch (type)
-                                       {
-                                       //                                      case InputEventType.DeviceAdded:
-                                       //                                              HandleDeviceAdded(input_context, device);
-                                       //                                              break;
-                                       //
-                                       //                                      case InputEventType.DeviceRemoved:
-                                       //                                              HandleDeviceRemoved(input_context, device);
-                                       //                                              break;
-                                       //
-                                       case InputEventType.KeyboardKey:
-                                               //run = false;
-                                               handleKeyboard(LibInput.GetKeyboardEvent(pevent));
-                                               break;
-                                               //
-                                               //                                      case InputEventType.PointerAxis:
-                                               //                                              HandlePointerAxis(GetMouse(device), LibInput.GetPointerEvent(pevent));
-                                               //                                              break;
-                                               //
-                                       case InputEventType.PointerButton:
-                                               handlePointerButton (LibInput.GetPointerEvent(pevent));
-                                               break;
-
-                                       case InputEventType.PointerMotion:
-                                               handlePointerMotion (LibInput.GetPointerEvent(pevent));
-                                               break;
-
-                                               //                                      case InputEventType.PointerMotionAbsolute:
-                                               //                                              HandlePointerMotionAbsolute(GetMouse(device), LibInput.GetPointerEvent(pevent));
-                                               //                                              break;
-                                       }
-                               }
-
-                               LibInput.DestroyEvent(pevent);
-                       }
-               }
-               int MouseX = 0, MouseY = 0;
-               volatile bool updateMousePos = true;
-
-               int roundDelta (double d){
-                       return d > 0 ? (int)Math.Ceiling(d) : (int)Math.Floor (d);
-               }
-
-               void handlePointerMotion(PointerEvent e)
-               {
-                       MouseX += roundDelta (e.DeltaX);
-                       MouseY += roundDelta (e.DeltaY);
-
-                       Rectangle bounds = CrowInterface.ClientRectangle;
-                       if (MouseX < bounds.Left)
-                               MouseX = bounds.Left;
-                       else if (MouseX > bounds.Right)
-                               MouseX = bounds.Right;
-
-                       if (MouseY < bounds.Top)
-                               MouseY = bounds.Top;
-                       else if (MouseY > bounds.Bottom)
-                               MouseY = bounds.Bottom;
-
-                       CrowInterface.ProcessMouseMove (MouseX, MouseY);
-
-                       updateMousePos = true;
-               }
-               void handlePointerButton (PointerEvent e)
-               {                       
-                       int but = 0;
-                       switch (e.Button) {
-                       case EvdevButton.LEFT:
-                               but = 0;
-                               break;
-                       case EvdevButton.MIDDLE:
-                               but = 1;
-                               break;
-                       case EvdevButton.RIGHT:
-                               but = 2;
-                               break;
-                       }
-                       if (e.ButtonState == ButtonState.Pressed)
-                               CrowInterface.ProcessMouseButtonDown (but);
-                       else
-                               CrowInterface.ProcessMouseButtonUp (but);
-               }
-
-               KeyModifiers curModifiers = KeyModifiers.None;
-
-               void handleKeyboard(KeyboardEvent e)
-               {
-                       return;
-                       int key = (int)Evdev.KeyMap [e.Key];
-                       Key k = (Key)key;
-                       if (e.KeyState == KeyState.Pressed) {
-                               CrowInterface.ProcessKeyDown (key);
-                               switch (k) {
-                               case Key.ShiftLeft:
-                               case Key.ShiftRight:
-                                       curModifiers |= KeyModifiers.Shift;
-                                       break;
-                               case Key.ControlLeft:
-                               case Key.ControlRight:
-                                       curModifiers |= KeyModifiers.Control;
-                                       break;
-                               case Key.AltLeft:
-                                       curModifiers |= KeyModifiers.Alt;
-                                       break;
-                               case Key.AltRight:
-                                       curModifiers |= KeyModifiers.AltGr;
-                                       break;
-                               }
-                       }else {
-                               CrowInterface.ProcessKeyUp (key);
-                               switch (k) {
-                               case Key.ShiftLeft:
-                               case Key.ShiftRight:
-                                       curModifiers &= ~KeyModifiers.Shift;
-                                       break;
-                               case Key.ControlLeft:
-                               case Key.ControlRight:
-                                       curModifiers &= ~KeyModifiers.Control;
-                                       break;
-                               case Key.AltLeft:
-                                       curModifiers &= ~KeyModifiers.Alt;
-                                       break;
-                               case Key.AltRight:
-                                       curModifiers &= ~KeyModifiers.AltGr;
-                                       break;
-                               }
-                               if (!keymap.ContainsKey (curModifiers)) {
-                                       Console.WriteLine ("keymap not found for: " + curModifiers + " " + (int)curModifiers);
-                                       return;
-                               }
-                               string tmp = keymap [curModifiers] [e.Key];
-//                             if (string.IsNullOrEmpty (tmp))
-//                                     return;
-//                             if (char.IsControl (tmp[0]))
-//                                     return;
-//                             CrowInterface.ProcessKeyPress (tmp [0]);
-                       }                       
-               }
-
-               #endregion
-       }
-}
-
-
-
-
diff --git a/testDrm/src/DisplayResolution.cs b/testDrm/src/DisplayResolution.cs
deleted file mode 100644 (file)
index 4341940..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK team.
- * This notice may not be removed.
- * See license.txt for licensing detailed licensing details.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Diagnostics;
-#if !MINIMAL
-using System.Drawing;
-#endif
-
-namespace OpenTK
-{
-    /// <summary>Contains information regarding a monitor's display resolution.</summary>
-    public class DisplayResolution
-    {
-        Rectangle bounds;
-        int bits_per_pixel;
-        float refresh_rate;
-
-        #region --- Constructors ---
-
-        internal DisplayResolution() { }
-
-        #region public DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate)
-
-        // Creates a new DisplayResolution object for the primary DisplayDevice.
-        internal DisplayResolution(int x, int y, int width, int height, int bitsPerPixel, float refreshRate)
-        {
-            // Refresh rate may be zero, since this information may not be available on some platforms.
-            if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
-            if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
-            if (bitsPerPixel <= 0) throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero.");
-            if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero.");
-
-            this.bounds = new Rectangle(x, y, width, height);
-            this.bits_per_pixel = bitsPerPixel;
-            this.refresh_rate = refreshRate;
-        }
-
-        #endregion
-
-        #region public DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate, DisplayDevice device)
-
-#if false
-
-        /// <summary>
-        /// Creates a new DisplayResolution object for the specified DisplayDevice.
-        /// </summary>
-        /// <param name="width">The requested width in pixels.</param>
-        /// <param name="height">The requested height in pixels.</param>
-        /// <param name="bitsPerPixel">The requested bits per pixel in bits.</param>
-        /// <param name="refreshRate">The requested refresh rate in hertz.</param>
-        /// <remarks>OpenTK will select the closest match between all available resolutions on the specified DisplayDevice.</remarks>
-        /// 
-        public DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate, DisplayDevice device)
-        {
-            // Refresh rate may be zero, since this information may not be available on some platforms.
-            if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
-            if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
-            if (bitsPerPixel <= 0) throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero.");
-            if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero.");
-            if (device == null) throw new ArgumentNullException("DisplayDevice", "Must be a valid DisplayDevice");
-
-            DisplayResolution res = device.SelectResolution(width, height, bitsPerPixel, refreshRate);
-
-            this.width = res.width;
-            this.height = res.height;
-            this.bits_per_pixel = res.bits_per_pixel;
-            this.refresh_rate = res.refresh_rate;
-        }
-#endif
-        #endregion
-
-        #endregion
-
-        #region --- Public Methods ---
-
-        #region Bounds
-
-        /// <summary>
-        /// Gets a System.Drawing.Rectangle that contains the bounds of this display device.
-        /// </summary>
-        [Obsolete("This property will return invalid results if a monitor changes resolution. Use DisplayDevice.Bounds instead.")]
-        [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
-        public Rectangle Bounds
-        {
-            get { return bounds; }
-        }
-
-        #endregion
-
-        #region public int Width
-
-        /// <summary>Gets a System.Int32 that contains the width of this display in pixels.</summary>
-        public int Width
-        {
-            get { return bounds.Width; }
-            internal set { bounds.Width = value; }
-        }
-
-        #endregion
-
-        #region public int Height
-
-        /// <summary>Gets a System.Int32 that contains the height of this display in pixels.</summary>
-        public int Height
-        {
-            get { return bounds.Height; }
-            internal set { bounds.Height = value; }
-        }
-
-        #endregion
-
-        #region public int BitsPerPixel
-
-        /// <summary>Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.</summary>
-        public int BitsPerPixel
-        {
-            get { return bits_per_pixel; }
-            internal set { bits_per_pixel = value; }
-        }
-
-        #endregion
-
-        #region public float RefreshRate
-
-        /// <summary>
-        /// Gets a System.Single representing the vertical refresh rate of this display.
-        /// </summary>
-        public float RefreshRate
-        {
-            get { return refresh_rate; }
-            internal set { refresh_rate = value; }
-        }
-
-        #endregion
-
-        #endregion
-
-        #region --- Overrides ---
-
-        #region public override string ToString()
-
-        /// <summary>
-        /// Returns a System.String representing this DisplayResolution.
-        /// </summary>
-        /// <returns>A System.String representing this DisplayResolution.</returns>
-        public override string ToString()
-        {
-            #pragma warning disable 612,618
-            return String.Format("{0}x{1}@{2}Hz", Bounds, bits_per_pixel, refresh_rate);
-            #pragma warning restore 612,618
-        }
-
-        #endregion
-
-        #region public override bool Equals(object obj)
-
-        /// <summary>Determines whether the specified resolutions are equal.</summary>
-        /// <param name="obj">The System.Object to check against.</param>
-        /// <returns>True if the System.Object is an equal DisplayResolution; false otherwise.</returns>
-        public override bool Equals(object obj)
-        {
-            if (obj == null) return false;
-            if (this.GetType() == obj.GetType())
-            {
-                DisplayResolution res = (DisplayResolution)obj;
-                return
-                    Width == res.Width &&
-                    Height == res.Height &&
-                    BitsPerPixel == res.BitsPerPixel &&
-                    RefreshRate == res.RefreshRate;
-            }
-
-            return false;
-        }
-
-        #endregion
-
-        #region public override int GetHashCode()
-
-        /// <summary>Returns a unique hash representing this resolution.</summary>
-        /// <returns>A System.Int32 that may serve as a hash code for this resolution.</returns>
-        public override int GetHashCode()
-        {
-            #pragma warning disable 612,618
-            return Bounds.GetHashCode() ^ bits_per_pixel ^ refresh_rate.GetHashCode();
-            #pragma warning restore 612,618
-        }
-
-        #endregion
-
-        #endregion
-
-        #region --- Operator Overloads ---
-
-        /// <summary>
-        /// Compares two instances for equality.
-        /// </summary>
-        /// <param name="left">The first instance.</param>
-        /// <param name="right">The second instance.</param>
-        /// <returns>True, if left equals right; false otherwise.</returns>
-        public static bool operator== (DisplayResolution left, DisplayResolution right)
-        {
-            if (((object)left) == null && ((object)right) == null)
-                return true;
-            else if ((((object)left) == null && ((object)right) != null) ||
-                     (((object)left) != null && ((object)right) == null))
-                return false;
-            return left.Equals(right);
-        }
-
-        /// <summary>
-        /// Compares two instances for inequality.
-        /// </summary>
-        /// <param name="left">The first instance.</param>
-        /// <param name="right">The second instance.</param>
-        /// <returns>True, if left does not equal right; false otherwise.</returns>
-        public static bool operator !=(DisplayResolution left, DisplayResolution right)
-        {
-            return !(left == right);
-        }
-
-        #endregion
-    }
-}
index 4cbd61c9a14ecbc87e370ee8545bbc63e6e6f0cc..06e9cdfc05c9c217e70552244e07354a809fe97e 100644 (file)
@@ -386,21 +386,7 @@ namespace Linux.oldEvDev
             return (uint)v;
         }
 
-        // Get absolute value / limits
-        public static int GetAbs(int fd, EvdevAxis axis, out InputAbsInfo info)
-        {
-            info = default(InputAbsInfo);
-            unsafe
-            {
-                fixed (InputAbsInfo* pinfo = &info)
-                {
-                    // EVIOCGABS(abs) = _IOR('E', 0x40 + (abs), struct input_absinfo)
-                    uint ioctl = IOCreate(DirectionFlags.Read, (int)axis + 0x40, BlittableValueType<InputAbsInfo>.Stride);
-                    int retval = Libc.ioctl(fd, ioctl, new IntPtr(pinfo));
-                    return retval;
-                }
-            }
-        }
+
 
         // Get supported event bits
         public static int GetBit(int fd, EvdevType ev, int length, IntPtr data)
index 3fc3935eebadae666365c6e04038cfdff9ea63f3..cb2794f23cec88eebca5c3cee553400319bdad82 100644 (file)
@@ -172,6 +172,8 @@ namespace Linux.DRI {
                        gbmDev = new GBM.Device (fd_gpu);
                        eglctx = new EGL.Context (gbmDev);
 
+                       Console.WriteLine (eglctx.Extensions);
+                       Console.WriteLine (eglctx.OffScreenExtensions);
                        try {
                                if (defaultConfiguration ())
                                        Console.WriteLine ("default config ok");
diff --git a/testDrm/src/MouseCursor.cs b/testDrm/src/MouseCursor.cs
deleted file mode 100644 (file)
index df8cd0c..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#region License
-//
-// Cursor.cs
-//
-// Author:
-//       Stefanos A. <stapostol@gmail.com>
-//
-// Copyright (c) 2006-2014 Stefanos Apostolopoulos
-//
-// 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.
-//
-#endregion
-
-using System;
-
-namespace OpenTK
-{
-    /// <summary>
-    /// Represents a predefined or custom mouse cursor.
-    /// </summary>
-    public sealed class MouseCursor : WindowIcon
-    {
-        static readonly MouseCursor default_cursor = new MouseCursor();
-        static readonly MouseCursor empty_cursor = new MouseCursor(
-            0, 0, 16, 16, new byte[16 * 16 * 4]);
-
-        int x;
-        int y;
-
-        MouseCursor()
-        {
-        }
-
-        /// <summary>
-        /// Initializes a new <see cref="MouseCursor"/> instance from a
-        /// contiguous array of BGRA pixels.
-        /// Each pixel is composed of 4 bytes, representing B, G, R and A values,
-        /// respectively. For correct antialiasing of translucent cursors,
-        /// the B, G and R components should be premultiplied with the A component:
-        /// <code>
-        /// B = (byte)((B * A) / 255)
-        /// G = (byte)((G * A) / 255)
-        /// R = (byte)((R * A) / 255)
-        /// </code>
-        /// </summary>
-        /// <param name="hotx">The x-coordinate of the cursor hotspot, in the range [0, width]</param>
-        /// <param name="hoty">The y-coordinate of the cursor hotspot, in the range [0, height]</param>
-        /// <param name="width">The width of the cursor data, in pixels.</param>
-        /// <param name="height">The height of the cursor data, in pixels.</param>
-        /// <param name="data">
-        /// A byte array representing the cursor image,
-        /// laid out as a contiguous array of BGRA pixels.
-        /// </param>
-        public MouseCursor(int hotx, int hoty, int width, int height, byte[] data)
-            : base(width, height, data)
-        {
-            if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height)
-                throw new ArgumentOutOfRangeException();
-
-            x = hotx;
-            y = hoty;
-        }
-
-        /// <summary>
-        /// Initializes a new <see cref="MouseCursor"/> instance from a
-        /// contiguous array of BGRA pixels.
-        /// Each pixel is composed of 4 bytes, representing B, G, R and A values,
-        /// respectively. For correct antialiasing of translucent cursors,
-        /// the B, G and R components should be premultiplied with the A component:
-        /// <code>
-        /// B = (byte)((B * A) / 255)
-        /// G = (byte)((G * A) / 255)
-        /// R = (byte)((R * A) / 255)
-        /// </code>
-        /// </summary>
-        /// <param name="hotx">The x-coordinate of the cursor hotspot, in the range [0, width]</param>
-        /// <param name="hoty">The y-coordinate of the cursor hotspot, in the range [0, height]</param>
-        /// <param name="width">The width of the cursor data, in pixels.</param>
-        /// <param name="height">The height of the cursor data, in pixels.</param>
-        /// <param name="data">
-        /// A pointer to the cursor image, laid out as a contiguous array of BGRA pixels.
-        /// </param>
-        public MouseCursor(int hotx, int hoty, int width, int height, IntPtr data)
-            : base(width, height, data)
-        {
-            if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height)
-                throw new ArgumentOutOfRangeException();
-
-            x = hotx;
-            y = hoty;
-        }
-
-        internal int X { get { return x; } }
-        internal int Y { get { return y; } }
-
-        /// <summary>
-        /// Gets the default mouse cursor for this platform.
-        /// </summary>
-        public static MouseCursor Default
-        {
-            get
-            {
-                return default_cursor;
-            }
-        }
-
-        /// <summary>
-        /// Gets an empty (invisible) mouse cursor.
-        /// </summary>
-        public static MouseCursor Empty
-        {
-            get
-            {
-                return empty_cursor;
-            }
-        }
-    }
-}
-
diff --git a/testDrm/src/WindowIcon.cs b/testDrm/src/WindowIcon.cs
deleted file mode 100644 (file)
index 53d2d1f..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#region License
-//
-// WindowIcon.cs
-//
-// Author:
-//       Stefanos A. <stapostol@gmail.com>
-//
-// Copyright (c) 2006-2014 Stefanos Apostolopoulos
-//
-// 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.
-//
-#endregion
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace OpenTK
-{
-    /// <summary>
-    /// Stores a window icon. A window icon is defined
-    /// as a 2-dimensional buffer of RGBA values.
-    /// </summary>
-    public class WindowIcon
-    {
-        byte[] data;
-        int width;
-        int height;
-
-        /// \internal
-        /// <summary>
-        /// Initializes a new instance of the <see cref="OpenTK.WindowIcon"/> class.
-        /// </summary>
-        internal protected WindowIcon()
-        {
-        }
-
-        WindowIcon(int width, int height)
-        {
-            if (width < 0 || width > 256 || height < 0 || height > 256)
-                throw new ArgumentOutOfRangeException();
-
-            this.width = width;
-            this.height = height;
-        }
-
-        internal WindowIcon(int width, int height, byte[] data)
-            : this(width, height)
-        {
-            if (data == null)
-                throw new ArgumentNullException();
-            if (data.Length < Width * Height * 4)
-                throw new ArgumentOutOfRangeException();
-
-            this.data = data;
-        }
-
-        internal WindowIcon(int width, int height, IntPtr data)
-            : this(width, height)
-        {
-            if (data == IntPtr.Zero)
-                throw new ArgumentNullException();
-
-            // We assume that width and height are correctly set.
-            // If they are not, we will read garbage and probably
-            // crash.
-            this.data = new byte[width * height * 4];
-            Marshal.Copy(data, this.data, 0, this.data.Length);
-        }
-
-        internal byte[] Data { get { return data; } }
-        internal int Width { get { return width; } }
-        internal int Height { get { return height; } }
-    }
-}
-
index 9a8d42918921670a5d4e8e3392fb7e30a37a6168..27db51e6d9dc4277933fc8e0eb3894e5f21afaea 100644 (file)
         <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
       </CustomCommands>
     </CustomCommands>
-    <StartupObject>testDrm.TestApp</StartupObject>
+    <StartupObject>testDrm.TestCrow</StartupObject>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <DefineConstants>DEBUG;MEASURE_TIME;</DefineConstants>
+    <DefineConstants>DEBUG;</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -37,7 +37,7 @@
         <Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" pauseExternalConsole="True" />
       </CustomCommands>
     </CustomCommands>
-    <ConsolePause>false</ConsolePause>
+    <Externalconsole>true</Externalconsole>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>full</DebugType>
     <Compile Include="src\Linux\Bindings\LibInput.cs" />
     <Compile Include="src\Linux\Bindings\Poll.cs" />
     <Compile Include="src\Linux\Bindings\Udev.cs" />
-    <Compile Include="src\BlittableValueType.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\DisplayResolution.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\MouseCursor.cs" />
-    <Compile Include="src\WindowIcon.cs" />
     <Compile Include="src\Linux\Signal.cs" />
     <Compile Include="src\Application.cs" />
     <Compile Include="Main.cs" />
@@ -75,6 +67,7 @@
     <Compile Include="src\Linux\DRIControler.cs" />
     <Compile Include="testCairo.cs" />
     <Compile Include="TestCrow.cs" />
+    <Compile Include="Showcase.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </EmbeddedResource>
     <EmbeddedResource Include="ui\go.crow" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="src\DRMContext.cs" />
+    <EmbeddedResource Include="ui\showcase.crow" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 57c9720248f9ed4cb0a61e8cf6010428e32878d6..efeac6536ef7ffbf3c408ec0c62419c05689b547 100755 (executable)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
-<Window Focusable="true" Caption="Measures" Width="200" Height="360" MinimumSize="100,100" Background="0.2,0.2,0.2,0.2" CornerRadius="10">
+<Window AlwaysOnTop="true" Focusable="true" Caption="Measures" Width="200" Height="360" MinimumSize="100,100" Background="0.2,0.2,0.2,0.2" CornerRadius="10">
        <ListBox Data="{PerfMeasures}" Fit="true" ItemTemplate="#ui.perfMsr.crow" Background="Transparent"/>
 </Window>
diff --git a/testDrm/ui/showcase.crow b/testDrm/ui/showcase.crow
new file mode 100755 (executable)
index 0000000..bf3ea8a
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<Window Width="50%" Height="50%">
+       <VerticalStack>
+               <Menu>
+                       <MenuItem Caption="File" Width="Fit">
+                               <MenuItem Caption="New"/>
+                               <MenuItem Command="{CMDOpen}"/>
+                               <MenuItem Caption="Save"/>
+                               <MenuItem Caption="Quit" MouseClick="onQuitClick"/>
+                       </MenuItem>
+                       <MenuItem Caption="View" Width="Fit">
+                               <MenuItem Command="{CMDViewPerf}"/>
+                               <MenuItem Command="{CMDViewCfg}"/>
+                               <MenuItem Command="{CMDViewTest0}"/>
+                       </MenuItem>
+                       <MenuItem Caption="Edit" Name="edit" Width="Fit">
+                               <MenuItem Caption="Cut"/>
+                               <MenuItem Caption="Copy"/>
+                               <MenuItem Caption="Paste"/>
+                               <MenuItem Caption="Special" Name="special" Width="Fit">
+                                       <MenuItem Caption="Cut"/>
+                                       <MenuItem Caption="Copy"/>
+                                       <MenuItem Caption="Paste"/>
+                               </MenuItem>
+                               <MenuItem Caption="Special2" Name="special" Width="Fit">
+                                       <MenuItem Caption="Cut"/>
+                                       <MenuItem Caption="Copy"/>
+                                       <MenuItem Caption="Paste"/>
+                               </MenuItem>
+                       </MenuItem>
+                       <MenuItem Caption="Help" Width="Fit">
+                               <MenuItem Caption="About"/>
+                               <MenuItem Caption="Help"/>
+                       </MenuItem>
+               </Menu>
+               <HorizontalStack Background="Onyx" Margin="5">
+                       <DirectoryView Name="dv" CurrentDirectory="Interfaces" Width="25%" SelectedItemChanged="Dv_SelectedItemChanged"
+                               />
+                       <Splitter Width="6"/>
+                       <VerticalStack>
+                               <Container Name="CrowContainer" Height="60%" Background="SmokyBlack"/>
+                               <Splitter/>
+                               <HorizontalStack>
+                                       <Scroller Name="scroller1" Background="White"
+                                                       Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+                                                       ValueChanged="./_scroller_ValueChanged">
+                                               <TextBox VerticalAlignment="Top" TextChanged="Tb_TextChanged"
+                                                       Text="{source}" Multiline="true" TextAlignment="TopLeft"
+                                                       Font="Courriernew 10"/>
+                                       </Scroller>
+                                       <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+                                               Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+                                               Width="14" />
+                               </HorizontalStack>
+                       </VerticalStack>
+               </HorizontalStack>
+       </VerticalStack>
+</Window>
\ No newline at end of file