Skip to content

Conversation

@Grey41
Copy link

@Grey41 Grey41 commented Dec 21, 2025

Description

In the old code, we tried to detect whether the canvas size was controlled with css by setting the canvas size to 1, then using emscripten_set_element_css_size to see if anything changed.

I suggest we leave the canvas size alone, except when the SDL_WINDOW_FILL_DOCUMENT flag is set. This means the canvas doesn't unexpectedly mutate (or its css). Also, on destroy, it's best just to clean up and not to mutate the canvas.

Finally, when SDL_WINDOW_HIGH_PIXEL_DENSITY exists, work backwards from the canvas size. For example:

window.width = canvas.width / pixelRatio
window.height = canvas.height / pixelRatio

This is intuitive because the canvas is setting the precedent for the window size, instead of SDL trying to guess by peering into the css.

@slouken slouken requested a review from icculus December 21, 2025 19:52
@slouken slouken added this to the 3.4.0 milestone Dec 21, 2025
@slouken
Copy link
Collaborator

slouken commented Dec 21, 2025

Conceptually this seems like a good idea. @icculus?

@icculus
Copy link
Collaborator

icculus commented Dec 21, 2025

Not against it, but I'm real nervous to apply this right before 3.4.0 ships.

@slouken slouken modified the milestones: 3.4.0, 3.4.2 Dec 21, 2025
@slouken
Copy link
Collaborator

slouken commented Dec 21, 2025

I'll bump this to the 3.4.2 milestone so it can get some more testing.

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.

3 participants