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

module GI.Gdk.Callbacks
    ( 

 -- * Signals
-- ** EventFunc #signal:EventFunc#
    C_EventFunc                             ,
    EventFunc                               ,
    EventFunc_WithClosures                  ,
    drop_closures_EventFunc                 ,
    dynamic_EventFunc                       ,
    genClosure_EventFunc                    ,
    mk_EventFunc                            ,
    noEventFunc                             ,
    noEventFunc_WithClosures                ,
    wrap_EventFunc                          ,


-- ** FilterFunc #signal:FilterFunc#
    C_FilterFunc                            ,
    FilterFunc                              ,
    FilterFunc_WithClosures                 ,
    drop_closures_FilterFunc                ,
    dynamic_FilterFunc                      ,
    genClosure_FilterFunc                   ,
    mk_FilterFunc                           ,
    noFilterFunc                            ,
    noFilterFunc_WithClosures               ,
    wrap_FilterFunc                         ,


-- ** SeatGrabPrepareFunc #signal:SeatGrabPrepareFunc#
    C_SeatGrabPrepareFunc                   ,
    SeatGrabPrepareFunc                     ,
    SeatGrabPrepareFunc_WithClosures        ,
    drop_closures_SeatGrabPrepareFunc       ,
    dynamic_SeatGrabPrepareFunc             ,
    genClosure_SeatGrabPrepareFunc          ,
    mk_SeatGrabPrepareFunc                  ,
    noSeatGrabPrepareFunc                   ,
    noSeatGrabPrepareFunc_WithClosures      ,
    wrap_SeatGrabPrepareFunc                ,


-- ** WindowChildFunc #signal:WindowChildFunc#
    C_WindowChildFunc                       ,
    WindowChildFunc                         ,
    WindowChildFunc_WithClosures            ,
    drop_closures_WindowChildFunc           ,
    dynamic_WindowChildFunc                 ,
    genClosure_WindowChildFunc              ,
    mk_WindowChildFunc                      ,
    noWindowChildFunc                       ,
    noWindowChildFunc_WithClosures          ,
    wrap_WindowChildFunc                    ,


-- ** WindowInvalidateHandlerFunc #signal:WindowInvalidateHandlerFunc#
    C_WindowInvalidateHandlerFunc           ,
    WindowInvalidateHandlerFunc             ,
    dynamic_WindowInvalidateHandlerFunc     ,
    genClosure_WindowInvalidateHandlerFunc  ,
    mk_WindowInvalidateHandlerFunc          ,
    noWindowInvalidateHandlerFunc           ,
    wrap_WindowInvalidateHandlerFunc        ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.Cairo.Structs.Region as Cairo.Region
import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Objects.Seat as Gdk.Seat
import {-# SOURCE #-} qualified GI.Gdk.Objects.Window as Gdk.Window
import {-# SOURCE #-} qualified GI.Gdk.Unions.Event as Gdk.Event

-- callback WindowInvalidateHandlerFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkWindow", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "region", argType = TInterface (Name {namespace = "cairo", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #cairo_region_t", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Whenever some area of the window is invalidated (directly in the\nwindow or in a child window) this gets called with @region in\nthe coordinate space of @window. You can use @region to just\nkeep track of the dirty region, or you can actually change\n@region in case you are doing display tricks like showing\na child in multiple places.", sinceVersion = Just "3.10"}}
type C_WindowInvalidateHandlerFunc =
    Ptr Gdk.Window.Window ->
    Ptr Cairo.Region.Region ->
    IO ()

-- Args : [Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkWindow", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "region", argType = TInterface (Name {namespace = "cairo", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #cairo_region_t", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_WindowInvalidateHandlerFunc :: FunPtr C_WindowInvalidateHandlerFunc -> C_WindowInvalidateHandlerFunc

dynamic_WindowInvalidateHandlerFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Window.IsWindow a) =>
    FunPtr C_WindowInvalidateHandlerFunc
    -> a
    {- ^ /@window@/: a 'GI.Gdk.Objects.Window.Window' -}
    -> Cairo.Region.Region
    {- ^ /@region@/: a 'GI.Cairo.Structs.Region.Region' -}
    -> m ()
dynamic_WindowInvalidateHandlerFunc __funPtr window region = liftIO $ do
    window' <- unsafeManagedPtrCastPtr window
    region' <- unsafeManagedPtrGetPtr region
    (__dynamic_C_WindowInvalidateHandlerFunc __funPtr) window' region'
    touchManagedPtr window
    touchManagedPtr region
    return ()

foreign import ccall "wrapper"
    mk_WindowInvalidateHandlerFunc :: C_WindowInvalidateHandlerFunc -> IO (FunPtr C_WindowInvalidateHandlerFunc)

type WindowInvalidateHandlerFunc =
    Gdk.Window.Window ->
    Cairo.Region.Region ->
    IO ()

noWindowInvalidateHandlerFunc :: Maybe WindowInvalidateHandlerFunc
noWindowInvalidateHandlerFunc = Nothing

genClosure_WindowInvalidateHandlerFunc :: WindowInvalidateHandlerFunc -> IO Closure
genClosure_WindowInvalidateHandlerFunc cb = do
    let cb' = wrap_WindowInvalidateHandlerFunc Nothing cb
    mk_WindowInvalidateHandlerFunc cb' >>= newCClosure


wrap_WindowInvalidateHandlerFunc ::
    Maybe (Ptr (FunPtr C_WindowInvalidateHandlerFunc)) ->
    WindowInvalidateHandlerFunc ->
    Ptr Gdk.Window.Window ->
    Ptr Cairo.Region.Region ->
    IO ()
wrap_WindowInvalidateHandlerFunc funptrptr _cb window region = do
    window' <- (newObject Gdk.Window.Window) window
    region' <- (newBoxed Cairo.Region.Region) region
    _cb  window' region'
    maybeReleaseFunPtr funptrptr


-- callback WindowChildFunc
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE to invalidate @window recursively", sinceVersion = Nothing}, args = [Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkWindow", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function of this type is passed to gdk_window_invalidate_maybe_recurse().\nIt gets called for each child of the window to determine whether to\nrecursively invalidate it or now.", sinceVersion = Nothing}}
type C_WindowChildFunc =
    Ptr Gdk.Window.Window ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkWindow", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_WindowChildFunc :: FunPtr C_WindowChildFunc -> C_WindowChildFunc

dynamic_WindowChildFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Window.IsWindow a) =>
    FunPtr C_WindowChildFunc
    -> a
    {- ^ /@window@/: a 'GI.Gdk.Objects.Window.Window' -}
    -> Ptr ()
    {- ^ /@userData@/: user data -}
    -> m Bool
    {- ^ __Returns:__ 'True' to invalidate /@window@/ recursively -}
dynamic_WindowChildFunc __funPtr window userData = liftIO $ do
    window' <- unsafeManagedPtrCastPtr window
    result <- (__dynamic_C_WindowChildFunc __funPtr) window' userData
    let result' = (/= 0) result
    touchManagedPtr window
    return result'

foreign import ccall "wrapper"
    mk_WindowChildFunc :: C_WindowChildFunc -> IO (FunPtr C_WindowChildFunc)

type WindowChildFunc =
    Gdk.Window.Window ->
    IO Bool

noWindowChildFunc :: Maybe WindowChildFunc
noWindowChildFunc = Nothing

type WindowChildFunc_WithClosures =
    Gdk.Window.Window ->
    Ptr () ->
    IO Bool

noWindowChildFunc_WithClosures :: Maybe WindowChildFunc_WithClosures
noWindowChildFunc_WithClosures = Nothing

drop_closures_WindowChildFunc :: WindowChildFunc -> WindowChildFunc_WithClosures
drop_closures_WindowChildFunc _f window _ = _f window

genClosure_WindowChildFunc :: WindowChildFunc -> IO Closure
genClosure_WindowChildFunc cb = do
    let cb' = drop_closures_WindowChildFunc cb
    let cb'' = wrap_WindowChildFunc Nothing cb'
    mk_WindowChildFunc cb'' >>= newCClosure


wrap_WindowChildFunc ::
    Maybe (Ptr (FunPtr C_WindowChildFunc)) ->
    WindowChildFunc_WithClosures ->
    Ptr Gdk.Window.Window ->
    Ptr () ->
    IO CInt
wrap_WindowChildFunc funptrptr _cb window userData = do
    window' <- (newObject Gdk.Window.Window) window
    result <- _cb  window' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback SeatGrabPrepareFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkSeat being grabbed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkWindow being grabbed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed in gdk_seat_grab()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Type of the callback used to set up @window so it can be\ngrabbed. A typical action would be ensuring the window is\nvisible, although there's room for other initialization\nactions.", sinceVersion = Just "3.20"}}
type C_SeatGrabPrepareFunc =
    Ptr Gdk.Seat.Seat ->
    Ptr Gdk.Window.Window ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkSeat being grabbed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "window", argType = TInterface (Name {namespace = "Gdk", name = "Window"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkWindow being grabbed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed in gdk_seat_grab()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_SeatGrabPrepareFunc :: FunPtr C_SeatGrabPrepareFunc -> C_SeatGrabPrepareFunc

dynamic_SeatGrabPrepareFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Seat.IsSeat a, Gdk.Window.IsWindow b) =>
    FunPtr C_SeatGrabPrepareFunc
    -> a
    {- ^ /@seat@/: the 'GI.Gdk.Objects.Seat.Seat' being grabbed -}
    -> b
    {- ^ /@window@/: the 'GI.Gdk.Objects.Window.Window' being grabbed -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed in 'GI.Gdk.Objects.Seat.seatGrab' -}
    -> m ()
dynamic_SeatGrabPrepareFunc __funPtr seat window userData = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    window' <- unsafeManagedPtrCastPtr window
    (__dynamic_C_SeatGrabPrepareFunc __funPtr) seat' window' userData
    touchManagedPtr seat
    touchManagedPtr window
    return ()

foreign import ccall "wrapper"
    mk_SeatGrabPrepareFunc :: C_SeatGrabPrepareFunc -> IO (FunPtr C_SeatGrabPrepareFunc)

type SeatGrabPrepareFunc =
    Gdk.Seat.Seat ->
    Gdk.Window.Window ->
    IO ()

noSeatGrabPrepareFunc :: Maybe SeatGrabPrepareFunc
noSeatGrabPrepareFunc = Nothing

type SeatGrabPrepareFunc_WithClosures =
    Gdk.Seat.Seat ->
    Gdk.Window.Window ->
    Ptr () ->
    IO ()

noSeatGrabPrepareFunc_WithClosures :: Maybe SeatGrabPrepareFunc_WithClosures
noSeatGrabPrepareFunc_WithClosures = Nothing

drop_closures_SeatGrabPrepareFunc :: SeatGrabPrepareFunc -> SeatGrabPrepareFunc_WithClosures
drop_closures_SeatGrabPrepareFunc _f seat window _ = _f seat window

genClosure_SeatGrabPrepareFunc :: SeatGrabPrepareFunc -> IO Closure
genClosure_SeatGrabPrepareFunc cb = do
    let cb' = drop_closures_SeatGrabPrepareFunc cb
    let cb'' = wrap_SeatGrabPrepareFunc Nothing cb'
    mk_SeatGrabPrepareFunc cb'' >>= newCClosure


wrap_SeatGrabPrepareFunc ::
    Maybe (Ptr (FunPtr C_SeatGrabPrepareFunc)) ->
    SeatGrabPrepareFunc_WithClosures ->
    Ptr Gdk.Seat.Seat ->
    Ptr Gdk.Window.Window ->
    Ptr () ->
    IO ()
wrap_SeatGrabPrepareFunc funptrptr _cb seat window userData = do
    seat' <- (newObject Gdk.Seat.Seat) seat
    window' <- (newObject Gdk.Window.Window) window
    _cb  seat' window' userData
    maybeReleaseFunPtr funptrptr


-- callback FilterFunc
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Gdk", name = "FilterReturn"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "a #GdkFilterReturn value.", sinceVersion = Nothing}, args = [Arg {argCName = "xevent", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the native event to filter.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gdk", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GDK event to which the X event will be translated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data set when the filter was installed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Specifies the type of function used to filter native events before they are\nconverted to GDK events.\n\nWhen a filter is called, @event is unpopulated, except for\n`event->window`. The filter may translate the native\nevent to a GDK event and store the result in @event, or handle it without\ntranslation. If the filter translates the event and processing should\ncontinue, it should return %GDK_FILTER_TRANSLATE.", sinceVersion = Nothing}}
type C_FilterFunc =
    Ptr () ->
    Ptr Gdk.Event.Event ->
    Ptr () ->
    IO CUInt

-- Args : [Arg {argCName = "xevent", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the native event to filter.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gdk", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GDK event to which the X event will be translated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data set when the filter was installed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "FilterReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_FilterFunc :: FunPtr C_FilterFunc -> C_FilterFunc

dynamic_FilterFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_FilterFunc
    -> Ptr ()
    {- ^ /@xevent@/: the native event to filter. -}
    -> Gdk.Event.Event
    {- ^ /@event@/: the GDK event to which the X event will be translated. -}
    -> Ptr ()
    {- ^ /@data@/: user data set when the filter was installed. -}
    -> m Gdk.Enums.FilterReturn
    {- ^ __Returns:__ a 'GI.Gdk.Enums.FilterReturn' value. -}
dynamic_FilterFunc __funPtr xevent event data_ = liftIO $ do
    event' <- unsafeManagedPtrGetPtr event
    result <- (__dynamic_C_FilterFunc __funPtr) xevent event' data_
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr event
    return result'

foreign import ccall "wrapper"
    mk_FilterFunc :: C_FilterFunc -> IO (FunPtr C_FilterFunc)

type FilterFunc =
    Ptr () ->
    Gdk.Event.Event ->
    IO Gdk.Enums.FilterReturn

noFilterFunc :: Maybe FilterFunc
noFilterFunc = Nothing

type FilterFunc_WithClosures =
    Ptr () ->
    Gdk.Event.Event ->
    Ptr () ->
    IO Gdk.Enums.FilterReturn

noFilterFunc_WithClosures :: Maybe FilterFunc_WithClosures
noFilterFunc_WithClosures = Nothing

drop_closures_FilterFunc :: FilterFunc -> FilterFunc_WithClosures
drop_closures_FilterFunc _f xevent event _ = _f xevent event

genClosure_FilterFunc :: FilterFunc -> IO Closure
genClosure_FilterFunc cb = do
    let cb' = drop_closures_FilterFunc cb
    let cb'' = wrap_FilterFunc Nothing cb'
    mk_FilterFunc cb'' >>= newCClosure


wrap_FilterFunc ::
    Maybe (Ptr (FunPtr C_FilterFunc)) ->
    FilterFunc_WithClosures ->
    Ptr () ->
    Ptr Gdk.Event.Event ->
    Ptr () ->
    IO CUInt
wrap_FilterFunc funptrptr _cb xevent event data_ = do
    event' <- (newBoxed Gdk.Event.Event) event
    result <- _cb  xevent event' data_
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback EventFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "event", argType = TInterface (Name {namespace = "Gdk", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkEvent to process.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data set when the event handler was installed with\n  gdk_event_handler_set().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Specifies the type of function passed to gdk_event_handler_set() to\nhandle all GDK events.", sinceVersion = Nothing}}
type C_EventFunc =
    Ptr Gdk.Event.Event ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "event", argType = TInterface (Name {namespace = "Gdk", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkEvent to process.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data set when the event handler was installed with\n  gdk_event_handler_set().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_EventFunc :: FunPtr C_EventFunc -> C_EventFunc

dynamic_EventFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_EventFunc
    -> Gdk.Event.Event
    {- ^ /@event@/: the 'GI.Gdk.Unions.Event.Event' to process. -}
    -> Ptr ()
    {- ^ /@data@/: user data set when the event handler was installed with
  'GI.Gdk.Functions.eventHandlerSet'. -}
    -> m ()
dynamic_EventFunc __funPtr event data_ = liftIO $ do
    event' <- unsafeManagedPtrGetPtr event
    (__dynamic_C_EventFunc __funPtr) event' data_
    touchManagedPtr event
    return ()

foreign import ccall "wrapper"
    mk_EventFunc :: C_EventFunc -> IO (FunPtr C_EventFunc)

type EventFunc =
    Gdk.Event.Event ->
    IO ()

noEventFunc :: Maybe EventFunc
noEventFunc = Nothing

type EventFunc_WithClosures =
    Gdk.Event.Event ->
    Ptr () ->
    IO ()

noEventFunc_WithClosures :: Maybe EventFunc_WithClosures
noEventFunc_WithClosures = Nothing

drop_closures_EventFunc :: EventFunc -> EventFunc_WithClosures
drop_closures_EventFunc _f event _ = _f event

genClosure_EventFunc :: EventFunc -> IO Closure
genClosure_EventFunc cb = do
    let cb' = drop_closures_EventFunc cb
    let cb'' = wrap_EventFunc Nothing cb'
    mk_EventFunc cb'' >>= newCClosure


wrap_EventFunc ::
    Maybe (Ptr (FunPtr C_EventFunc)) ->
    EventFunc_WithClosures ->
    Ptr Gdk.Event.Event ->
    Ptr () ->
    IO ()
wrap_EventFunc funptrptr _cb event data_ = do
    event' <- (newBoxed Gdk.Event.Event) event
    _cb  event' data_
    maybeReleaseFunPtr funptrptr