From aff97198726d225e31122807ecd154a4c7045e54 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Fri, 10 Jan 2014 16:55:20 +0100 Subject: [PATCH] [SDL2] Implemented GetWindowWMInfo --- Source/OpenTK/Platform/SDL2/Sdl2.cs | 99 ++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2.cs b/Source/OpenTK/Platform/SDL2/Sdl2.cs index 5dc31dd9..d38039be 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2.cs @@ -94,7 +94,6 @@ namespace OpenTK.Platform.SDL2 [SuppressUnmanagedCodeSecurity] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateWindow", ExactSpelling = true)] public static extern IntPtr CreateWindow(string title, int x, int y, int w, int h, WindowFlags flags); - //public static extern IntPtr SDL_CreateWindow(string title, int x, int y, int w, int h, WindowFlags flags); [SuppressUnmanagedCodeSecurity] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateWindowFrom", ExactSpelling = true)] @@ -420,6 +419,34 @@ namespace OpenTK.Platform.SDL2 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WarpMouseInWindow", ExactSpelling = true)] public static extern void WarpMouseInWindow(IntPtr window, int x, int y); + #region SysWM + + /// + /// Retrieves driver-dependent window information. + /// + /// + /// The window about which information is being requested. + /// + /// + /// Returns driver-dependent information about the specified window. + /// + /// + /// True, if the function is implemented and the version number of the info struct is valid; + /// false, otherwise. + /// + public static bool GetWindowWMInfo(IntPtr window, out SysWMInfo info) + { + info = new SysWMInfo(); + info.Version = GetVersion(); + return GetWindowWMInfoInternal(window, ref info); + } + + [SuppressUnmanagedCodeSecurity] + [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetWindowWMInfo", ExactSpelling = true)] + static extern bool GetWindowWMInfoInternal(IntPtr window, ref SysWMInfo info); + + #endregion + public partial class GL { [SuppressUnmanagedCodeSecurity] @@ -1200,6 +1227,17 @@ namespace OpenTK.Platform.SDL2 JOYSTICK | HAPTIC | GAMECONTROLLER } + enum SysWMType + { + Unknown = 0, + Windows, + X11, + Wayland, + DirectFB, + Cocoa, + UIKit, + } + enum WindowEventID : byte { NONE, @@ -1517,6 +1555,65 @@ namespace OpenTK.Platform.SDL2 public int Height; } + struct SysWMInfo + { + public Version Version; + public SysWMType Subsystem; + public SysInfo Info; + + [StructLayout(LayoutKind.Explicit)] + public struct SysInfo + { + [FieldOffset(0)] + public WindowsInfo Windows; + [FieldOffset(0)] + public X11Info X11; + [FieldOffset(0)] + public WaylandInfo Wayland; + [FieldOffset(0)] + public DirectFBInfo DirectFB; + [FieldOffset(0)] + public CocoaInfo Cocoa; + [FieldOffset(0)] + public UIKitInfo UIKit; + + public struct WindowsInfo + { + public IntPtr Window; + } + + public struct X11Info + { + public IntPtr Display; + public IntPtr Window; + } + + public struct WaylandInfo + { + public IntPtr Display; + public IntPtr Surface; + public IntPtr ShellSurface; + } + + public struct DirectFBInfo + { + public IntPtr Dfb; + public IntPtr Window; + public IntPtr Surface; + } + + public struct CocoaInfo + { + public IntPtr Window; + } + + public struct UIKitInfo + { + public IntPtr Window; + } + } + } + struct TextEditingEvent { public const int TextSize = 32;