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

The 'GI.Gdk.Objects.Seat.Seat' object represents a collection of input devices
that belong to a user.
-}

module GI.Gdk.Objects.Seat
    ( 

-- * Exported types
    Seat(..)                                ,
    IsSeat                                  ,
    toSeat                                  ,
    noSeat                                  ,


 -- * Methods
-- ** getCapabilities #method:getCapabilities#
    SeatGetCapabilitiesMethodInfo           ,
    seatGetCapabilities                     ,


-- ** getDisplay #method:getDisplay#
    SeatGetDisplayMethodInfo                ,
    seatGetDisplay                          ,


-- ** getKeyboard #method:getKeyboard#
    SeatGetKeyboardMethodInfo               ,
    seatGetKeyboard                         ,


-- ** getPointer #method:getPointer#
    SeatGetPointerMethodInfo                ,
    seatGetPointer                          ,


-- ** getSlaves #method:getSlaves#
    SeatGetSlavesMethodInfo                 ,
    seatGetSlaves                           ,


-- ** grab #method:grab#
    SeatGrabMethodInfo                      ,
    seatGrab                                ,


-- ** ungrab #method:ungrab#
    SeatUngrabMethodInfo                    ,
    seatUngrab                              ,




 -- * Properties
-- ** display #attr:display#
    SeatDisplayPropertyInfo                 ,
    constructSeatDisplay                    ,
    getSeatDisplay                          ,
    seatDisplay                             ,




 -- * Signals
-- ** deviceAdded #signal:deviceAdded#
    C_SeatDeviceAddedCallback               ,
    SeatDeviceAddedCallback                 ,
    SeatDeviceAddedSignalInfo               ,
    afterSeatDeviceAdded                    ,
    genClosure_SeatDeviceAdded              ,
    mk_SeatDeviceAddedCallback              ,
    noSeatDeviceAddedCallback               ,
    onSeatDeviceAdded                       ,
    wrap_SeatDeviceAddedCallback            ,


-- ** deviceRemoved #signal:deviceRemoved#
    C_SeatDeviceRemovedCallback             ,
    SeatDeviceRemovedCallback               ,
    SeatDeviceRemovedSignalInfo             ,
    afterSeatDeviceRemoved                  ,
    genClosure_SeatDeviceRemoved            ,
    mk_SeatDeviceRemovedCallback            ,
    noSeatDeviceRemovedCallback             ,
    onSeatDeviceRemoved                     ,
    wrap_SeatDeviceRemovedCallback          ,


-- ** toolAdded #signal:toolAdded#
    C_SeatToolAddedCallback                 ,
    SeatToolAddedCallback                   ,
    SeatToolAddedSignalInfo                 ,
    afterSeatToolAdded                      ,
    genClosure_SeatToolAdded                ,
    mk_SeatToolAddedCallback                ,
    noSeatToolAddedCallback                 ,
    onSeatToolAdded                         ,
    wrap_SeatToolAddedCallback              ,


-- ** toolRemoved #signal:toolRemoved#
    C_SeatToolRemovedCallback               ,
    SeatToolRemovedCallback                 ,
    SeatToolRemovedSignalInfo               ,
    afterSeatToolRemoved                    ,
    genClosure_SeatToolRemoved              ,
    mk_SeatToolRemovedCallback              ,
    noSeatToolRemovedCallback               ,
    onSeatToolRemoved                       ,
    wrap_SeatToolRemovedCallback            ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Callbacks as Gdk.Callbacks
import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Flags as Gdk.Flags
import {-# SOURCE #-} qualified GI.Gdk.Objects.Cursor as Gdk.Cursor
import {-# SOURCE #-} qualified GI.Gdk.Objects.Device as Gdk.Device
import {-# SOURCE #-} qualified GI.Gdk.Objects.DeviceTool as Gdk.DeviceTool
import {-# SOURCE #-} qualified GI.Gdk.Objects.Display as Gdk.Display
import {-# SOURCE #-} qualified GI.Gdk.Objects.Window as Gdk.Window
import {-# SOURCE #-} qualified GI.Gdk.Unions.Event as Gdk.Event

newtype Seat = Seat (ManagedPtr Seat)
foreign import ccall "gdk_seat_get_type"
    c_gdk_seat_get_type :: IO GType

instance GObject Seat where
    gobjectType _ = c_gdk_seat_get_type
    

class GObject o => IsSeat o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Seat a) =>
    IsSeat a
#endif
instance IsSeat Seat
instance GObject.Object.IsObject Seat

toSeat :: IsSeat o => o -> IO Seat
toSeat = unsafeCastTo Seat

noSeat :: Maybe Seat
noSeat = Nothing

type family ResolveSeatMethod (t :: Symbol) (o :: *) :: * where
    ResolveSeatMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSeatMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSeatMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSeatMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSeatMethod "grab" o = SeatGrabMethodInfo
    ResolveSeatMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSeatMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSeatMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSeatMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSeatMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSeatMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveSeatMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveSeatMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSeatMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSeatMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSeatMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSeatMethod "ungrab" o = SeatUngrabMethodInfo
    ResolveSeatMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSeatMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSeatMethod "getCapabilities" o = SeatGetCapabilitiesMethodInfo
    ResolveSeatMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSeatMethod "getDisplay" o = SeatGetDisplayMethodInfo
    ResolveSeatMethod "getKeyboard" o = SeatGetKeyboardMethodInfo
    ResolveSeatMethod "getPointer" o = SeatGetPointerMethodInfo
    ResolveSeatMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSeatMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSeatMethod "getSlaves" o = SeatGetSlavesMethodInfo
    ResolveSeatMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSeatMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSeatMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSeatMethod t Seat, O.MethodInfo info Seat p) => O.IsLabelProxy t (Seat -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveSeatMethod t Seat, O.MethodInfo info Seat p) => O.IsLabel t (Seat -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal Seat::device-added
type SeatDeviceAddedCallback =
    Gdk.Device.Device ->
    IO ()

noSeatDeviceAddedCallback :: Maybe SeatDeviceAddedCallback
noSeatDeviceAddedCallback = Nothing

type C_SeatDeviceAddedCallback =
    Ptr () ->                               -- object
    Ptr Gdk.Device.Device ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_SeatDeviceAddedCallback :: C_SeatDeviceAddedCallback -> IO (FunPtr C_SeatDeviceAddedCallback)

genClosure_SeatDeviceAdded :: SeatDeviceAddedCallback -> IO Closure
genClosure_SeatDeviceAdded cb = do
    let cb' = wrap_SeatDeviceAddedCallback cb
    mk_SeatDeviceAddedCallback cb' >>= newCClosure


wrap_SeatDeviceAddedCallback ::
    SeatDeviceAddedCallback ->
    Ptr () ->
    Ptr Gdk.Device.Device ->
    Ptr () ->
    IO ()
wrap_SeatDeviceAddedCallback _cb _ device _ = do
    device' <- (newObject Gdk.Device.Device) device
    _cb  device'


onSeatDeviceAdded :: (GObject a, MonadIO m) => a -> SeatDeviceAddedCallback -> m SignalHandlerId
onSeatDeviceAdded obj cb = liftIO $ connectSeatDeviceAdded obj cb SignalConnectBefore
afterSeatDeviceAdded :: (GObject a, MonadIO m) => a -> SeatDeviceAddedCallback -> m SignalHandlerId
afterSeatDeviceAdded obj cb = connectSeatDeviceAdded obj cb SignalConnectAfter

connectSeatDeviceAdded :: (GObject a, MonadIO m) =>
                          a -> SeatDeviceAddedCallback -> SignalConnectMode -> m SignalHandlerId
connectSeatDeviceAdded obj cb after = liftIO $ do
    let cb' = wrap_SeatDeviceAddedCallback cb
    cb'' <- mk_SeatDeviceAddedCallback cb'
    connectSignalFunPtr obj "device-added" cb'' after

-- signal Seat::device-removed
type SeatDeviceRemovedCallback =
    Gdk.Device.Device ->
    IO ()

noSeatDeviceRemovedCallback :: Maybe SeatDeviceRemovedCallback
noSeatDeviceRemovedCallback = Nothing

type C_SeatDeviceRemovedCallback =
    Ptr () ->                               -- object
    Ptr Gdk.Device.Device ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_SeatDeviceRemovedCallback :: C_SeatDeviceRemovedCallback -> IO (FunPtr C_SeatDeviceRemovedCallback)

genClosure_SeatDeviceRemoved :: SeatDeviceRemovedCallback -> IO Closure
genClosure_SeatDeviceRemoved cb = do
    let cb' = wrap_SeatDeviceRemovedCallback cb
    mk_SeatDeviceRemovedCallback cb' >>= newCClosure


wrap_SeatDeviceRemovedCallback ::
    SeatDeviceRemovedCallback ->
    Ptr () ->
    Ptr Gdk.Device.Device ->
    Ptr () ->
    IO ()
wrap_SeatDeviceRemovedCallback _cb _ device _ = do
    device' <- (newObject Gdk.Device.Device) device
    _cb  device'


onSeatDeviceRemoved :: (GObject a, MonadIO m) => a -> SeatDeviceRemovedCallback -> m SignalHandlerId
onSeatDeviceRemoved obj cb = liftIO $ connectSeatDeviceRemoved obj cb SignalConnectBefore
afterSeatDeviceRemoved :: (GObject a, MonadIO m) => a -> SeatDeviceRemovedCallback -> m SignalHandlerId
afterSeatDeviceRemoved obj cb = connectSeatDeviceRemoved obj cb SignalConnectAfter

connectSeatDeviceRemoved :: (GObject a, MonadIO m) =>
                            a -> SeatDeviceRemovedCallback -> SignalConnectMode -> m SignalHandlerId
connectSeatDeviceRemoved obj cb after = liftIO $ do
    let cb' = wrap_SeatDeviceRemovedCallback cb
    cb'' <- mk_SeatDeviceRemovedCallback cb'
    connectSignalFunPtr obj "device-removed" cb'' after

-- signal Seat::tool-added
type SeatToolAddedCallback =
    Gdk.DeviceTool.DeviceTool ->
    IO ()

noSeatToolAddedCallback :: Maybe SeatToolAddedCallback
noSeatToolAddedCallback = Nothing

type C_SeatToolAddedCallback =
    Ptr () ->                               -- object
    Ptr Gdk.DeviceTool.DeviceTool ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_SeatToolAddedCallback :: C_SeatToolAddedCallback -> IO (FunPtr C_SeatToolAddedCallback)

genClosure_SeatToolAdded :: SeatToolAddedCallback -> IO Closure
genClosure_SeatToolAdded cb = do
    let cb' = wrap_SeatToolAddedCallback cb
    mk_SeatToolAddedCallback cb' >>= newCClosure


wrap_SeatToolAddedCallback ::
    SeatToolAddedCallback ->
    Ptr () ->
    Ptr Gdk.DeviceTool.DeviceTool ->
    Ptr () ->
    IO ()
wrap_SeatToolAddedCallback _cb _ tool _ = do
    tool' <- (newObject Gdk.DeviceTool.DeviceTool) tool
    _cb  tool'


onSeatToolAdded :: (GObject a, MonadIO m) => a -> SeatToolAddedCallback -> m SignalHandlerId
onSeatToolAdded obj cb = liftIO $ connectSeatToolAdded obj cb SignalConnectBefore
afterSeatToolAdded :: (GObject a, MonadIO m) => a -> SeatToolAddedCallback -> m SignalHandlerId
afterSeatToolAdded obj cb = connectSeatToolAdded obj cb SignalConnectAfter

connectSeatToolAdded :: (GObject a, MonadIO m) =>
                        a -> SeatToolAddedCallback -> SignalConnectMode -> m SignalHandlerId
connectSeatToolAdded obj cb after = liftIO $ do
    let cb' = wrap_SeatToolAddedCallback cb
    cb'' <- mk_SeatToolAddedCallback cb'
    connectSignalFunPtr obj "tool-added" cb'' after

-- signal Seat::tool-removed
type SeatToolRemovedCallback =
    Gdk.DeviceTool.DeviceTool ->
    IO ()

noSeatToolRemovedCallback :: Maybe SeatToolRemovedCallback
noSeatToolRemovedCallback = Nothing

type C_SeatToolRemovedCallback =
    Ptr () ->                               -- object
    Ptr Gdk.DeviceTool.DeviceTool ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_SeatToolRemovedCallback :: C_SeatToolRemovedCallback -> IO (FunPtr C_SeatToolRemovedCallback)

genClosure_SeatToolRemoved :: SeatToolRemovedCallback -> IO Closure
genClosure_SeatToolRemoved cb = do
    let cb' = wrap_SeatToolRemovedCallback cb
    mk_SeatToolRemovedCallback cb' >>= newCClosure


wrap_SeatToolRemovedCallback ::
    SeatToolRemovedCallback ->
    Ptr () ->
    Ptr Gdk.DeviceTool.DeviceTool ->
    Ptr () ->
    IO ()
wrap_SeatToolRemovedCallback _cb _ tool _ = do
    tool' <- (newObject Gdk.DeviceTool.DeviceTool) tool
    _cb  tool'


onSeatToolRemoved :: (GObject a, MonadIO m) => a -> SeatToolRemovedCallback -> m SignalHandlerId
onSeatToolRemoved obj cb = liftIO $ connectSeatToolRemoved obj cb SignalConnectBefore
afterSeatToolRemoved :: (GObject a, MonadIO m) => a -> SeatToolRemovedCallback -> m SignalHandlerId
afterSeatToolRemoved obj cb = connectSeatToolRemoved obj cb SignalConnectAfter

connectSeatToolRemoved :: (GObject a, MonadIO m) =>
                          a -> SeatToolRemovedCallback -> SignalConnectMode -> m SignalHandlerId
connectSeatToolRemoved obj cb after = liftIO $ do
    let cb' = wrap_SeatToolRemovedCallback cb
    cb'' <- mk_SeatToolRemovedCallback cb'
    connectSignalFunPtr obj "tool-removed" cb'' after

-- VVV Prop "display"
   -- Type: TInterface (Name {namespace = "Gdk", name = "Display"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getSeatDisplay :: (MonadIO m, IsSeat o) => o -> m Gdk.Display.Display
getSeatDisplay obj = liftIO $ checkUnexpectedNothing "getSeatDisplay" $ getObjectPropertyObject obj "display" Gdk.Display.Display

constructSeatDisplay :: (IsSeat o, Gdk.Display.IsDisplay a) => a -> IO (GValueConstruct o)
constructSeatDisplay val = constructObjectPropertyObject "display" (Just val)

data SeatDisplayPropertyInfo
instance AttrInfo SeatDisplayPropertyInfo where
    type AttrAllowedOps SeatDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SeatDisplayPropertyInfo = Gdk.Display.IsDisplay
    type AttrBaseTypeConstraint SeatDisplayPropertyInfo = IsSeat
    type AttrGetType SeatDisplayPropertyInfo = Gdk.Display.Display
    type AttrLabel SeatDisplayPropertyInfo = "display"
    type AttrOrigin SeatDisplayPropertyInfo = Seat
    attrGet _ = getSeatDisplay
    attrSet _ = undefined
    attrConstruct _ = constructSeatDisplay
    attrClear _ = undefined

instance O.HasAttributeList Seat
type instance O.AttributeList Seat = SeatAttributeList
type SeatAttributeList = ('[ '("display", SeatDisplayPropertyInfo)] :: [(Symbol, *)])

seatDisplay :: AttrLabelProxy "display"
seatDisplay = AttrLabelProxy

data SeatDeviceAddedSignalInfo
instance SignalInfo SeatDeviceAddedSignalInfo where
    type HaskellCallbackType SeatDeviceAddedSignalInfo = SeatDeviceAddedCallback
    connectSignal _ = connectSeatDeviceAdded

data SeatDeviceRemovedSignalInfo
instance SignalInfo SeatDeviceRemovedSignalInfo where
    type HaskellCallbackType SeatDeviceRemovedSignalInfo = SeatDeviceRemovedCallback
    connectSignal _ = connectSeatDeviceRemoved

data SeatToolAddedSignalInfo
instance SignalInfo SeatToolAddedSignalInfo where
    type HaskellCallbackType SeatToolAddedSignalInfo = SeatToolAddedCallback
    connectSignal _ = connectSeatToolAdded

data SeatToolRemovedSignalInfo
instance SignalInfo SeatToolRemovedSignalInfo where
    type HaskellCallbackType SeatToolRemovedSignalInfo = SeatToolRemovedCallback
    connectSignal _ = connectSeatToolRemoved

type instance O.SignalList Seat = SeatSignalList
type SeatSignalList = ('[ '("deviceAdded", SeatDeviceAddedSignalInfo), '("deviceRemoved", SeatDeviceRemovedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("toolAdded", SeatToolAddedSignalInfo), '("toolRemoved", SeatToolRemovedSignalInfo)] :: [(Symbol, *)])

-- method Seat::get_capabilities
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "SeatCapabilities"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_get_capabilities" gdk_seat_get_capabilities :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    IO CUInt

{- |
Returns the capabilities this 'GI.Gdk.Objects.Seat.Seat' currently has.

@since 3.20
-}
seatGetCapabilities ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> m [Gdk.Flags.SeatCapabilities]
    {- ^ __Returns:__ the seat capabilities -}
seatGetCapabilities seat = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    result <- gdk_seat_get_capabilities seat'
    let result' = wordToGFlags result
    touchManagedPtr seat
    return result'

data SeatGetCapabilitiesMethodInfo
instance (signature ~ (m [Gdk.Flags.SeatCapabilities]), MonadIO m, IsSeat a) => O.MethodInfo SeatGetCapabilitiesMethodInfo a signature where
    overloadedMethod _ = seatGetCapabilities

-- method Seat::get_display
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Display"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_get_display" gdk_seat_get_display :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    IO (Ptr Gdk.Display.Display)

{- |
Returns the 'GI.Gdk.Objects.Display.Display' this seat belongs to.
-}
seatGetDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> m Gdk.Display.Display
    {- ^ __Returns:__ a 'GI.Gdk.Objects.Display.Display'. This object is owned by GTK+
         and must not be freed. -}
seatGetDisplay seat = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    result <- gdk_seat_get_display seat'
    checkUnexpectedReturnNULL "seatGetDisplay" result
    result' <- (newObject Gdk.Display.Display) result
    touchManagedPtr seat
    return result'

data SeatGetDisplayMethodInfo
instance (signature ~ (m Gdk.Display.Display), MonadIO m, IsSeat a) => O.MethodInfo SeatGetDisplayMethodInfo a signature where
    overloadedMethod _ = seatGetDisplay

-- method Seat::get_keyboard
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Device"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_get_keyboard" gdk_seat_get_keyboard :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    IO (Ptr Gdk.Device.Device)

{- |
Returns the master device that routes keyboard events.

@since 3.20
-}
seatGetKeyboard ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> m (Maybe Gdk.Device.Device)
    {- ^ __Returns:__ a master 'GI.Gdk.Objects.Device.Device' with keyboard
         capabilities. This object is owned by GTK+ and must not be freed. -}
seatGetKeyboard seat = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    result <- gdk_seat_get_keyboard seat'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Device.Device) result'
        return result''
    touchManagedPtr seat
    return maybeResult

data SeatGetKeyboardMethodInfo
instance (signature ~ (m (Maybe Gdk.Device.Device)), MonadIO m, IsSeat a) => O.MethodInfo SeatGetKeyboardMethodInfo a signature where
    overloadedMethod _ = seatGetKeyboard

-- method Seat::get_pointer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Device"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_get_pointer" gdk_seat_get_pointer :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    IO (Ptr Gdk.Device.Device)

{- |
Returns the master device that routes pointer events.

@since 3.20
-}
seatGetPointer ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> m (Maybe Gdk.Device.Device)
    {- ^ __Returns:__ a master 'GI.Gdk.Objects.Device.Device' with pointer
         capabilities. This object is owned by GTK+ and must not be freed. -}
seatGetPointer seat = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    result <- gdk_seat_get_pointer seat'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Device.Device) result'
        return result''
    touchManagedPtr seat
    return maybeResult

data SeatGetPointerMethodInfo
instance (signature ~ (m (Maybe Gdk.Device.Device)), MonadIO m, IsSeat a) => O.MethodInfo SeatGetPointerMethodInfo a signature where
    overloadedMethod _ = seatGetPointer

-- method Seat::get_slaves
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "capabilities", argType = TInterface (Name {namespace = "Gdk", name = "SeatCapabilities"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "capabilities to get devices for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gdk", name = "Device"})))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_get_slaves" gdk_seat_get_slaves :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    CUInt ->                                -- capabilities : TInterface (Name {namespace = "Gdk", name = "SeatCapabilities"})
    IO (Ptr (GList (Ptr Gdk.Device.Device)))

{- |
Returns the slave devices that match the given capabilities.

@since 3.20
-}
seatGetSlaves ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> [Gdk.Flags.SeatCapabilities]
    {- ^ /@capabilities@/: capabilities to get devices for -}
    -> m [Gdk.Device.Device]
    {- ^ __Returns:__ A list of @/GdkDevices/@.
         The list must be freed with @/g_list_free()/@, the elements are owned
         by GDK and must not be freed. -}
seatGetSlaves seat capabilities = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    let capabilities' = gflagsToWord capabilities
    result <- gdk_seat_get_slaves seat' capabilities'
    result' <- unpackGList result
    result'' <- mapM (newObject Gdk.Device.Device) result'
    g_list_free result
    touchManagedPtr seat
    return result''

data SeatGetSlavesMethodInfo
instance (signature ~ ([Gdk.Flags.SeatCapabilities] -> m [Gdk.Device.Device]), MonadIO m, IsSeat a) => O.MethodInfo SeatGetSlavesMethodInfo a signature where
    overloadedMethod _ = seatGetSlaves

-- method Seat::grab
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", 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 which will own the grab", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "capabilities", argType = TInterface (Name {namespace = "Gdk", name = "SeatCapabilities"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "capabilities that will be grabbed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "owner_events", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if %FALSE then all device events are reported with respect to\n               @window and are only reported if selected by @event_mask. If\n               %TRUE then pointer events for this application are reported\n               as normal, but pointer events outside this application are\n               reported with respect to @window and only if selected by\n               @event_mask. In either mode, unreported events are discarded.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cursor", argType = TInterface (Name {namespace = "Gdk", name = "Cursor"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the cursor to display while the grab is active. If\n         this is %NULL then the normal cursors are used for\n         @window and its descendants, and the cursor for @window is used\n         elsewhere.", 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 = True, argDoc = Documentation {rawDocText = Just "the event that is triggering the grab, or %NULL if none\n        is available.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "prepare_func", argType = TInterface (Name {namespace = "Gdk", name = "SeatGrabPrepareFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to\n               prepare the window to be grabbed, it can be %NULL if @window is\n               visible before this call.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 7, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "prepare_func_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @prepare_func", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "GrabStatus"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_grab" gdk_seat_grab :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    Ptr Gdk.Window.Window ->                -- window : TInterface (Name {namespace = "Gdk", name = "Window"})
    CUInt ->                                -- capabilities : TInterface (Name {namespace = "Gdk", name = "SeatCapabilities"})
    CInt ->                                 -- owner_events : TBasicType TBoolean
    Ptr Gdk.Cursor.Cursor ->                -- cursor : TInterface (Name {namespace = "Gdk", name = "Cursor"})
    Ptr Gdk.Event.Event ->                  -- event : TInterface (Name {namespace = "Gdk", name = "Event"})
    FunPtr Gdk.Callbacks.C_SeatGrabPrepareFunc -> -- prepare_func : TInterface (Name {namespace = "Gdk", name = "SeatGrabPrepareFunc"})
    Ptr () ->                               -- prepare_func_data : TBasicType TPtr
    IO CUInt

{- |
Grabs the seat so that all events corresponding to the given /@capabilities@/
are passed to this application until the seat is ungrabbed with 'GI.Gdk.Objects.Seat.seatUngrab',
or the window becomes hidden. This overrides any previous grab on the
seat by this client.

As a rule of thumb, if a grab is desired over 'GI.Gdk.Flags.SeatCapabilitiesPointer',
all other \"pointing\" capabilities (eg. 'GI.Gdk.Flags.SeatCapabilitiesTouch') should
be grabbed too, so the user is able to interact with all of those while
the grab holds, you should thus use 'GI.Gdk.Flags.SeatCapabilitiesAllPointing' most
commonly.

Grabs are used for operations which need complete control over the
events corresponding to the given capabilities. For example in GTK+ this
is used for Drag and Drop operations, popup menus and such.

Note that if the event mask of a 'GI.Gdk.Objects.Window.Window' has selected both button press
and button release events, or touch begin and touch end, then a press event
will cause an automatic grab until the button is released, equivalent to a
grab on the window with /@ownerEvents@/ set to 'True'. This is done because most
applications expect to receive paired press and release events.

If you set up anything at the time you take the grab that needs to be
cleaned up when the grab ends, you should handle the 'GI.Gdk.Structs.EventGrabBroken.EventGrabBroken'
events that are emitted when the grab ends unvoluntarily.

@since 3.20
-}
seatGrab ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a, Gdk.Window.IsWindow b, Gdk.Cursor.IsCursor c) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> b
    {- ^ /@window@/: the 'GI.Gdk.Objects.Window.Window' which will own the grab -}
    -> [Gdk.Flags.SeatCapabilities]
    {- ^ /@capabilities@/: capabilities that will be grabbed -}
    -> Bool
    {- ^ /@ownerEvents@/: if 'False' then all device events are reported with respect to
               /@window@/ and are only reported if selected by /@eventMask@/. If
               'True' then pointer events for this application are reported
               as normal, but pointer events outside this application are
               reported with respect to /@window@/ and only if selected by
               /@eventMask@/. In either mode, unreported events are discarded. -}
    -> Maybe (c)
    {- ^ /@cursor@/: the cursor to display while the grab is active. If
         this is 'Nothing' then the normal cursors are used for
         /@window@/ and its descendants, and the cursor for /@window@/ is used
         elsewhere. -}
    -> Maybe (Gdk.Event.Event)
    {- ^ /@event@/: the event that is triggering the grab, or 'Nothing' if none
        is available. -}
    -> Maybe (Gdk.Callbacks.SeatGrabPrepareFunc)
    {- ^ /@prepareFunc@/: function to
               prepare the window to be grabbed, it can be 'Nothing' if /@window@/ is
               visible before this call. -}
    -> m Gdk.Enums.GrabStatus
    {- ^ __Returns:__ 'GI.Gdk.Enums.GrabStatusSuccess' if the grab was successful. -}
seatGrab seat window capabilities ownerEvents cursor event prepareFunc = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    window' <- unsafeManagedPtrCastPtr window
    let capabilities' = gflagsToWord capabilities
    let ownerEvents' = (fromIntegral . fromEnum) ownerEvents
    maybeCursor <- case cursor of
        Nothing -> return nullPtr
        Just jCursor -> do
            jCursor' <- unsafeManagedPtrCastPtr jCursor
            return jCursor'
    maybeEvent <- case event of
        Nothing -> return nullPtr
        Just jEvent -> do
            jEvent' <- unsafeManagedPtrGetPtr jEvent
            return jEvent'
    maybePrepareFunc <- case prepareFunc of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jPrepareFunc -> do
            jPrepareFunc' <- Gdk.Callbacks.mk_SeatGrabPrepareFunc (Gdk.Callbacks.wrap_SeatGrabPrepareFunc Nothing (Gdk.Callbacks.drop_closures_SeatGrabPrepareFunc jPrepareFunc))
            return jPrepareFunc'
    let prepareFuncData = nullPtr
    result <- gdk_seat_grab seat' window' capabilities' ownerEvents' maybeCursor maybeEvent maybePrepareFunc prepareFuncData
    let result' = (toEnum . fromIntegral) result
    safeFreeFunPtr $ castFunPtrToPtr maybePrepareFunc
    touchManagedPtr seat
    touchManagedPtr window
    whenJust cursor touchManagedPtr
    whenJust event touchManagedPtr
    return result'

data SeatGrabMethodInfo
instance (signature ~ (b -> [Gdk.Flags.SeatCapabilities] -> Bool -> Maybe (c) -> Maybe (Gdk.Event.Event) -> Maybe (Gdk.Callbacks.SeatGrabPrepareFunc) -> m Gdk.Enums.GrabStatus), MonadIO m, IsSeat a, Gdk.Window.IsWindow b, Gdk.Cursor.IsCursor c) => O.MethodInfo SeatGrabMethodInfo a signature where
    overloadedMethod _ = seatGrab

-- method Seat::ungrab
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "seat", argType = TInterface (Name {namespace = "Gdk", name = "Seat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkSeat", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_seat_ungrab" gdk_seat_ungrab :: 
    Ptr Seat ->                             -- seat : TInterface (Name {namespace = "Gdk", name = "Seat"})
    IO ()

{- |
Releases a grab added through 'GI.Gdk.Objects.Seat.seatGrab'.

@since 3.20
-}
seatUngrab ::
    (B.CallStack.HasCallStack, MonadIO m, IsSeat a) =>
    a
    {- ^ /@seat@/: a 'GI.Gdk.Objects.Seat.Seat' -}
    -> m ()
seatUngrab seat = liftIO $ do
    seat' <- unsafeManagedPtrCastPtr seat
    gdk_seat_ungrab seat'
    touchManagedPtr seat
    return ()

data SeatUngrabMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSeat a) => O.MethodInfo SeatUngrabMethodInfo a signature where
    overloadedMethod _ = seatUngrab