ikskuh / SDL.zig

A shallow wrapper around SDL that provides object API and error handling
MIT License
348 stars 75 forks source link

getWMInfo always fails on Windows - SDL_SysWMInfo is not properly initialized #186

Open adihodos opened 2 months ago

adihodos commented 2 months ago

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 beSDL_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;
    }
ikskuh commented 2 months ago

Can you make a pull request with this?