From 2724018232b923005e733709ad7c84b2c635aa9c Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 17 Jul 2026 04:27:27 -0400 Subject: [PATCH 1/4] fix sleep --- src/desktop/backends/glfw2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop/backends/glfw2.c b/src/desktop/backends/glfw2.c index b97b41764..534b16b77 100644 --- a/src/desktop/backends/glfw2.c +++ b/src/desktop/backends/glfw2.c @@ -291,7 +291,7 @@ bool platformHandleEvents(void) { } void platformSleepUntil(uint64_t time) { - double remaining = ((int64_t)time - nowNanos()) / 1000000000.0; + double remaining = ((int64_t)time - (int64_t)nowNanos()) / 1000000000.0; if (remaining > 0.002) // glfwSleep takes seconds as a double glfwSleep(remaining - 0.001); From 60c2436246399f0b557240ab29a6a5d35ad885ba Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 17 Jul 2026 04:27:30 -0400 Subject: [PATCH 2/4] fix alt+f4 --- src/desktop/backends/sdl1.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/desktop/backends/sdl1.c b/src/desktop/backends/sdl1.c index ad9beba10..c416ab16b 100644 --- a/src/desktop/backends/sdl1.c +++ b/src/desktop/backends/sdl1.c @@ -540,6 +540,10 @@ bool platformHandleEvents(void) { } break; case SDL_KEYDOWN: + // SDL1.2 needs to manually intercept Alt+F4 to exit properly + if (e.key.keysym.sym == SDLK_F4 && (e.key.keysym.mod & KMOD_ALT)) { + return true; + } // During playback, suppress real keyboard input if (InputRecording_isPlaybackActive(globalInputRecording)) break; RunnerKeyboard_onKeyDown(g_runner->keyboard, SDLKeyToGml(e.key.keysym.sym)); From dfb9c7a920dddbf06518c7703051a213c976c626 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 17 Jul 2026 04:27:37 -0400 Subject: [PATCH 3/4] better platformGetWindowScale --- src/desktop/backends/sdl2.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/desktop/backends/sdl2.c b/src/desktop/backends/sdl2.c index c677ffd8d..e4549db1b 100644 --- a/src/desktop/backends/sdl2.c +++ b/src/desktop/backends/sdl2.c @@ -129,22 +129,20 @@ bool platformGetScaledWindowSize(int32_t* outW, int32_t* outH) { return true; } -static void platformGetWindowScale(float *scale_x, float *scale_y) { +static float platformGetWindowScale(void) { if (!scale_x || !scale_y) return; int32_t draw_w, draw_h; int logical_w, logical_h; platformGetWindowSize(&draw_w, &draw_h); SDL_GetWindowSize(window, &logical_w, &logical_h); - *scale_x = (logical_w > 0) ? (float)draw_w / logical_w : 1.0f; - *scale_y = (logical_h > 0) ? (float)draw_h / logical_h : 1.0f; + return (logical_h > 0) ? (float)draw_h / logical_h : 1.0f; } void platformSetWindowSize(int32_t width, int32_t height) { if (width <= 0 || height <= 0) return; - float scale_x, scale_y; - platformGetWindowScale(&scale_x, &scale_y); - SDL_SetWindowSize(window, (int)(width / scale_x), (int)(height / scale_y)); + float scale = platformGetWindowScale(); + SDL_SetWindowSize(window, (int)(width / scale), (int)(height / scale)); if (gfx == SOFTWARE) scr = SDL_GetWindowSurface(window); @@ -154,10 +152,9 @@ void platformGetMousePos(double *xPos, double *yPos) { if (!xPos || !yPos) return; int mx = 0, my = 0; SDL_GetMouseState(&mx, &my); - float scale_x, scale_y; - platformGetWindowScale(&scale_x, &scale_y); - *xPos = (double)mx * scale_x; - *yPos = (double)my * scale_y; + float scale = platformGetWindowScale(); + *xPos = (double)mx * scale; + *yPos = (double)my * scale; } static bool platformGetWindowFocus(void) { From 94a3ffea5c24e8e312277240923fd968a414282c Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 17 Jul 2026 22:06:42 -0400 Subject: [PATCH 4/4] glfw2 mouse fix --- src/desktop/backends/glfw2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/desktop/backends/glfw2.c b/src/desktop/backends/glfw2.c index 534b16b77..8debf98dc 100644 --- a/src/desktop/backends/glfw2.c +++ b/src/desktop/backends/glfw2.c @@ -224,9 +224,19 @@ void platformExit(void) { static void platformSetCursor(int32_t cursorType) { // GLFW2 only supports showing/hiding if (cursorType == GML_CR_NONE) { + // GLFW2's mouse cursor locks the mouse position when it's invisible on Windows. + // This just makes it visible/invisible as intended. +#ifdef _WIN32 + while (ShowCursor(FALSE) >= 0); +#else glfwDisable(GLFW_MOUSE_CURSOR); +#endif } else { +#ifdef _WIN32 + while (ShowCursor(TRUE) < 0); +#else glfwEnable(GLFW_MOUSE_CURSOR); +#endif } }