File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -746,11 +746,18 @@ convertRaw (Raw.UnknownEvent t ts) =
746746
747747-- | Poll for currently pending events. You can only call this function in the thread that set the video mode.
748748pollEvent :: MonadIO m => m (Maybe Event )
749- pollEvent = liftIO $ alloca $ \ e -> do
750- n <- Raw. pollEvent e
751- if n == 0
752- then return Nothing
753- else fmap Just (peek e >>= convertRaw)
749+ pollEvent =
750+ liftIO $ do
751+ n <- Raw. pollEvent nullPtr
752+ -- We use NULL first to check if there's an event.
753+ if n == 0
754+ then return Nothing
755+ else alloca $ \ e -> do
756+ n <- Raw. pollEvent e
757+ -- Checking 0 again doesn't hurt and it's good to be safe.
758+ if n == 0
759+ then return Nothing
760+ else fmap Just (peek e >>= convertRaw)
754761
755762-- | Clear the event queue by polling for all pending events.
756763pollEvents :: (Functor m , MonadIO m ) => m [Event ]
You can’t perform that action at this time.
0 commit comments