On DisplayHandles, the core defines a couple of basic combinators for producing new DisplayHandles out of existing ones:
type Controller = DisplayHandle -> DisplayHandle
type DevController = DeviceHandler -> DeviceHandler
type SysController = SystemHandler -> SystemHandler
{- just a function application -}
encapsulateDH :: Controller -> DisplayHandle -> DisplayHandle
encapsulateEv :: DevController -> DisplayHandle -> DisplayHandle
encapsulateSys :: SysController -> DisplayHandle -> DisplayHandle
The new DisplayHandle constructed by these three combinators will catch commands and user input events destined for a component, interpret them, and perhaps then pass them on to their `child.' Catching user input events is a quite common task, so a separate, slightly easier to use combinator is also included in the core:
catchDeviceEv :: DisplayHandle -> IO (InputDevice, DisplayHandle) getDeviceEv :: InputDevice -> IO DeviceEvent sendDeviceEv :: InputDevice -> DeviceEvent -> IO ()
All device events, See section The DeviceEvent type, are diverted to the InputDevice channel that can be listened to with getDeviceEv. If the events received on the InputDevice is not of interest, sendDeviceEv can be used to pass the event on to the encapsulated component.