Skip to content

[rcore] [web] Fix an oversight on MaximizeWindow() for PLATFORM_WEB#4404

Merged
raysan5 merged 1 commit intomasterfrom
unknown repository
Oct 21, 2024
Merged

[rcore] [web] Fix an oversight on MaximizeWindow() for PLATFORM_WEB#4404
raysan5 merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 21, 2024

Sorry, there was an oversight on my part when commiting #4402.

If the user SetWindowState(FLAG_WINDOW_MAXIMIZED) then MaximizeWindow(), the platform.unmaximizedWidth/Height will be overridden and ClearWindowState(FLAG_WINDOW_MAXIMIZED) or RestoreWindow() won't be able to restore the canvas ("window") to the unmaximized size. This can be fixed with additional flag checks.

The fix can be tested with:

// Note: usage of `minshell.html` is recommended since it won't force canvas CSS overrides

#include "raylib.h"
int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);

    SetWindowState(FLAG_WINDOW_RESIZABLE);

    while (!WindowShouldClose()) {

        // Press 1, 2, 3 or 1, 2, 4:

        if (IsKeyPressed(KEY_ONE)) SetWindowState(FLAG_WINDOW_MAXIMIZED);
        if (IsKeyPressed(KEY_TWO)) MaximizeWindow();
        if (IsKeyPressed(KEY_THREE)) ClearWindowState(FLAG_WINDOW_MAXIMIZED);
        if (IsKeyPressed(KEY_FOUR)) RestoreWindow();

        BeginDrawing();
        ClearBackground(RAYWHITE);
        DrawText("test", 20, 20, 20, BLACK);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

@raysan5 raysan5 merged commit cb21fe8 into raysan5:master Oct 21, 2024
@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Oct 21, 2024

@asdqwe thanks for the review!

@ghost ghost deleted the fix-maximizewindow-web branch October 21, 2024 11:58
psxdev pushed a commit to raylib4Consoles/raylib that referenced this pull request Nov 18, 2024
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