Correctly initialize SDL_SysWMinfo structures.

This is apparently something I forgot. The X11 driver seems less forgiving than the Win32 or Cocoa drivers.
This commit is contained in:
Pieter-Jan Briers
2023-02-12 02:42:51 +01:00
parent 72b5735349
commit 024b6ef16d
2 changed files with 8 additions and 0 deletions

View File

@@ -138,6 +138,7 @@ internal partial class Clyde
// Clear owner on close to avoid this.
SDL_SysWMinfo wmInfo = default;
SDL_VERSION(out wmInfo.version);
if (SDL_GetWindowWMInfo(cmd.Window, ref wmInfo) == SDL_TRUE && wmInfo.subsystem == SDL_SYSWM_WINDOWS)
{
var hWnd = (HWND)wmInfo.info.win.window;
@@ -245,6 +246,7 @@ internal partial class Clyde
if (OperatingSystem.IsWindows())
{
SDL_SysWMinfo info = default;
SDL_VERSION(out info.version);
if (SDL_GetWindowWMInfo(window, ref info) == SDL_TRUE && info.subsystem == SDL_SYSWM_WINDOWS)
WsiShared.WindowsSharedWindowCreate((HWND) info.info.win.window, _cfg);
}
@@ -267,6 +269,7 @@ internal partial class Clyde
var handle = new WindowHandle(_clyde, reg);
reg.Handle = handle;
SDL_VERSION(out reg.SysWMinfo.version);
var res = SDL_GetWindowWMInfo(window, ref reg.SysWMinfo);
if (res == SDL_FALSE)
_sawmill.Error("Failed to get window WM info: {error}", SDL_GetError());

View File

@@ -160,6 +160,11 @@ internal partial class Clyde
};
var msg = Marshal.PtrToStringUTF8((IntPtr) message) ?? "";
if (msg == "That operation is not supported")
{
obj._sawmillSdl2.Info(Environment.StackTrace);
}
var categoryName = SdlLogCategoryName(category);
obj._sawmillSdl2.Log(level, $"[{categoryName}] {msg}");
}