Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] [SDL2] Fix show, hide, focus and unfocus window/flags states #4610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asdqwe
Copy link
Contributor

@asdqwe asdqwe commented Dec 16, 2024

Fixes show, hide, focus and unfocus window/flags states on PLATFORM_DESKTOP_SDL, and IsWindowHidden() (ref) and IsWindowFocused() (ref) that were INOP on PLATFORM_DESKTOP_SDL because the platform was missing event handling for SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST (ref).

This PR was tested with SDL2.30.10 on Linux Mint 22.0. SDL3 wasn't tested but should work since these changes share the same events and the handling is agnostic.

The PR can be tested with:
#include "raylib.h"
int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);

    double interval = 2.0;

    while (!WindowShouldClose()) {

        // Show and Hide the window every two seconds:
        if (GetTime() > interval) {
            if (IsWindowHidden()) {
                ClearWindowState(FLAG_WINDOW_HIDDEN);
            } else {
                SetWindowState(FLAG_WINDOW_HIDDEN);
            }
            interval += 2.0;
        }

        TraceLog(LOG_INFO, "Hidden %i.  Focused %i.", IsWindowHidden(), IsWindowFocused());

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
     }
    CloseWindow();
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant