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] [web] Simplify EmscriptenResizeCallback() #4415

Merged
merged 1 commit into from Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/platforms/rcore_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ void MaximizeWindow(void)
platform.unmaximizedWidth = CORE.Window.screen.width;
platform.unmaximizedHeight = CORE.Window.screen.height;

const int tabWidth = EM_ASM_INT( { return window.innerWidth; }, 0);
const int tabHeight = EM_ASM_INT( { return window.innerHeight; }, 0);
const int tabWidth = EM_ASM_INT( return window.innerWidth; );
const int tabHeight = EM_ASM_INT( return window.innerHeight; );

if (tabWidth && tabHeight) glfwSetWindowSize(platform.handle, tabWidth, tabHeight);

Expand Down Expand Up @@ -423,8 +423,8 @@ void SetWindowState(unsigned int flags)
platform.unmaximizedWidth = CORE.Window.screen.width;
platform.unmaximizedHeight = CORE.Window.screen.height;

const int tabWidth = EM_ASM_INT( { return window.innerWidth; }, 0);
const int tabHeight = EM_ASM_INT( { return window.innerHeight; }, 0);
const int tabWidth = EM_ASM_INT( return window.innerWidth; );
const int tabHeight = EM_ASM_INT( return window.innerHeight; );

if (tabWidth && tabHeight) glfwSetWindowSize(platform.handle, tabWidth, tabHeight);

Expand Down Expand Up @@ -1639,9 +1639,6 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
// return 1; // The event was consumed by the callback handler
// }

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)
{
Expand All @@ -1650,8 +1647,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 = GetWindowInnerWidth();
int height = GetWindowInnerHeight();
int width = EM_ASM_INT( return window.innerWidth; );
int height = EM_ASM_INT( return window.innerHeight; );

if (width < (int)CORE.Window.screenMin.width) width = CORE.Window.screenMin.width;
else if (width > (int)CORE.Window.screenMax.width && CORE.Window.screenMax.width > 0) width = CORE.Window.screenMax.width;
Expand Down
Loading