ikskuh/SDL.zig

getWMInfo always fails on Windows - SDL_SysWMInfo is not properly initialized

Opened this issue · 1 comments

In the SDL wiki SDL_GetWindowWMInfo it is specified that:

The caller must initialize the info structure's version by using SDL_VERSION(&info.version), and then this function will fill in the rest of the structure with information about the given window.

Also the return value of SDL_GetWindowWMInfo() to check against should be SDL_TRUE which is defined as 1, but the code tests against 0. The following changes are necessary:

    pub fn getWMInfo(w: Window) !c.SDL_SysWMInfo {
        var info: c.SDL_SysWMInfo = undefined;
        info.version = c.SDL_VERSION;
        if (c.SDL_GetWindowWMInfo(w.ptr, &info) != c.SDL_TRUE) {
            return makeError();
        }
        return info;
    }

Can you make a pull request with this?