aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/backends/Display.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-11-21 18:48:52 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-11-21 18:48:52 +0100
commit4db409fdff013e3e4249d567e4d6fdb0ee877256 (patch)
tree3b985c0941fda237f60b2e5f9a63382327159fb9 /src/backends/Display.cs
parenta1dca1431f685020df843162b805edee11e1929c (diff)
xcb backend
Diffstat (limited to 'src/backends/Display.cs')
-rw-r--r--src/backends/Display.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/backends/Display.cs b/src/backends/Display.cs
new file mode 100644
index 00000000..05832ab1
--- /dev/null
+++ b/src/backends/Display.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace XLib
+{
+ public class Display : IDisposable
+ {
+ internal IntPtr handle;
+ internal Int32 screen;
+ IntPtr lastEvent;
+
+ public Display()
+ {
+ handle = XOpenDisplay(IntPtr.Zero);
+ if (handle == IntPtr.Zero)
+ throw new NotSupportedException("[XLib] Failed to open display.");
+
+ screen = XDefaultScreen(handle);
+ lastEvent = Marshal.AllocHGlobal(96);
+ }
+
+ /*public IntPtr NextEvent {
+ get {
+ NativeMethods.XNextEvent(handle, lastEvent);
+ return lastEvent;
+ }
+ }*/
+
+ #region IDisposable Support
+ private bool disposedValue = false; // To detect redundant calls
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposedValue)
+ {
+ if (disposing)
+ {
+ // TODO: dispose managed state (managed objects).
+ }
+
+ //Marshal.FreeHGlobal (lastEvent);
+ NativeMethods.XCloseDisplay (handle);
+
+ disposedValue = true;
+ }
+ }
+
+ // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
+ ~Display() {
+ // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
+ Dispose(false);
+ }
+
+ // This code added to correctly implement the disposable pattern.
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion
+
+
+ }
+}