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

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

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

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

get_Window :: XEventPtr -> IO Window
get_Window :: XEventPtr -> IO Window
get_Window = (\XEventPtr
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff XEventPtr
hsc_ptr Int
32)
{-# LINE 116 "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 -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
40) Ptr XKeyEvent
p
{-# LINE 139 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
subwindow       <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
48) Ptr XKeyEvent
p
{-# LINE 140 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
time            <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
56) Ptr XKeyEvent
p
{-# LINE 141 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x               <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
64) Ptr XKeyEvent
p
{-# LINE 142 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y               <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
68) Ptr XKeyEvent
p
{-# LINE 143 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x_root          <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
72) Ptr XKeyEvent
p
{-# LINE 144 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y_root          <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
76) Ptr XKeyEvent
p
{-# LINE 145 "Graphics/X11/Xlib/Event.hsc" #-}
        Modifier
state           <- ((\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
80) Ptr XKeyEvent
p) :: IO CUInt
{-# LINE 146 "Graphics/X11/Xlib/Event.hsc" #-}
        Modifier
keycode         <- ((\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
84) Ptr XKeyEvent
p) :: IO CUInt
{-# LINE 147 "Graphics/X11/Xlib/Event.hsc" #-}
        Bool
same_screen     <- (\Ptr XKeyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XKeyEvent
hsc_ptr Int
88) Ptr XKeyEvent
p
{-# LINE 148 "Graphics/X11/Xlib/Event.hsc" #-}
        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,
                forall a b. (Integral a, Num b) => a -> b
fromIntegral Modifier
state, 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 (forall a b. Ptr a -> Ptr b
castPtr XEventPtr
p)

type XKeyEventPtr   = Ptr XKeyEvent

asKeyEvent :: XEventPtr -> XKeyEventPtr
asKeyEvent :: XEventPtr -> Ptr XKeyEvent
asKeyEvent = 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 -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
40) Ptr XButtonEvent
p
{-# LINE 175 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
subwindow       <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
48) Ptr XButtonEvent
p
{-# LINE 176 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
time            <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
56) Ptr XButtonEvent
p
{-# LINE 177 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x               <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
64) Ptr XButtonEvent
p
{-# LINE 178 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y               <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
68) Ptr XButtonEvent
p
{-# LINE 179 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x_root          <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
72) Ptr XButtonEvent
p
{-# LINE 180 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y_root          <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
76) Ptr XButtonEvent
p
{-# LINE 181 "Graphics/X11/Xlib/Event.hsc" #-}
        Modifier
state           <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
80) Ptr XButtonEvent
p
{-# LINE 182 "Graphics/X11/Xlib/Event.hsc" #-}
        Word32
button          <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
84) Ptr XButtonEvent
p
{-# LINE 183 "Graphics/X11/Xlib/Event.hsc" #-}
        Bool
same_screen     <- (\Ptr XButtonEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XButtonEvent
hsc_ptr Int
88) Ptr XButtonEvent
p
{-# LINE 184 "Graphics/X11/Xlib/Event.hsc" #-}
        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 (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 -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
40) Ptr XMotionEvent
p
{-# LINE 206 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
subwindow       <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
48) Ptr XMotionEvent
p
{-# LINE 207 "Graphics/X11/Xlib/Event.hsc" #-}
        Window
time            <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
56) Ptr XMotionEvent
p
{-# LINE 208 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x               <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
64) Ptr XMotionEvent
p
{-# LINE 209 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y               <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
68) Ptr XMotionEvent
p
{-# LINE 210 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
x_root          <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
72) Ptr XMotionEvent
p
{-# LINE 211 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
y_root          <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
76) Ptr XMotionEvent
p
{-# LINE 212 "Graphics/X11/Xlib/Event.hsc" #-}
        Modifier
state           <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
80) Ptr XMotionEvent
p
{-# LINE 213 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
is_hint         <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
84) Ptr XMotionEvent
p
{-# LINE 214 "Graphics/X11/Xlib/Event.hsc" #-}
        Bool
same_screen     <- (\Ptr XMotionEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XMotionEvent
hsc_ptr Int
88) Ptr XMotionEvent
p
{-# LINE 215 "Graphics/X11/Xlib/Event.hsc" #-}
        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 (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 -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XExposeEvent
hsc_ptr Int
40) Ptr XExposeEvent
p
{-# LINE 257 "Graphics/X11/Xlib/Event.hsc" #-}
        Position
y       <- (\Ptr XExposeEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XExposeEvent
hsc_ptr Int
44) Ptr XExposeEvent
p
{-# LINE 258 "Graphics/X11/Xlib/Event.hsc" #-}
        Word32
width   <- (\Ptr XExposeEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XExposeEvent
hsc_ptr Int
48) Ptr XExposeEvent
p
{-# LINE 259 "Graphics/X11/Xlib/Event.hsc" #-}
        Word32
height  <- (\Ptr XExposeEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XExposeEvent
hsc_ptr Int
52) Ptr XExposeEvent
p
{-# LINE 260 "Graphics/X11/Xlib/Event.hsc" #-}
        CInt
count   <- (\Ptr XExposeEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XExposeEvent
hsc_ptr Int
56) Ptr XExposeEvent
p
{-# LINE 261 "Graphics/X11/Xlib/Event.hsc" #-}
        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 (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 =
        forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
56) forall a b. (a -> b) -> a -> b
$ \ Ptr XMappingEvent
event_map_ptr -> do
{-# LINE 318 "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 -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XMappingEvent
hsc_ptr Int
40)           Ptr XMappingEvent
p CInt
request
{-# LINE 324 "Graphics/X11/Xlib/Event.hsc" #-}
        (\Ptr XMappingEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XMappingEvent
hsc_ptr Int
44)     Ptr XMappingEvent
p KeyCode
first_keycode
{-# LINE 325 "Graphics/X11/Xlib/Event.hsc" #-}
        (\Ptr XMappingEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XMappingEvent
hsc_ptr Int
48)             Ptr XMappingEvent
p CInt
count
{-# LINE 326 "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 -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XConfigureEvent
hsc_ptr Int
48) Ptr XConfigureEvent
p
{-# LINE 337 "Graphics/X11/Xlib/Event.hsc" #-}
        Position
y       <- (\Ptr XConfigureEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XConfigureEvent
hsc_ptr Int
52) Ptr XConfigureEvent
p
{-# LINE 338 "Graphics/X11/Xlib/Event.hsc" #-}
        Word32
width   <- (\Ptr XConfigureEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XConfigureEvent
hsc_ptr Int
56) Ptr XConfigureEvent
p
{-# LINE 339 "Graphics/X11/Xlib/Event.hsc" #-}
        Word32
height  <- (\Ptr XConfigureEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XConfigureEvent
hsc_ptr Int
60) Ptr XConfigureEvent
p
{-# LINE 340 "Graphics/X11/Xlib/Event.hsc" #-}
        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 (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 =
        forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with (CLong -> CLong -> TimeVal
TimeVal (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
usecs forall a. Integral a => a -> a -> a
`div` CLong
1000000) (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
usecs forall a. Integral a => a -> a -> a
`mod` CLong
1000000)) forall a b. (a -> b) -> a -> b
$ \ Ptr TimeVal
tv_ptr ->
        forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
128) forall a b. (a -> b) -> a -> b
$ \ Ptr FdSet
readfds ->
{-# LINE 404 "Graphics/X11/Xlib/Event.hsc" #-}
        forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
128) forall a b. (a -> b) -> a -> b
$ \ Ptr FdSet
nofds -> do
{-# LINE 405 "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 (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 ((forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
fd)forall a. Num a => a -> a -> a
+CInt
1) Ptr FdSet
readfds Ptr FdSet
nofds Ptr FdSet
nofds Ptr TimeVal
tv_ptr
        forall (m :: * -> *) a. Monad m => a -> m a
return (CInt
n forall a. Eq a => a -> a -> Bool
== CInt
0)

newtype FdSet = FdSet (Ptr FdSet)

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

{-# LINE 418 "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 =
        forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \ Ptr TimeVal
tv_ptr -> do
        ()
_rc <- Ptr TimeVal -> Ptr TimeZone -> IO ()
gettimeofday Ptr TimeVal
tv_ptr forall a. Ptr a
nullPtr
        TimeVal CLong
sec CLong
usec <- forall a. Storable a => Ptr a -> IO a
peek Ptr TimeVal
tv_ptr
        forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Integral a => a -> Integer
toInteger CLong
sec forall a. Num a => a -> a -> a
* Integer
1000 forall a. Num a => a -> a -> a
+ forall a. Integral a => a -> Integer
toInteger CLong
usec forall a. Integral a => a -> a -> a
`div` Integer
1000)

data TimeVal = TimeVal CLong CLong

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

newtype TimeZone = TimeZone (Ptr TimeZone)

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

{-# LINE 452 "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" 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 =
        forall a. XMappingEvent -> (Ptr XMappingEvent -> IO a) -> IO a
withXMappingEvent XMappingEvent
event_map 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
----------------------------------------------------------------