{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Contains the fields which are common to all event structs.
Any event pointer can safely be cast to a pointer to a #GdkEventAny to
access these fields.
-}

module GI.Gdk.Structs.EventAny
    ( 

-- * Exported types
    EventAny(..)                            ,
    noEventAny                              ,


 -- * Properties
-- ** SendEvent
    eventAnyReadSendEvent                   ,


-- ** Type
    eventAnyReadType                        ,


-- ** Window
    eventAnyReadWindow                      ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gdk.Types
import GI.Gdk.Callbacks

newtype EventAny = EventAny (ForeignPtr EventAny)
noEventAny :: Maybe EventAny
noEventAny = Nothing

eventAnyReadType :: EventAny -> IO EventType
eventAnyReadType s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

eventAnyReadWindow :: EventAny -> IO Window
eventAnyReadWindow s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (Ptr Window)
    val' <- (newObject Window) val
    return val'

eventAnyReadSendEvent :: EventAny -> IO Int8
eventAnyReadSendEvent s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int8
    return val