From aba85d479c1b3652d057b69296b315b80cdb70f6 Mon Sep 17 00:00:00 2001 From: Vlad K Date: Mon, 19 Jun 2017 00:19:11 +0300 Subject: [PATCH] Some docs --- src/OpenTK/Platform/Windows/WinGLNative.cs | 5 ++--- src/OpenTK/Platform/X11/API.cs | 7 +++++-- src/OpenTK/Platform/X11/X11GLNative.cs | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/OpenTK/Platform/Windows/WinGLNative.cs b/src/OpenTK/Platform/Windows/WinGLNative.cs index b63a9210..d068428c 100644 --- a/src/OpenTK/Platform/Windows/WinGLNative.cs +++ b/src/OpenTK/Platform/Windows/WinGLNative.cs @@ -693,9 +693,8 @@ namespace OpenTK.Platform.Windows IntPtr str = Marshal.AllocHGlobal((int)fileNameSize); Functions.DragQueryFile(hDrop, i, str, fileNameSize); - - Marshal.Copy(str, byteArray, 0, (int)(fileNameSize - 1)); - string dropString = System.Text.Encoding.UTF8.GetString(byteArray); + + string dropString = Marshal.PtrToStringAuto(str); OnFileDrop(dropString); Marshal.FreeHGlobal(str); diff --git a/src/OpenTK/Platform/X11/API.cs b/src/OpenTK/Platform/X11/API.cs index 8274dc7a..1f3d3d44 100644 --- a/src/OpenTK/Platform/X11/API.cs +++ b/src/OpenTK/Platform/X11/API.cs @@ -53,10 +53,13 @@ namespace OpenTK.Platform.X11 #endregion // X11 has some defined values + // Whis values are defined with c's #define in X.h internal static class Consts { - public static readonly IntPtr None = IntPtr.Zero; - public static readonly IntPtr CurrentTime = IntPtr.Zero; + // Universal null resource or null atom + public static readonly IntPtr None = IntPtr.Zero; // #define None 0L + // Special time value + public static readonly IntPtr CurrentTime = IntPtr.Zero; // #define CurrentTime 0L } #region internal static class API diff --git a/src/OpenTK/Platform/X11/X11GLNative.cs b/src/OpenTK/Platform/X11/X11GLNative.cs index 3926f4b6..4217b30b 100644 --- a/src/OpenTK/Platform/X11/X11GLNative.cs +++ b/src/OpenTK/Platform/X11/X11GLNative.cs @@ -861,7 +861,6 @@ namespace OpenTK.Platform.X11 // Process all pending events while (Exists && window != null) { - //Functions.XNextEvent(window.Display, ref e); using (new XLock(window.Display)) { if (!Functions.XCheckWindowEvent(window.Display, window.Handle, window.EventMask, ref e) && @@ -910,9 +909,13 @@ namespace OpenTK.Platform.X11 break; } } + // For X11 drag and drop handling use https://freedesktop.org/wiki/Specifications/XDND/#index9h2 else if (e.ClientMessageEvent.message_type == _atom_xdnd_enter) { // Xdnd started + // ptr1 -> source window handler + // ptr2 bit 0 -> set to 1 if source support more than three data formats + // ptr2 third byte contains Xdnd version that source supports bool useList = ((e.ClientMessageEvent.ptr2.ToInt64() & 1) == 1); sourceHandler = e.ClientMessageEvent.ptr1; sourceXdndVersion = e.ClientMessageEvent.ptr2.ToInt64() >> 24; @@ -927,7 +930,6 @@ namespace OpenTK.Platform.X11 } else { - // Bad code it will save only 1 format formats = Marshal.AllocHGlobal(3 * IntPtr.Size); Marshal.WriteIntPtr(formats, e.ClientMessageEvent.ptr3); Marshal.WriteIntPtr(formats, IntPtr.Size * 2, e.ClientMessageEvent.ptr4);