Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

xhb-event-queue

This package provides a monad transformer that allows for operations on the xhb event queue, along with some useful such cases:

class Monad m => EventQueueCtx m where
    stateEventQueue :: (EventQueue -> (a, EventQueue)) -> m a

Example

C program reacting to a MotionNotify event might use something like the following to only use the most recent MotionNotify event (because ones from the past are useless and can cause lag):

while(XCheckTypedEvent(dpy, MotionNotify, &ev));

This package contains the following function:

skipEventsByType :: (MonadX x m, EventQueueCtx m, Event e) => m (Maybe e)

which can be used to the effect of XCheckTypedEvent like so:

onMotionNotify :: (MonadX IO m, EventQueueCtx m) => MotionNotifyEvent -> m ()
onMotionNotify ev = do
    flushEventQueue -- move events from xhb channel to our state
    MkMotionNotifyEvent{..} <- fromMaybe ev <$> skipEventsByType
    ...

Documentation

This article describes this package and some of its friends in detail.

Haddock can be found here.

About

Monad transformer over xhb-monad for more sophisticated event handling

Resources

License

Releases

No releases published

Packages

No packages published