gi-gdk-0.3.18.13: GI/Gdk/Structs/EventAny.hs
{- |
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(..) ,
newZeroEventAny ,
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)
-- | Construct a `EventAny` struct initialized to zero.
newZeroEventAny :: MonadIO m => m EventAny
newZeroEventAny = liftIO $ callocBytes 24 >>= wrapPtr 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
type family ResolveEventAnyMethod (t :: Symbol) (o :: *) :: * where
ResolveEventAnyMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveEventAnyMethod t EventAny, MethodInfo info EventAny p) => IsLabelProxy t (EventAny -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveEventAnyMethod t EventAny, MethodInfo info EventAny p) => IsLabel t (EventAny -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif