From b4321a949f473a5877e0084c6845704a924f07a4 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 4 Oct 2023 09:19:29 -0700 Subject: Fix resize hang. --- Demos/Pong/Main.hs | 1 - Spear/Window.hs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Demos/Pong/Main.hs b/Demos/Pong/Main.hs index 0237a26..26ceefa 100644 --- a/Demos/Pong/Main.hs +++ b/Demos/Pong/Main.hs @@ -98,7 +98,6 @@ renderGO go = do ,vec2 xmax ymax ,vec2 xmin ymax)] --- TODO: Fix the resize hang. resize :: WindowEvent -> Game GameState () resize (ResizeEvent w h) = let r = fromIntegral w / fromIntegral h diff --git a/Spear/Window.hs b/Spear/Window.hs index 3cdc5f5..aafcb59 100644 --- a/Spear/Window.hs +++ b/Spear/Window.hs @@ -178,7 +178,7 @@ onWindowClose closeRequest window = putMVar closeRequest True -- the last in a poll can be ignored, we just replace the contents of the mvar -- here instead of adding the event to the list. onResize :: MVar [WindowEvent] -> GLFW.WindowSizeCallback -onResize windowEvents window w h = putMVar windowEvents [ResizeEvent w h] +onResize windowEvents window w h = modifyMVar_ windowEvents (return <$> const [ResizeEvent w h]) onKey :: MVar [InputEvent] -> GLFW.KeyCallback onKey events window key _ GLFW.KeyState'Pressed _ = addEvent events $ KeyDown (fromGLFWkey key) -- cgit v1.2.3