Skip to content
This repository
Browse code

[SDL2] Implemented GetWindowWMInfo

  • Loading branch information...
commit aff97198726d225e31122807ecd154a4c7045e54 1 parent bdfcf43
thefiddler authored

Showing 1 changed file with 98 additions and 1 deletion. Show diff stats Hide diff stats

  1. +98 1 Source/OpenTK/Platform/SDL2/Sdl2.cs
99 Source/OpenTK/Platform/SDL2/Sdl2.cs
@@ -94,7 +94,6 @@ static string IntPtrToString(IntPtr ptr)
94 94 [SuppressUnmanagedCodeSecurity]
95 95 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateWindow", ExactSpelling = true)]
96 96 public static extern IntPtr CreateWindow(string title, int x, int y, int w, int h, WindowFlags flags);
97   - //public static extern IntPtr SDL_CreateWindow(string title, int x, int y, int w, int h, WindowFlags flags);
98 97
99 98 [SuppressUnmanagedCodeSecurity]
100 99 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_CreateWindowFrom", ExactSpelling = true)]
@@ -420,6 +419,34 @@ public static string JoystickName(IntPtr joystick)
420 419 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WarpMouseInWindow", ExactSpelling = true)]
421 420 public static extern void WarpMouseInWindow(IntPtr window, int x, int y);
422 421
  422 + #region SysWM
  423 +
  424 + /// <summary>
  425 + /// Retrieves driver-dependent window information.
  426 + /// </summary>
  427 + /// <param name="window">
  428 + /// The window about which information is being requested.
  429 + /// </param>
  430 + /// <param name="info">
  431 + /// Returns driver-dependent information about the specified window.
  432 + /// </param>
  433 + /// <returns>
  434 + /// True, if the function is implemented and the version number of the info struct is valid;
  435 + /// false, otherwise.
  436 + /// </returns>
  437 + public static bool GetWindowWMInfo(IntPtr window, out SysWMInfo info)
  438 + {
  439 + info = new SysWMInfo();
  440 + info.Version = GetVersion();
  441 + return GetWindowWMInfoInternal(window, ref info);
  442 + }
  443 +
  444 + [SuppressUnmanagedCodeSecurity]
  445 + [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetWindowWMInfo", ExactSpelling = true)]
  446 + static extern bool GetWindowWMInfoInternal(IntPtr window, ref SysWMInfo info);
  447 +
  448 + #endregion
  449 +
423 450 public partial class GL
424 451 {
425 452 [SuppressUnmanagedCodeSecurity]
@@ -1200,6 +1227,17 @@ enum SystemFlags : uint
1200 1227 JOYSTICK | HAPTIC | GAMECONTROLLER
1201 1228 }
1202 1229
  1230 + enum SysWMType
  1231 + {
  1232 + Unknown = 0,
  1233 + Windows,
  1234 + X11,
  1235 + Wayland,
  1236 + DirectFB,
  1237 + Cocoa,
  1238 + UIKit,
  1239 + }
  1240 +
1203 1241 enum WindowEventID : byte
1204 1242 {
1205 1243 NONE,
@@ -1517,6 +1555,65 @@ struct Rect
1517 1555 public int Height;
1518 1556 }
1519 1557
  1558 + struct SysWMInfo
  1559 + {
  1560 + public Version Version;
  1561 + public SysWMType Subsystem;
  1562 + public SysInfo Info;
  1563 +
  1564 + [StructLayout(LayoutKind.Explicit)]
  1565 + public struct SysInfo
  1566 + {
  1567 + [FieldOffset(0)]
  1568 + public WindowsInfo Windows;
  1569 + [FieldOffset(0)]
  1570 + public X11Info X11;
  1571 + [FieldOffset(0)]
  1572 + public WaylandInfo Wayland;
  1573 + [FieldOffset(0)]
  1574 + public DirectFBInfo DirectFB;
  1575 + [FieldOffset(0)]
  1576 + public CocoaInfo Cocoa;
  1577 + [FieldOffset(0)]
  1578 + public UIKitInfo UIKit;
  1579 +
  1580 + public struct WindowsInfo
  1581 + {
  1582 + public IntPtr Window;
  1583 + }
  1584 +
  1585 + public struct X11Info
  1586 + {
  1587 + public IntPtr Display;
  1588 + public IntPtr Window;
  1589 + }
  1590 +
  1591 + public struct WaylandInfo
  1592 + {
  1593 + public IntPtr Display;
  1594 + public IntPtr Surface;
  1595 + public IntPtr ShellSurface;
  1596 + }
  1597 +
  1598 + public struct DirectFBInfo
  1599 + {
  1600 + public IntPtr Dfb;
  1601 + public IntPtr Window;
  1602 + public IntPtr Surface;
  1603 + }
  1604 +
  1605 + public struct CocoaInfo
  1606 + {
  1607 + public IntPtr Window;
  1608 + }
  1609 +
  1610 + public struct UIKitInfo
  1611 + {
  1612 + public IntPtr Window;
  1613 + }
  1614 + }
  1615 + }
  1616 +
1520 1617 struct TextEditingEvent
1521 1618 {
1522 1619 public const int TextSize = 32;

0 comments on commit aff9719

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