SDL_WINDOW_MOUSE_FOCUS broken in 2.0.14 on iOS

I’d like to report an issue I am having with SDL 2.0.14 that did not cause me problems in SDL 2.0.12.

In UIKit_ShowWindow(), SDL_SetMouseFocus() is called. The window flags are updated with SDL_WINDOW_MOUSE_FOCUS.

Afterward, due to a call to SDL_CreateRenderer(), SDL_RecreateWindow() is called. The window->flags are overridden with the new ones, ignoring the fact that SDL_WINDOW_MOUSE_FOCUS was previously set. This would be okay, except that due to the new window being created an upcoming call to SDL_SetMouseFocus() from UIKit_ShowWindow() improperly early aborts, because it thinks the mouse focus is already set for the window.

Later on in my code, I test SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS. This now fails.

A possible fix for this is some additional code in SDL_RecreateWindow():

    /* Restore video mode, etc. */
    SDL_HideWindow(window);

    if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
        SDL_SetMouseFocus(NULL);
    }

    if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
        SDL_SetKeyboardFocus(NULL);
    }
 
    /* Tear down the old native window */
    if (window->surface) {

Thoughts?

2 Likes

Can you please report this as a bug in bugzilla.libsdl.org, for tracking?

Thanks!