From 3a909c3ed97a8ee5127aad0de89c0d2159e6a44b Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:23:36 -0300 Subject: [PATCH] Reapply commit 9d230d7 (#3305) that was missing --- src/rcore_web.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rcore_web.c b/src/rcore_web.c index 1c117f45b..736584592 100644 --- a/src/rcore_web.c +++ b/src/rcore_web.c @@ -159,9 +159,9 @@ void InitWindow(int width, int height, const char *title) // Check fullscreen change events(note this is done on the window since most browsers don't support this on #canvas) // emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); // Check Resize event (note this is done on the window since most browsers don't support this on #canvas) - // emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); // Trigger this once to get initial window sizing - // EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL); + EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL); // Support keyboard events -> Not used, GLFW.JS takes care of that // emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback); @@ -202,8 +202,8 @@ static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUi return 1; // The event was consumed by the callback handler } -EM_JS(int, GetCanvasWidth, (), { return canvas.clientWidth; }); -EM_JS(int, GetCanvasHeight, (), { return canvas.clientHeight; }); +EM_JS(int, GetWindowInnerWidth, (), { return window.innerWidth; }); +EM_JS(int, GetWindowInnerHeight, (), { return window.innerHeight; }); // Register DOM element resize event static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData) @@ -213,8 +213,8 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent * // This event is called whenever the window changes sizes, // so the size of the canvas object is explicitly retrieved below - int width = GetCanvasWidth(); - int height = GetCanvasHeight(); + int width = GetWindowInnerWidth(); + int height = GetWindowInnerHeight(); emscripten_set_canvas_element_size("#canvas", width, height); SetupViewport(width, height); // Reset viewport and projection matrix for new size