    {-# LINE 1 "Graphics/X11/Xlib/Event.hsc" #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.X11.Xlib.Event
    -- Copyright   :  (c) Alastair Reid, 1999-2003
    -- License     :  BSD-style (see the file libraries/base/LICENSE)
    --
    -- Maintainer  :  libraries@haskell.org
    -- Stability   :  provisional
    -- Portability :  portable
    --
    -- A collection of FFI declarations for interfacing with Xlib Events.
    --
    -----------------------------------------------------------------------------

    module Graphics.X11.Xlib.Event(
            QueuedMode,
            queuedAlready,
            queuedAfterFlush,
            queuedAfterReading,
            XEvent(..),
            XEventPtr,
            allocaXEvent,
            get_EventType,
            get_Window,
            XKeyEvent,
            XKeyEventPtr,
            asKeyEvent,
            XButtonEvent,
            get_KeyEvent,
            get_ButtonEvent,
            get_MotionEvent,
            XMotionEvent,
            XExposeEvent,
            get_ExposeEvent,
            XMappingEvent,
            XConfigureEvent,
            get_ConfigureEvent,
            waitForEvent,
            gettimeofday_in_milliseconds,
            -- gettimeofday_in_milliseconds_internal,
            flush,
            sync,
            pending,
            eventsQueued,
            nextEvent,
            allowEvents,
            selectInput,
            sendEvent,
            windowEvent,
            checkWindowEvent,
            maskEvent,
            checkMaskEvent,
            checkTypedEvent,
            checkTypedWindowEvent,
            putBackEvent,
            peekEvent,
            refreshKeyboardMapping,

            ) where

    import Graphics.X11.Types
    import Graphics.X11.Xlib.Types
    import Graphics.X11.Xlib.Display( connectionNumber )

    import Foreign
    import Foreign.C.Types

    {-# LINE 70 "Graphics/X11/Xlib/Event.hsc" #-}
    import Data.Data

    {-# LINE 72 "Graphics/X11/Xlib/Event.hsc" #-}

    {-# CFILES cbits/fdset.c #-}

    ----------------------------------------------------------------
    -- Events
    ----------------------------------------------------------------

    type   QueuedMode   = CInt
    queuedAlready         :: QueuedMode
    queuedAlready :: CInt
    queuedAlready         =  CInt
    0
    queuedAfterFlush      :: QueuedMode
    queuedAfterFlush :: CInt
    queuedAfterFlush      =  CInt
    2
    queuedAfterReading    :: QueuedMode
    queuedAfterReading :: CInt
    queuedAfterReading    =  CInt
    1

    {-# LINE 87 "Graphics/X11/Xlib/Event.hsc" #-}

    -- Because of the way the corresponding C types are defined,
    -- These "structs" are somewhat unusual - they omit fields which can
    -- be found in more general structs.
    -- For example, XAnyEvent omits type since it is in XEvent.
    -- Therefore, to get the complete contents of an event one typically
    -- writes:
    --   do
    --     ty <- get_XEvent e
    --     (serial,send_event,display,window) <- get_XAnyEvent
    --     window' <- get_XDestroyWindowEvent

    newtype XEvent = XEvent XEventPtr

    {-# LINE 101 "Graphics/X11/Xlib/Event.hsc" #-}
            deriving (XEvent -> XEvent -> Bool
    (XEvent -> XEvent -> Bool)
    -> (XEvent -> XEvent -> Bool) -> Eq XEvent
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: XEvent -> XEvent -> Bool
    == :: XEvent -> XEvent -> Bool
    $c/= :: XEvent -> XEvent -> Bool
    /= :: XEvent -> XEvent -> Bool
    Eq, Eq XEvent
    Eq XEvent
    -> (XEvent -> XEvent -> Ordering)
    -> (XEvent -> XEvent -> Bool)
    -> (XEvent -> XEvent -> Bool)
    -> (XEvent -> XEvent -> Bool)
    -> (XEvent -> XEvent -> Bool)
    -> (XEvent -> XEvent -> XEvent)
    -> (XEvent -> XEvent -> XEvent)
    -> Ord XEvent
    XEvent -> XEvent -> Bool
    XEvent -> XEvent -> Ordering
    XEvent -> XEvent -> XEvent
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: XEvent -> XEvent -> Ordering
    compare :: XEvent -> XEvent -> Ordering
    $c< :: XEvent -> XEvent -> Bool
    < :: XEvent -> XEvent -> Bool
    $c<= :: XEvent -> XEvent -> Bool
    <= :: XEvent -> XEvent -> Bool
    $c> :: XEvent -> XEvent -> Bool
    > :: XEvent -> XEvent -> Bool
    $c>= :: XEvent -> XEvent -> Bool
    >= :: XEvent -> XEvent -> Bool
    $cmax :: XEvent -> XEvent -> XEvent
    max :: XEvent -> XEvent -> XEvent
    $cmin :: XEvent -> XEvent -> XEvent
    min :: XEvent -> XEvent -> XEvent
    Ord, Int -> XEvent -> ShowS
    [XEvent] -> ShowS
    XEvent -> String
    (Int -> XEvent -> ShowS)
    -> (XEvent -> String) -> ([XEvent] -> ShowS) -> Show XEvent
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> XEvent -> ShowS
    showsPrec :: Int -> XEvent -> ShowS
    $cshow :: XEvent -> String
    show :: XEvent -> String
    $cshowList :: [XEvent] -> ShowS
    showList :: [XEvent] -> ShowS
    Show, Typeable, Typeable XEvent
    Typeable XEvent
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> XEvent -> c XEvent)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c XEvent)
    -> (XEvent -> Constr)
    -> (XEvent -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c XEvent))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XEvent))
    -> ((forall b. Data b => b -> b) -> XEvent -> XEvent)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> XEvent -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> XEvent -> r)
    -> (forall u. (forall d. Data d => d -> u) -> XEvent -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> XEvent -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> XEvent -> m XEvent)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> XEvent -> m XEvent)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> XEvent -> m XEvent)
    -> Data XEvent
    XEvent -> Constr
    XEvent -> DataType
    (forall b. Data b => b -> b) -> XEvent -> XEvent
    forall a.
    Typeable a
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> XEvent -> u
    forall u. (forall d. Data d => d -> u) -> XEvent -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XEvent
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XEvent -> c XEvent
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XEvent)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XEvent)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XEvent -> c XEvent
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> XEvent -> c XEvent
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XEvent
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XEvent
    $ctoConstr :: XEvent -> Constr
    toConstr :: XEvent -> Constr
    $cdataTypeOf :: XEvent -> DataType
    dataTypeOf :: XEvent -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XEvent)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XEvent)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XEvent)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XEvent)
    $cgmapT :: (forall b. Data b => b -> b) -> XEvent -> XEvent
    gmapT :: (forall b. Data b => b -> b) -> XEvent -> XEvent
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> XEvent -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> XEvent -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> XEvent -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XEvent -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XEvent -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XEvent -> m XEvent
    Data)

    {-# LINE 105 "Graphics/X11/Xlib/Event.hsc" #-}
    type XEventPtr = Ptr XEvent

    allocaXEvent :: (XEventPtr -> IO a) -> IO a
    allocaXEvent :: forall a. (XEventPtr -> IO a) -> IO a
    allocaXEvent = Int -> (XEventPtr -> IO a) -> IO a
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes (Int
    192)
    {-# LINE 109 "Graphics/X11/Xlib/Event.hsc" #-}

    get_EventType :: XEventPtr -> IO EventType
    get_EventType :: XEventPtr -> IO Word32
    get_EventType = (\XEventPtr
    hsc_ptr -> XEventPtr -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff XEventPtr
    hsc_ptr Int
    0)
    {-# LINE 112 "Graphics/X11/Xlib/Event.hsc" #-}

    get_Window :: XEventPtr -> IO Window
    get_Window :: XEventPtr -> IO Window
    get_Window = (\XEventPtr
    hsc_ptr -> XEventPtr -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff XEventPtr
    hsc_ptr Int
    32)
    {-# LINE 115 "Graphics/X11/Xlib/Event.hsc" #-}

    -- %struct : XAnyEvent : XAnyEvent arg1
    --   Int32     : serial            # # of last request processed by server
    --   Bool      : send_event        # true if this came from a SendEvent request
    --   Display   : display           # Display the event was read from
    --   Window    : window            # window on which event was requested in event mask

    type XKeyEvent =
            ( Window    -- root window that the event occured on
            , Window    -- child window
            , Time      -- milliseconds
            , CInt       -- pointer x, y coordinates in event window
            , CInt       --
            , CInt       -- coordinates relative to root
            , CInt       --
            , Modifier  -- key or button mask
            , KeyCode   -- detail
            , Bool      -- same screen flag
            )

    peekXKeyEvent :: Ptr XKeyEvent -> IO XKeyEvent
    peekXKeyEvent :: Ptr XKeyEvent -> IO XKeyEvent
    peekXKeyEvent Ptr XKeyEvent
    p = do
            Window
    root            <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    40) Ptr XKeyEvent
    p
    {-# LINE 138 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    subwindow       <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    48) Ptr XKeyEvent
    p
    {-# LINE 139 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    time            <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    56) Ptr XKeyEvent
    p
    {-# LINE 140 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x               <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    64) Ptr XKeyEvent
    p
    {-# LINE 141 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y               <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    68) Ptr XKeyEvent
    p
    {-# LINE 142 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x_root          <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    72) Ptr XKeyEvent
    p
    {-# LINE 143 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y_root          <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    76) Ptr XKeyEvent
    p
    {-# LINE 144 "Graphics/X11/Xlib/Event.hsc" #-}
            Modifier
    state           <- ((\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Modifier
    forall b. Ptr b -> Int -> IO Modifier
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    80) Ptr XKeyEvent
    p) :: IO CUInt
    {-# LINE 145 "Graphics/X11/Xlib/Event.hsc" #-}
            Modifier
    keycode         <- ((\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Modifier
    forall b. Ptr b -> Int -> IO Modifier
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    84) Ptr XKeyEvent
    p) :: IO CUInt
    {-# LINE 146 "Graphics/X11/Xlib/Event.hsc" #-}
            Bool
    same_screen     <- (\Ptr XKeyEvent
    hsc_ptr -> Ptr XKeyEvent -> Int -> IO Bool
    forall b. Ptr b -> Int -> IO Bool
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XKeyEvent
    hsc_ptr Int
    88) Ptr XKeyEvent
    p
    {-# LINE 147 "Graphics/X11/Xlib/Event.hsc" #-}
            XKeyEvent -> IO XKeyEvent
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Window
    root, Window
    subwindow, Window
    time, CInt
    x, CInt
    y, CInt
    x_root, CInt
    y_root,
                    Modifier -> Modifier
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Modifier
    state, Modifier -> KeyCode
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Modifier
    keycode, Bool
    same_screen)

    get_KeyEvent :: XEventPtr -> IO XKeyEvent
    get_KeyEvent :: XEventPtr -> IO XKeyEvent
    get_KeyEvent XEventPtr
    p = Ptr XKeyEvent -> IO XKeyEvent
    peekXKeyEvent (XEventPtr -> Ptr XKeyEvent
    forall a b. Ptr a -> Ptr b
    castPtr XEventPtr
    p)

    type XKeyEventPtr   = Ptr XKeyEvent

    asKeyEvent :: XEventPtr -> XKeyEventPtr
    asKeyEvent :: XEventPtr -> Ptr XKeyEvent
    asKeyEvent = XEventPtr -> Ptr XKeyEvent
    forall a b. Ptr a -> Ptr b
    castPtr

    type XButtonEvent =
            ( Window    --  root window that the event occured on
            , Window    --  child window
            , Time      --  milliseconds
            , CInt       -- pointer x, y coordinates in event window
            , CInt
            , CInt       -- coordinates relative to root
            , CInt
            , Modifier  --  key or button mask
            , Button    --  detail
            , Bool      --  same screen flag
            )

    peekXButtonEvent :: Ptr XButtonEvent -> IO XButtonEvent
    peekXButtonEvent :: Ptr XButtonEvent -> IO XButtonEvent
    peekXButtonEvent Ptr XButtonEvent
    p = do
            Window
    root            <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    40) Ptr XButtonEvent
    p
    {-# LINE 174 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    subwindow       <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    48) Ptr XButtonEvent
    p
    {-# LINE 175 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    time            <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    56) Ptr XButtonEvent
    p
    {-# LINE 176 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x               <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    64) Ptr XButtonEvent
    p
    {-# LINE 177 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y               <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    68) Ptr XButtonEvent
    p
    {-# LINE 178 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x_root          <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    72) Ptr XButtonEvent
    p
    {-# LINE 179 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y_root          <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    76) Ptr XButtonEvent
    p
    {-# LINE 180 "Graphics/X11/Xlib/Event.hsc" #-}
            Modifier
    state           <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Modifier
    forall b. Ptr b -> Int -> IO Modifier
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    80) Ptr XButtonEvent
    p
    {-# LINE 181 "Graphics/X11/Xlib/Event.hsc" #-}
            Word32
    button          <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    84) Ptr XButtonEvent
    p
    {-# LINE 182 "Graphics/X11/Xlib/Event.hsc" #-}
            Bool
    same_screen     <- (\Ptr XButtonEvent
    hsc_ptr -> Ptr XButtonEvent -> Int -> IO Bool
    forall b. Ptr b -> Int -> IO Bool
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XButtonEvent
    hsc_ptr Int
    88) Ptr XButtonEvent
    p
    {-# LINE 183 "Graphics/X11/Xlib/Event.hsc" #-}
            XButtonEvent -> IO XButtonEvent
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Window
    root, Window
    subwindow, Window
    time, CInt
    x, CInt
    y, CInt
    x_root, CInt
    y_root,
                    Modifier
    state, Word32
    button, Bool
    same_screen)

    get_ButtonEvent :: XEventPtr -> IO XButtonEvent
    get_ButtonEvent :: XEventPtr -> IO XButtonEvent
    get_ButtonEvent XEventPtr
    p = Ptr XButtonEvent -> IO XButtonEvent
    peekXButtonEvent (XEventPtr -> Ptr XButtonEvent
    forall a b. Ptr a -> Ptr b
    castPtr XEventPtr
    p)

    type XMotionEvent =
            ( Window      -- root window that the event occured on
            , Window      -- child window
            , Time        -- milliseconds
            , CInt         -- pointer x, y coordinates in event window
            , CInt
            , CInt         -- coordinates relative to root
            , CInt
            , Modifier    -- key or button mask
            , NotifyMode  -- detail
            , Bool        -- same screen flag
            )

    peekXMotionEvent :: Ptr XMotionEvent -> IO XMotionEvent
    peekXMotionEvent :: Ptr XMotionEvent -> IO XMotionEvent
    peekXMotionEvent Ptr XMotionEvent
    p = do
            Window
    root            <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    40) Ptr XMotionEvent
    p
    {-# LINE 205 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    subwindow       <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    48) Ptr XMotionEvent
    p
    {-# LINE 206 "Graphics/X11/Xlib/Event.hsc" #-}
            Window
    time            <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO Window
    forall b. Ptr b -> Int -> IO Window
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    56) Ptr XMotionEvent
    p
    {-# LINE 207 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x               <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    64) Ptr XMotionEvent
    p
    {-# LINE 208 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y               <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    68) Ptr XMotionEvent
    p
    {-# LINE 209 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    x_root          <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    72) Ptr XMotionEvent
    p
    {-# LINE 210 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    y_root          <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    76) Ptr XMotionEvent
    p
    {-# LINE 211 "Graphics/X11/Xlib/Event.hsc" #-}
            Modifier
    state           <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO Modifier
    forall b. Ptr b -> Int -> IO Modifier
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    80) Ptr XMotionEvent
    p
    {-# LINE 212 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    is_hint         <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    84) Ptr XMotionEvent
    p
    {-# LINE 213 "Graphics/X11/Xlib/Event.hsc" #-}
            Bool
    same_screen     <- (\Ptr XMotionEvent
    hsc_ptr -> Ptr XMotionEvent -> Int -> IO Bool
    forall b. Ptr b -> Int -> IO Bool
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XMotionEvent
    hsc_ptr Int
    88) Ptr XMotionEvent
    p
    {-# LINE 214 "Graphics/X11/Xlib/Event.hsc" #-}
            XMotionEvent -> IO XMotionEvent
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Window
    root, Window
    subwindow, Window
    time, CInt
    x, CInt
    y, CInt
    x_root, CInt
    y_root,
                    Modifier
    state, CInt
    is_hint, Bool
    same_screen)

    get_MotionEvent :: XEventPtr -> IO XMotionEvent
    get_MotionEvent :: XEventPtr -> IO XMotionEvent
    get_MotionEvent XEventPtr
    p = Ptr XMotionEvent -> IO XMotionEvent
    peekXMotionEvent (XEventPtr -> Ptr XMotionEvent
    forall a b. Ptr a -> Ptr b
    castPtr XEventPtr
    p)

    -- %struct : XCrossingEvent : XCrossingEvent arg1
    --   Window       : root                # root window that the event occured on
    --   Window       : subwindow   # child window
    --   Time         : time                # milliseconds
    --   Int          : x           # pointer x, y coordinates in event window
    --   Int          : y
    --   Int          : x_root              # coordinates relative to root
    --   Int          : y_root
    --   NotifyMode   : mode
    --   NotifyDetail : detail
    --   Bool         : same_screen # same screen flag
    --   Bool         : focus               # boolean focus
    --   Modifier     : state               # key or button mask
    --
    -- %struct : XFocusChangeEvent : XFocusChangeEvent arg1
    --   NotifyMode   : mode
    --   NotifyDetail : detail
    --
    -- -- omitted: should be translated into bitmaps
    -- -- PURE void getKeymapEvent(event)
    -- -- IN XEvent*        event
    -- -- OUT Window        window          = ((XKeymapEvent*)event)->window
    -- -- OUT array[32] Char key_vector     = ((XKeymapEvent*)event)->key_vector
    -- -- RESULT:

    type XExposeEvent =
            ( Position      -- x
            , Position      -- y
            , Dimension     -- width
            , Dimension     -- height
            , CInt          -- count
            )

    peekXExposeEvent :: Ptr XExposeEvent -> IO XExposeEvent
    peekXExposeEvent :: Ptr XExposeEvent -> IO XExposeEvent
    peekXExposeEvent Ptr XExposeEvent
    p = do
            Position
    x       <- (\Ptr XExposeEvent
    hsc_ptr -> Ptr XExposeEvent -> Int -> IO Position
    forall b. Ptr b -> Int -> IO Position
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XExposeEvent
    hsc_ptr Int
    40) Ptr XExposeEvent
    p
    {-# LINE 256 "Graphics/X11/Xlib/Event.hsc" #-}
            Position
    y       <- (\Ptr XExposeEvent
    hsc_ptr -> Ptr XExposeEvent -> Int -> IO Position
    forall b. Ptr b -> Int -> IO Position
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XExposeEvent
    hsc_ptr Int
    44) Ptr XExposeEvent
    p
    {-# LINE 257 "Graphics/X11/Xlib/Event.hsc" #-}
            Word32
    width   <- (\Ptr XExposeEvent
    hsc_ptr -> Ptr XExposeEvent -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XExposeEvent
    hsc_ptr Int
    48) Ptr XExposeEvent
    p
    {-# LINE 258 "Graphics/X11/Xlib/Event.hsc" #-}
            Word32
    height  <- (\Ptr XExposeEvent
    hsc_ptr -> Ptr XExposeEvent -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XExposeEvent
    hsc_ptr Int
    52) Ptr XExposeEvent
    p
    {-# LINE 259 "Graphics/X11/Xlib/Event.hsc" #-}
            CInt
    count   <- (\Ptr XExposeEvent
    hsc_ptr -> Ptr XExposeEvent -> Int -> IO CInt
    forall b. Ptr b -> Int -> IO CInt
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XExposeEvent
    hsc_ptr Int
    56) Ptr XExposeEvent
    p
    {-# LINE 260 "Graphics/X11/Xlib/Event.hsc" #-}
            XExposeEvent -> IO XExposeEvent
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Position
    x, Position
    y, Word32
    width, Word32
    height, CInt
    count)

    get_ExposeEvent :: XEventPtr -> IO XExposeEvent
    get_ExposeEvent :: XEventPtr -> IO XExposeEvent
    get_ExposeEvent XEventPtr
    p = Ptr XExposeEvent -> IO XExposeEvent
    peekXExposeEvent (XEventPtr -> Ptr XExposeEvent
    forall a b. Ptr a -> Ptr b
    castPtr XEventPtr
    p)

    -- %struct : XGraphicsExposeEvent : XGraphicsExposeEvent arg1
    --   Position   : x
    --   Position   : y
    --   Dimension  : width         .
    --   Dimension  : height
    --   Int                : count
    --   Int                : major_code
    --   Int                : minor_code
    --
    -- %struct : XCirculateEvent : XCirculateEvent arg1
    --   Window     : window
    --   Place              : place
    --
    -- %struct : XConfigureEvent : XConfigureEvent arg1
    --   Window     : window
    --   Position   : x
    --   Position   : y
    --   Dimension  : width
    --   Dimension  : height
    --   Dimension  : border_width
    --   Window     : above
    --   Bool               : override_redirect
    --
    -- %struct : XCreateWindowEvent : XCreateWindowEvent arg1
    --   Window     : window
    --   Position   : x
    --   Position   : y
    --   Dimension  : width
    --   Dimension  : height
    --   Dimension  : border_width
    --   Bool               : override_redirect
    --
    -- %struct : XDestroyWindowEvent : XDestroyWindowEvent arg1
    --   Window     : window
    --
    -- %struct : XGravityEvent : XGravityEvent arg1
    --   Window     : window
    --   Position   : x
    --   Position   : y
    --
    -- %struct : XMapEvent : XMapEvent arg1
    --   Bool               : override_redirect

    type XMappingEvent =
            ( MappingRequest  -- request
            , KeyCode         -- first_keycode
            , CInt            -- count
            )

    withXMappingEvent :: XMappingEvent -> (Ptr XMappingEvent -> IO a) -> IO a
    withXMappingEvent :: forall a. XMappingEvent -> (Ptr XMappingEvent -> IO a) -> IO a
    withXMappingEvent XMappingEvent
    event_map Ptr XMappingEvent -> IO a
    f =
            Int -> (Ptr XMappingEvent -> IO a) -> IO a
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes (Int
    56) ((Ptr XMappingEvent -> IO a) -> IO a)
    -> (Ptr XMappingEvent -> IO a) -> IO a
    forall a b. (a -> b) -> a -> b
    $ \ Ptr XMappingEvent
    event_map_ptr -> do
    {-# LINE 317 "Graphics/X11/Xlib/Event.hsc" #-}
            Ptr XMappingEvent -> XMappingEvent -> IO ()
    pokeXMappingEvent Ptr XMappingEvent
    event_map_ptr XMappingEvent
    event_map
            Ptr XMappingEvent -> IO a
    f Ptr XMappingEvent
    event_map_ptr

    pokeXMappingEvent :: Ptr XMappingEvent -> XMappingEvent -> IO ()
    pokeXMappingEvent :: Ptr XMappingEvent -> XMappingEvent -> IO ()
    pokeXMappingEvent Ptr XMappingEvent
    p (CInt
    request, KeyCode
    first_keycode, CInt
    count) = do
            (\Ptr XMappingEvent
    hsc_ptr -> Ptr XMappingEvent -> Int -> CInt -> IO ()
    forall b. Ptr b -> Int -> CInt -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr XMappingEvent
    hsc_ptr Int
    40)           Ptr XMappingEvent
    p CInt
    request
    {-# LINE 323 "Graphics/X11/Xlib/Event.hsc" #-}
            (\Ptr XMappingEvent
    hsc_ptr -> Ptr XMappingEvent -> Int -> KeyCode -> IO ()
    forall b. Ptr b -> Int -> KeyCode -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr XMappingEvent
    hsc_ptr Int
    44)     Ptr XMappingEvent
    p KeyCode
    first_keycode
    {-# LINE 324 "Graphics/X11/Xlib/Event.hsc" #-}
            (\Ptr XMappingEvent
    hsc_ptr -> Ptr XMappingEvent -> Int -> CInt -> IO ()
    forall b. Ptr b -> Int -> CInt -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr XMappingEvent
    hsc_ptr Int
    48)             Ptr XMappingEvent
    p CInt
    count
    {-# LINE 325 "Graphics/X11/Xlib/Event.hsc" #-}

    type XConfigureEvent =
            ( Position
            , Position
            , Dimension
            , Dimension
            )

    peekXConfigureEvent :: Ptr XConfigureEvent -> IO XConfigureEvent
    peekXConfigureEvent :: Ptr XConfigureEvent -> IO XConfigureEvent
    peekXConfigureEvent Ptr XConfigureEvent
    p = do
            Position
    x       <- (\Ptr XConfigureEvent
    hsc_ptr -> Ptr XConfigureEvent -> Int -> IO Position
    forall b. Ptr b -> Int -> IO Position
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XConfigureEvent
    hsc_ptr Int
    48) Ptr XConfigureEvent
    p
    {-# LINE 336 "Graphics/X11/Xlib/Event.hsc" #-}
            Position
    y       <- (\Ptr XConfigureEvent
    hsc_ptr -> Ptr XConfigureEvent -> Int -> IO Position
    forall b. Ptr b -> Int -> IO Position
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XConfigureEvent
    hsc_ptr Int
    52) Ptr XConfigureEvent
    p
    {-# LINE 337 "Graphics/X11/Xlib/Event.hsc" #-}
            Word32
    width   <- (\Ptr XConfigureEvent
    hsc_ptr -> Ptr XConfigureEvent -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XConfigureEvent
    hsc_ptr Int
    56) Ptr XConfigureEvent
    p
    {-# LINE 338 "Graphics/X11/Xlib/Event.hsc" #-}
            Word32
    height  <- (\Ptr XConfigureEvent
    hsc_ptr -> Ptr XConfigureEvent -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr XConfigureEvent
    hsc_ptr Int
    60) Ptr XConfigureEvent
    p
    {-# LINE 339 "Graphics/X11/Xlib/Event.hsc" #-}
            XConfigureEvent -> IO XConfigureEvent
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Position
    x, Position
    y, Word32
    width, Word32
    height)

    get_ConfigureEvent :: XEventPtr -> IO XConfigureEvent
    get_ConfigureEvent :: XEventPtr -> IO XConfigureEvent
    get_ConfigureEvent XEventPtr
    p = Ptr XConfigureEvent -> IO XConfigureEvent
    peekXConfigureEvent (XEventPtr -> Ptr XConfigureEvent
    forall a b. Ptr a -> Ptr b
    castPtr XEventPtr
    p)

    -- %struct : XResizeRequestEvent : XResizeRequestEvent arg1
    --   Dimension  : width
    --   Dimension  : height
    --

    -- %struct : XReparentEvent : XReparentEvent arg1
    --   Window     : window
    --   Window     : parent
    --   Position   : x
    --   Position   : y
    --   Bool               : override_redirect
    --
    -- %struct : XUnmapEvent : XUnmapEvent arg1
    --   Window     : window
    --   Bool               : from_configure
    --
    -- %struct : XVisibilityEvent : XVisibilityEvent arg1
    --   Visibility : state
    --
    -- %struct : XCirculateRequestEvent : XCirculateRequestEvent arg1
    --   Place              : place
    --
    -- -- omitted because valuemask looks tricky
    -- -- %struct : XConfigureRequestEvent : XConfigureRequestEvent arg1
    -- --   Window   : window
    -- --   Position         : x
    -- --   Position         : y
    -- --   Dimension        : width
    -- --   Dimension        : height
    -- --   Dimension        : border_width
    -- --   Window   : above
    -- --   StackingMethod : detail
    -- --   ???              : valuemask
    --
    -- %struct : XMapRequestEvent : XMapRequestEvent arg1
    --   Window     : window
    --
    -- %struct : XColormapEvent : XColormapEvent arg1
    --   Colormap           : colormap
    --   Bool                       : new
    --   ColormapNotification       : state
    --
    -- -- getClientMessageEvent omitted
    -- -- getPropertyEvent omitted
    -- -- getSelectionClearEvent omitted
    -- -- getSelectionRequestEvent omitted
    -- -- getSelectionEvent omitted
    -- -- xrrScreenChangeNotifyEvent omitted

    -- functions

    -- The following is useful if you want to do a read with timeout.

    -- | Reads an event with a timeout (in microseconds).
    -- Returns True if timeout occurs.
    waitForEvent :: Display -> Word32 -> IO Bool
    waitForEvent :: Display -> Word32 -> IO Bool
    waitForEvent Display
    display Word32
    usecs =
            TimeVal -> (Ptr TimeVal -> IO Bool) -> IO Bool
    forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
    with (Word32 -> Word32 -> TimeVal
    TimeVal (Word32
    usecs Word32 -> Word32 -> Word32
    forall a. Integral a => a -> a -> a
    `div` Word32
    1000000) (Word32
    usecs Word32 -> Word32 -> Word32
    forall a. Integral a => a -> a -> a
    `mod` Word32
    1000000)) ((Ptr TimeVal -> IO Bool) -> IO Bool)
    -> (Ptr TimeVal -> IO Bool) -> IO Bool
    forall a b. (a -> b) -> a -> b
    $ \ Ptr TimeVal
    tv_ptr ->
            Int -> (Ptr FdSet -> IO Bool) -> IO Bool
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes (Int
    128) ((Ptr FdSet -> IO Bool) -> IO Bool)
    -> (Ptr FdSet -> IO Bool) -> IO Bool
    forall a b. (a -> b) -> a -> b
    $ \ Ptr FdSet
    readfds ->
    {-# LINE 403 "Graphics/X11/Xlib/Event.hsc" #-}
            Int -> (Ptr FdSet -> IO Bool) -> IO Bool
    forall a b. Int -> (Ptr a -> IO b) -> IO b
    allocaBytes (Int
    128) ((Ptr FdSet -> IO Bool) -> IO Bool)
    -> (Ptr FdSet -> IO Bool) -> IO Bool
    forall a b. (a -> b) -> a -> b
    $ \ Ptr FdSet
    nofds -> do
    {-# LINE 404 "Graphics/X11/Xlib/Event.hsc" #-}
            let fd :: CInt
    fd = Display -> CInt
    connectionNumber Display
    display
            Ptr FdSet -> IO ()
    fdZero Ptr FdSet
    readfds
            Ptr FdSet -> IO ()
    fdZero Ptr FdSet
    nofds
            CInt -> Ptr FdSet -> IO ()
    fdSet (CInt -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    fd) Ptr FdSet
    readfds
            CInt
    n <- CInt
    -> Ptr FdSet -> Ptr FdSet -> Ptr FdSet -> Ptr TimeVal -> IO CInt
    select ((CInt -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    fd)CInt -> CInt -> CInt
    forall a. Num a => a -> a -> a
    +CInt
    1) Ptr FdSet
    readfds Ptr FdSet
    nofds Ptr FdSet
    nofds Ptr TimeVal
    tv_ptr
            Bool -> IO Bool
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (CInt
    n CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    == CInt
    0)

    newtype FdSet = FdSet (Ptr FdSet)

    {-# LINE 413 "Graphics/X11/Xlib/Event.hsc" #-}
            deriving (FdSet -> FdSet -> Bool
    (FdSet -> FdSet -> Bool) -> (FdSet -> FdSet -> Bool) -> Eq FdSet
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FdSet -> FdSet -> Bool
    == :: FdSet -> FdSet -> Bool
    $c/= :: FdSet -> FdSet -> Bool
    /= :: FdSet -> FdSet -> Bool
    Eq, Eq FdSet
    Eq FdSet
    -> (FdSet -> FdSet -> Ordering)
    -> (FdSet -> FdSet -> Bool)
    -> (FdSet -> FdSet -> Bool)
    -> (FdSet -> FdSet -> Bool)
    -> (FdSet -> FdSet -> Bool)
    -> (FdSet -> FdSet -> FdSet)
    -> (FdSet -> FdSet -> FdSet)
    -> Ord FdSet
    FdSet -> FdSet -> Bool
    FdSet -> FdSet -> Ordering
    FdSet -> FdSet -> FdSet
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: FdSet -> FdSet -> Ordering
    compare :: FdSet -> FdSet -> Ordering
    $c< :: FdSet -> FdSet -> Bool
    < :: FdSet -> FdSet -> Bool
    $c<= :: FdSet -> FdSet -> Bool
    <= :: FdSet -> FdSet -> Bool
    $c> :: FdSet -> FdSet -> Bool
    > :: FdSet -> FdSet -> Bool
    $c>= :: FdSet -> FdSet -> Bool
    >= :: FdSet -> FdSet -> Bool
    $cmax :: FdSet -> FdSet -> FdSet
    max :: FdSet -> FdSet -> FdSet
    $cmin :: FdSet -> FdSet -> FdSet
    min :: FdSet -> FdSet -> FdSet
    Ord, Int -> FdSet -> ShowS
    [FdSet] -> ShowS
    FdSet -> String
    (Int -> FdSet -> ShowS)
    -> (FdSet -> String) -> ([FdSet] -> ShowS) -> Show FdSet
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FdSet -> ShowS
    showsPrec :: Int -> FdSet -> ShowS
    $cshow :: FdSet -> String
    show :: FdSet -> String
    $cshowList :: [FdSet] -> ShowS
    showList :: [FdSet] -> ShowS
    Show, Typeable, Typeable FdSet
    Typeable FdSet
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> FdSet -> c FdSet)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c FdSet)
    -> (FdSet -> Constr)
    -> (FdSet -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c FdSet))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FdSet))
    -> ((forall b. Data b => b -> b) -> FdSet -> FdSet)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r)
    -> (forall u. (forall d. Data d => d -> u) -> FdSet -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> FdSet -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> FdSet -> m FdSet)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> FdSet -> m FdSet)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> FdSet -> m FdSet)
    -> Data FdSet
    FdSet -> Constr
    FdSet -> DataType
    (forall b. Data b => b -> b) -> FdSet -> FdSet
    forall a.
    Typeable a
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> FdSet -> u
    forall u. (forall d. Data d => d -> u) -> FdSet -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FdSet
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> FdSet -> c FdSet
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FdSet)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FdSet)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> FdSet -> c FdSet
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> FdSet -> c FdSet
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FdSet
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FdSet
    $ctoConstr :: FdSet -> Constr
    toConstr :: FdSet -> Constr
    $cdataTypeOf :: FdSet -> DataType
    dataTypeOf :: FdSet -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FdSet)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FdSet)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FdSet)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FdSet)
    $cgmapT :: (forall b. Data b => b -> b) -> FdSet -> FdSet
    gmapT :: (forall b. Data b => b -> b) -> FdSet -> FdSet
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FdSet -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> FdSet -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> FdSet -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FdSet -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FdSet -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FdSet -> m FdSet
    Data)

    {-# LINE 417 "Graphics/X11/Xlib/Event.hsc" #-}

    foreign import ccall unsafe "HsXlib.h" fdZero :: Ptr FdSet -> IO ()
    foreign import ccall unsafe "HsXlib.h" fdSet :: CInt -> Ptr FdSet -> IO ()

    foreign import ccall unsafe "HsXlib.h" select ::
            CInt -> Ptr FdSet -> Ptr FdSet -> Ptr FdSet -> Ptr TimeVal -> IO CInt

    -- | This function is somewhat compatible with Win32's @TimeGetTime()@
    gettimeofday_in_milliseconds :: IO Integer
    gettimeofday_in_milliseconds :: IO Integer
    gettimeofday_in_milliseconds =
            (Ptr TimeVal -> IO Integer) -> IO Integer
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
    alloca ((Ptr TimeVal -> IO Integer) -> IO Integer)
    -> (Ptr TimeVal -> IO Integer) -> IO Integer
    forall a b. (a -> b) -> a -> b
    $ \ Ptr TimeVal
    tv_ptr -> do
            ()
    _rc <- Ptr TimeVal -> Ptr TimeZone -> IO ()
    gettimeofday Ptr TimeVal
    tv_ptr Ptr TimeZone
    forall a. Ptr a
    nullPtr
            TimeVal Word32
    sec Word32
    usec <- Ptr TimeVal -> IO TimeVal
    forall a. Storable a => Ptr a -> IO a
    peek Ptr TimeVal
    tv_ptr
            Integer -> IO Integer
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word32
    sec Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    * Integer
    1000 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word32
    usec Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `div` Integer
    1000)

    data TimeVal = TimeVal Word32 Word32

    instance Storable TimeVal where
            alignment :: TimeVal -> Int
    alignment TimeVal
    _ = (Int
    4)
    {-# LINE 436 "Graphics/X11/Xlib/Event.hsc" #-}
            sizeOf :: TimeVal -> Int
    sizeOf TimeVal
    _ = (Int
    16)
    {-# LINE 437 "Graphics/X11/Xlib/Event.hsc" #-}
            peek :: Ptr TimeVal -> IO TimeVal
    peek Ptr TimeVal
    p = do
                    Word32
    sec <- (\Ptr TimeVal
    hsc_ptr -> Ptr TimeVal -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr TimeVal
    hsc_ptr Int
    0) Ptr TimeVal
    p
    {-# LINE 439 "Graphics/X11/Xlib/Event.hsc" #-}
                    Word32
    usec <- (\Ptr TimeVal
    hsc_ptr -> Ptr TimeVal -> Int -> IO Word32
    forall b. Ptr b -> Int -> IO Word32
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr TimeVal
    hsc_ptr Int
    8) Ptr TimeVal
    p
    {-# LINE 440 "Graphics/X11/Xlib/Event.hsc" #-}
                    TimeVal -> IO TimeVal
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Word32 -> Word32 -> TimeVal
    TimeVal Word32
    sec Word32
    usec)
            poke :: Ptr TimeVal -> TimeVal -> IO ()
    poke Ptr TimeVal
    p (TimeVal Word32
    sec Word32
    usec) = do
                    (\Ptr TimeVal
    hsc_ptr -> Ptr TimeVal -> Int -> Word32 -> IO ()
    forall b. Ptr b -> Int -> Word32 -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr TimeVal
    hsc_ptr Int
    0) Ptr TimeVal
    p Word32
    sec
    {-# LINE 443 "Graphics/X11/Xlib/Event.hsc" #-}
                    (\Ptr TimeVal
    hsc_ptr -> Ptr TimeVal -> Int -> Word32 -> IO ()
    forall b. Ptr b -> Int -> Word32 -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr TimeVal
    hsc_ptr Int
    8) Ptr TimeVal
    p Word32
    usec
    {-# LINE 444 "Graphics/X11/Xlib/Event.hsc" #-}

    newtype TimeZone = TimeZone (Ptr TimeZone)

    {-# LINE 447 "Graphics/X11/Xlib/Event.hsc" #-}
            deriving (TimeZone -> TimeZone -> Bool
    (TimeZone -> TimeZone -> Bool)
    -> (TimeZone -> TimeZone -> Bool) -> Eq TimeZone
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TimeZone -> TimeZone -> Bool
    == :: TimeZone -> TimeZone -> Bool
    $c/= :: TimeZone -> TimeZone -> Bool
    /= :: TimeZone -> TimeZone -> Bool
    Eq, Eq TimeZone
    Eq TimeZone
    -> (TimeZone -> TimeZone -> Ordering)
    -> (TimeZone -> TimeZone -> Bool)
    -> (TimeZone -> TimeZone -> Bool)
    -> (TimeZone -> TimeZone -> Bool)
    -> (TimeZone -> TimeZone -> Bool)
    -> (TimeZone -> TimeZone -> TimeZone)
    -> (TimeZone -> TimeZone -> TimeZone)
    -> Ord TimeZone
    TimeZone -> TimeZone -> Bool
    TimeZone -> TimeZone -> Ordering
    TimeZone -> TimeZone -> TimeZone
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: TimeZone -> TimeZone -> Ordering
    compare :: TimeZone -> TimeZone -> Ordering
    $c< :: TimeZone -> TimeZone -> Bool
    < :: TimeZone -> TimeZone -> Bool
    $c<= :: TimeZone -> TimeZone -> Bool
    <= :: TimeZone -> TimeZone -> Bool
    $c> :: TimeZone -> TimeZone -> Bool
    > :: TimeZone -> TimeZone -> Bool
    $c>= :: TimeZone -> TimeZone -> Bool
    >= :: TimeZone -> TimeZone -> Bool
    $cmax :: TimeZone -> TimeZone -> TimeZone
    max :: TimeZone -> TimeZone -> TimeZone
    $cmin :: TimeZone -> TimeZone -> TimeZone
    min :: TimeZone -> TimeZone -> TimeZone
    Ord, Int -> TimeZone -> ShowS
    [TimeZone] -> ShowS
    TimeZone -> String
    (Int -> TimeZone -> ShowS)
    -> (TimeZone -> String) -> ([TimeZone] -> ShowS) -> Show TimeZone
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TimeZone -> ShowS
    showsPrec :: Int -> TimeZone -> ShowS
    $cshow :: TimeZone -> String
    show :: TimeZone -> String
    $cshowList :: [TimeZone] -> ShowS
    showList :: [TimeZone] -> ShowS
    Show, Typeable, Typeable TimeZone
    Typeable TimeZone
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> TimeZone -> c TimeZone)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c TimeZone)
    -> (TimeZone -> Constr)
    -> (TimeZone -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c TimeZone))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeZone))
    -> ((forall b. Data b => b -> b) -> TimeZone -> TimeZone)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> TimeZone -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> TimeZone -> r)
    -> (forall u. (forall d. Data d => d -> u) -> TimeZone -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> TimeZone -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone)
    -> Data TimeZone
    TimeZone -> Constr
    TimeZone -> DataType
    (forall b. Data b => b -> b) -> TimeZone -> TimeZone
    forall a.
    Typeable a
    -> (forall (c :: * -> *).
        (forall d b. Data d => c (d -> b) -> d -> c b)
        -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> TimeZone -> u
    forall u. (forall d. Data d => d -> u) -> TimeZone -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TimeZone
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TimeZone -> c TimeZone
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TimeZone)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeZone)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TimeZone -> c TimeZone
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TimeZone -> c TimeZone
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TimeZone
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TimeZone
    $ctoConstr :: TimeZone -> Constr
    toConstr :: TimeZone -> Constr
    $cdataTypeOf :: TimeZone -> DataType
    dataTypeOf :: TimeZone -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TimeZone)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TimeZone)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeZone)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeZone)
    $cgmapT :: (forall b. Data b => b -> b) -> TimeZone -> TimeZone
    gmapT :: (forall b. Data b => b -> b) -> TimeZone -> TimeZone
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TimeZone -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> TimeZone -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> TimeZone -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TimeZone -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TimeZone -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone
    Data)

    {-# LINE 451 "Graphics/X11/Xlib/Event.hsc" #-}

    foreign import ccall unsafe "HsXlib.h"
            gettimeofday :: Ptr TimeVal -> Ptr TimeZone -> IO ()

    -- | interface to the X11 library function @XFlush()@.
    foreign import ccall unsafe "HsXlib.h XFlush"
            flush        :: Display ->               IO ()

    -- | interface to the X11 library function @XSync()@.
    foreign import ccall safe "HsXlib.h XSync"
            sync         :: Display -> Bool ->       IO ()

    -- | interface to the X11 library function @XPending()@.
    foreign import ccall unsafe "HsXlib.h XPending"
            pending      :: Display ->               IO CInt

    -- | interface to the X11 library function @XEventsQueued()@.
    foreign import ccall unsafe "HsXlib.h XEventsQueued"
            eventsQueued :: Display -> QueuedMode -> IO CInt

    -- | interface to the X11 library function @XNextEvent()@.
    foreign import ccall safe "HsXlib.h XNextEvent"
            nextEvent    :: Display -> XEventPtr  -> IO ()

    -- | interface to the X11 library function @XAllowEvents()@.
    foreign import ccall unsafe "HsXlib.h XAllowEvents"
            allowEvents  :: Display -> AllowEvents -> Time -> IO ()

    -- ToDo: XFree(res1) after constructing result
    -- %fun XGetMotionEvents :: Display -> Window -> Time -> Time -> IO ListXTimeCoord
    -- %code res1 = XGetMotionEvents(arg1,arg2,arg3,arg4,&res1_size)

    -- | interface to the X11 library function @XSelectInput()@.
    foreign import ccall unsafe "HsXlib.h XSelectInput"
            selectInput :: Display -> Window -> EventMask -> IO ()

    -- | interface to the X11 library function @XSendEvent()@.
    sendEvent :: Display -> Window -> Bool -> EventMask -> XEventPtr -> IO ()
    sendEvent :: Display -> Window -> Bool -> Window -> XEventPtr -> IO ()
    sendEvent Display
    display Window
    w Bool
    propagate Window
    event_mask XEventPtr
    event_send =
            String -> IO CInt -> IO ()
    throwIfZero String
    "sendEvent" (IO CInt -> IO ()) -> IO CInt -> IO ()
    forall a b. (a -> b) -> a -> b
    $
                    Display -> Window -> Bool -> Window -> XEventPtr -> IO CInt
    xSendEvent Display
    display Window
    w Bool
    propagate Window
    event_mask XEventPtr
    event_send
    foreign import ccall unsafe "HsXlib.h XSendEvent"
            xSendEvent :: Display -> Window -> Bool -> EventMask ->
                    XEventPtr -> IO Status

    -- | interface to the X11 library function @XWindowEvent()@.
    foreign import ccall safe "HsXlib.h XWindowEvent"
            windowEvent :: Display -> Window -> EventMask -> XEventPtr -> IO ()

    -- | interface to the X11 library function @XCheckWindowEvent()@.
    foreign import ccall unsafe "HsXlib.h XCheckWindowEvent"
            checkWindowEvent :: Display -> Window -> EventMask ->
                    XEventPtr -> IO Bool

    -- | interface to the X11 library function @XMaskEvent()@.
    foreign import ccall safe "HsXlib.h XMaskEvent"
            maskEvent :: Display -> EventMask -> XEventPtr -> IO ()

    -- | interface to the X11 library function @XCheckMaskEvent()@.
    foreign import ccall unsafe "HsXlib.h XCheckMaskEvent"
            checkMaskEvent :: Display -> EventMask -> XEventPtr -> IO Bool

    -- | interface to the X11 library function @XCheckTypedEvent()@.
    foreign import ccall unsafe "HsXlib.h XCheckTypedEvent"
            checkTypedEvent :: Display -> EventType -> XEventPtr -> IO Bool

    -- | interface to the X11 library function @XCheckTypedWindowEvent()@.
    foreign import ccall unsafe "HsXlib.h XCheckTypedWindowEvent"
            checkTypedWindowEvent :: Display -> Window -> EventType ->
                    XEventPtr -> IO Bool

    -- | interface to the X11 library function @XPutBackEvent()@.
    foreign import ccall unsafe "HsXlib.h XPutBackEvent"
            putBackEvent :: Display -> XEventPtr -> IO ()

    -- | interface to the X11 library function @XPeekEvent()@.
    foreign import ccall safe "HsXlib.h XPeekEvent"
            peekEvent :: Display -> XEventPtr -> IO ()

    -- XFilterEvent omitted (can't find documentation)
    -- XIfEvent omitted (can't pass predicates (yet))
    -- XCheckIfEvent omitted (can't pass predicates (yet))
    -- XPeekIfEvent omitted (can't pass predicates (yet))

    -- | interface to the X11 library function @XRefreshKeyboardMapping()@.
    refreshKeyboardMapping :: XMappingEvent -> IO ()
    refreshKeyboardMapping :: XMappingEvent -> IO ()
    refreshKeyboardMapping XMappingEvent
    event_map =
            XMappingEvent -> (Ptr XMappingEvent -> IO ()) -> IO ()
    forall a. XMappingEvent -> (Ptr XMappingEvent -> IO a) -> IO a
    withXMappingEvent XMappingEvent
    event_map ((Ptr XMappingEvent -> IO ()) -> IO ())
    -> (Ptr XMappingEvent -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \ Ptr XMappingEvent
    event_map_ptr ->
            Ptr XMappingEvent -> IO ()
    xRefreshKeyboardMapping Ptr XMappingEvent
    event_map_ptr
    foreign import ccall unsafe "HsXlib.h XRefreshKeyboardMapping"
            xRefreshKeyboardMapping :: Ptr XMappingEvent -> IO ()

    -- XSynchronize omitted (returns C function)
    -- XSetAfterFunction omitted (can't pass functions (yet))

    ----------------------------------------------------------------
    -- End
    ----------------------------------------------------------------