Skip to content
Browse files

[SDL2] Implemented GetWindowWMInfo

  • Loading branch information...
1 parent bdfcf43 commit aff97198726d225e31122807ecd154a4c7045e54 @thefiddler thefiddler committed Jan 10, 2014
Showing with 98 additions and 1 deletion.
  1. +98 −1 Source/OpenTK/Platform/SDL2/Sdl2.cs
View
99 Source/OpenTK/Platform/SDL2/Sdl2.cs
@@ -94,7 +94,6 @@ static string IntPtrToString(IntPtr ptr)
[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 @@ public static string JoystickName(IntPtr joystick)
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WarpMouseInWindow", ExactSpelling = true)]
public static extern void WarpMouseInWindow(IntPtr window, int x, int y);
+ #region SysWM
+
+ /// <summary>
+ /// Retrieves driver-dependent window information.
+ /// </summary>
+ /// <param name="window">
+ /// The window about which information is being requested.
+ /// </param>
+ /// <param name="info">
+ /// Returns driver-dependent information about the specified window.
+ /// </param>
+ /// <returns>
+ /// True, if the function is implemented and the version number of the info struct is valid;
+ /// false, otherwise.
+ /// </returns>
+ 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 @@ enum SystemFlags : uint
JOYSTICK | HAPTIC | GAMECONTROLLER
}
+ enum SysWMType
+ {
+ Unknown = 0,
+ Windows,
+ X11,
+ Wayland,
+ DirectFB,
+ Cocoa,
+ UIKit,
+ }
+
enum WindowEventID : byte
{
NONE,
@@ -1517,6 +1555,65 @@ struct Rect
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;

0 comments on commit aff9719

Please sign in to comment.
Something went wrong with that request. Please try again.