{- |
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.Objects.Device
    ( 

-- * Exported types
    Device(..)                              ,
    DeviceK                                 ,
    toDevice                                ,
    noDevice                                ,


 -- * Methods
-- ** deviceGetAssociatedDevice
    deviceGetAssociatedDevice               ,


-- ** deviceGetAxisUse
    deviceGetAxisUse                        ,


-- ** deviceGetDeviceType
    deviceGetDeviceType                     ,


-- ** deviceGetDisplay
    deviceGetDisplay                        ,


-- ** deviceGetHasCursor
    deviceGetHasCursor                      ,


-- ** deviceGetKey
    deviceGetKey                            ,


-- ** deviceGetLastEventWindow
    deviceGetLastEventWindow                ,


-- ** deviceGetMode
    deviceGetMode                           ,


-- ** deviceGetNAxes
    deviceGetNAxes                          ,


-- ** deviceGetNKeys
    deviceGetNKeys                          ,


-- ** deviceGetName
    deviceGetName                           ,


-- ** deviceGetPosition
    deviceGetPosition                       ,


-- ** deviceGetPositionDouble
    deviceGetPositionDouble                 ,


-- ** deviceGetProductId
    deviceGetProductId                      ,


-- ** deviceGetSource
    deviceGetSource                         ,


-- ** deviceGetVendorId
    deviceGetVendorId                       ,


-- ** deviceGetWindowAtPosition
    deviceGetWindowAtPosition               ,


-- ** deviceGetWindowAtPositionDouble
    deviceGetWindowAtPositionDouble         ,


-- ** deviceGrab
    deviceGrab                              ,


-- ** deviceGrabInfoLibgtkOnly
    deviceGrabInfoLibgtkOnly                ,


-- ** deviceListAxes
    deviceListAxes                          ,


-- ** deviceListSlaveDevices
    deviceListSlaveDevices                  ,


-- ** deviceSetAxisUse
    deviceSetAxisUse                        ,


-- ** deviceSetKey
    deviceSetKey                            ,


-- ** deviceSetMode
    deviceSetMode                           ,


-- ** deviceUngrab
    deviceUngrab                            ,


-- ** deviceWarp
    deviceWarp                              ,




 -- * Properties
-- ** AssociatedDevice
    DeviceAssociatedDevicePropertyInfo      ,
    getDeviceAssociatedDevice               ,


-- ** DeviceManager
    DeviceDeviceManagerPropertyInfo         ,
    constructDeviceDeviceManager            ,
    getDeviceDeviceManager                  ,


-- ** Display
    DeviceDisplayPropertyInfo               ,
    constructDeviceDisplay                  ,
    getDeviceDisplay                        ,


-- ** HasCursor
    DeviceHasCursorPropertyInfo             ,
    constructDeviceHasCursor                ,
    getDeviceHasCursor                      ,


-- ** InputMode
    DeviceInputModePropertyInfo             ,
    constructDeviceInputMode                ,
    getDeviceInputMode                      ,
    setDeviceInputMode                      ,


-- ** InputSource
    DeviceInputSourcePropertyInfo           ,
    constructDeviceInputSource              ,
    getDeviceInputSource                    ,


-- ** NAxes
    DeviceNAxesPropertyInfo                 ,
    getDeviceNAxes                          ,


-- ** Name
    DeviceNamePropertyInfo                  ,
    constructDeviceName                     ,
    getDeviceName                           ,


-- ** ProductId
    DeviceProductIdPropertyInfo             ,
    constructDeviceProductId                ,
    getDeviceProductId                      ,


-- ** Type
    DeviceTypePropertyInfo                  ,
    constructDeviceType                     ,
    getDeviceType                           ,


-- ** VendorId
    DeviceVendorIdPropertyInfo              ,
    constructDeviceVendorId                 ,
    getDeviceVendorId                       ,




 -- * Signals
-- ** Changed
    DeviceChangedCallback                   ,
    DeviceChangedCallbackC                  ,
    DeviceChangedSignalInfo                 ,
    afterDeviceChanged                      ,
    deviceChangedCallbackWrapper            ,
    deviceChangedClosure                    ,
    mkDeviceChangedCallback                 ,
    noDeviceChangedCallback                 ,
    onDeviceChanged                         ,




    ) 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
import qualified GI.GObject as GObject

newtype Device = Device (ForeignPtr Device)
foreign import ccall "gdk_device_get_type"
    c_gdk_device_get_type :: IO GType

type instance ParentTypes Device = DeviceParentTypes
type DeviceParentTypes = '[GObject.Object]

instance GObject Device where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_device_get_type
    

class GObject o => DeviceK o
instance (GObject o, IsDescendantOf Device o) => DeviceK o

toDevice :: DeviceK o => o -> IO Device
toDevice = unsafeCastTo Device

noDevice :: Maybe Device
noDevice = Nothing

-- signal Device::changed
type DeviceChangedCallback =
    IO ()

noDeviceChangedCallback :: Maybe DeviceChangedCallback
noDeviceChangedCallback = Nothing

type DeviceChangedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkDeviceChangedCallback :: DeviceChangedCallbackC -> IO (FunPtr DeviceChangedCallbackC)

deviceChangedClosure :: DeviceChangedCallback -> IO Closure
deviceChangedClosure cb = newCClosure =<< mkDeviceChangedCallback wrapped
    where wrapped = deviceChangedCallbackWrapper cb

deviceChangedCallbackWrapper ::
    DeviceChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
deviceChangedCallbackWrapper _cb _ _ = do
    _cb 

onDeviceChanged :: (GObject a, MonadIO m) => a -> DeviceChangedCallback -> m SignalHandlerId
onDeviceChanged obj cb = liftIO $ connectDeviceChanged obj cb SignalConnectBefore
afterDeviceChanged :: (GObject a, MonadIO m) => a -> DeviceChangedCallback -> m SignalHandlerId
afterDeviceChanged obj cb = connectDeviceChanged obj cb SignalConnectAfter

connectDeviceChanged :: (GObject a, MonadIO m) =>
                        a -> DeviceChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectDeviceChanged obj cb after = liftIO $ do
    cb' <- mkDeviceChangedCallback (deviceChangedCallbackWrapper cb)
    connectSignalFunPtr obj "changed" cb' after

-- VVV Prop "associated-device"
   -- Type: TInterface "Gdk" "Device"
   -- Flags: [PropertyReadable]

getDeviceAssociatedDevice :: (MonadIO m, DeviceK o) => o -> m Device
getDeviceAssociatedDevice obj = liftIO $ getObjectPropertyObject obj "associated-device" Device

data DeviceAssociatedDevicePropertyInfo
instance AttrInfo DeviceAssociatedDevicePropertyInfo where
    type AttrAllowedOps DeviceAssociatedDevicePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DeviceAssociatedDevicePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DeviceAssociatedDevicePropertyInfo = DeviceK
    type AttrGetType DeviceAssociatedDevicePropertyInfo = Device
    type AttrLabel DeviceAssociatedDevicePropertyInfo = "Device::associated-device"
    attrGet _ = getDeviceAssociatedDevice
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "device-manager"
   -- Type: TInterface "Gdk" "DeviceManager"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceDeviceManager :: (MonadIO m, DeviceK o) => o -> m DeviceManager
getDeviceDeviceManager obj = liftIO $ getObjectPropertyObject obj "device-manager" DeviceManager

constructDeviceDeviceManager :: (DeviceManagerK a) => a -> IO ([Char], GValue)
constructDeviceDeviceManager val = constructObjectPropertyObject "device-manager" val

data DeviceDeviceManagerPropertyInfo
instance AttrInfo DeviceDeviceManagerPropertyInfo where
    type AttrAllowedOps DeviceDeviceManagerPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceDeviceManagerPropertyInfo = DeviceManagerK
    type AttrBaseTypeConstraint DeviceDeviceManagerPropertyInfo = DeviceK
    type AttrGetType DeviceDeviceManagerPropertyInfo = DeviceManager
    type AttrLabel DeviceDeviceManagerPropertyInfo = "Device::device-manager"
    attrGet _ = getDeviceDeviceManager
    attrSet _ = undefined
    attrConstruct _ = constructDeviceDeviceManager

-- VVV Prop "display"
   -- Type: TInterface "Gdk" "Display"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceDisplay :: (MonadIO m, DeviceK o) => o -> m Display
getDeviceDisplay obj = liftIO $ getObjectPropertyObject obj "display" Display

constructDeviceDisplay :: (DisplayK a) => a -> IO ([Char], GValue)
constructDeviceDisplay val = constructObjectPropertyObject "display" val

data DeviceDisplayPropertyInfo
instance AttrInfo DeviceDisplayPropertyInfo where
    type AttrAllowedOps DeviceDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceDisplayPropertyInfo = DisplayK
    type AttrBaseTypeConstraint DeviceDisplayPropertyInfo = DeviceK
    type AttrGetType DeviceDisplayPropertyInfo = Display
    type AttrLabel DeviceDisplayPropertyInfo = "Device::display"
    attrGet _ = getDeviceDisplay
    attrSet _ = undefined
    attrConstruct _ = constructDeviceDisplay

-- VVV Prop "has-cursor"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceHasCursor :: (MonadIO m, DeviceK o) => o -> m Bool
getDeviceHasCursor obj = liftIO $ getObjectPropertyBool obj "has-cursor"

constructDeviceHasCursor :: Bool -> IO ([Char], GValue)
constructDeviceHasCursor val = constructObjectPropertyBool "has-cursor" val

data DeviceHasCursorPropertyInfo
instance AttrInfo DeviceHasCursorPropertyInfo where
    type AttrAllowedOps DeviceHasCursorPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceHasCursorPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint DeviceHasCursorPropertyInfo = DeviceK
    type AttrGetType DeviceHasCursorPropertyInfo = Bool
    type AttrLabel DeviceHasCursorPropertyInfo = "Device::has-cursor"
    attrGet _ = getDeviceHasCursor
    attrSet _ = undefined
    attrConstruct _ = constructDeviceHasCursor

-- VVV Prop "input-mode"
   -- Type: TInterface "Gdk" "InputMode"
   -- Flags: [PropertyReadable,PropertyWritable]

getDeviceInputMode :: (MonadIO m, DeviceK o) => o -> m InputMode
getDeviceInputMode obj = liftIO $ getObjectPropertyEnum obj "input-mode"

setDeviceInputMode :: (MonadIO m, DeviceK o) => o -> InputMode -> m ()
setDeviceInputMode obj val = liftIO $ setObjectPropertyEnum obj "input-mode" val

constructDeviceInputMode :: InputMode -> IO ([Char], GValue)
constructDeviceInputMode val = constructObjectPropertyEnum "input-mode" val

data DeviceInputModePropertyInfo
instance AttrInfo DeviceInputModePropertyInfo where
    type AttrAllowedOps DeviceInputModePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceInputModePropertyInfo = (~) InputMode
    type AttrBaseTypeConstraint DeviceInputModePropertyInfo = DeviceK
    type AttrGetType DeviceInputModePropertyInfo = InputMode
    type AttrLabel DeviceInputModePropertyInfo = "Device::input-mode"
    attrGet _ = getDeviceInputMode
    attrSet _ = setDeviceInputMode
    attrConstruct _ = constructDeviceInputMode

-- VVV Prop "input-source"
   -- Type: TInterface "Gdk" "InputSource"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceInputSource :: (MonadIO m, DeviceK o) => o -> m InputSource
getDeviceInputSource obj = liftIO $ getObjectPropertyEnum obj "input-source"

constructDeviceInputSource :: InputSource -> IO ([Char], GValue)
constructDeviceInputSource val = constructObjectPropertyEnum "input-source" val

data DeviceInputSourcePropertyInfo
instance AttrInfo DeviceInputSourcePropertyInfo where
    type AttrAllowedOps DeviceInputSourcePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceInputSourcePropertyInfo = (~) InputSource
    type AttrBaseTypeConstraint DeviceInputSourcePropertyInfo = DeviceK
    type AttrGetType DeviceInputSourcePropertyInfo = InputSource
    type AttrLabel DeviceInputSourcePropertyInfo = "Device::input-source"
    attrGet _ = getDeviceInputSource
    attrSet _ = undefined
    attrConstruct _ = constructDeviceInputSource

-- VVV Prop "n-axes"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable]

getDeviceNAxes :: (MonadIO m, DeviceK o) => o -> m Word32
getDeviceNAxes obj = liftIO $ getObjectPropertyCUInt obj "n-axes"

data DeviceNAxesPropertyInfo
instance AttrInfo DeviceNAxesPropertyInfo where
    type AttrAllowedOps DeviceNAxesPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DeviceNAxesPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DeviceNAxesPropertyInfo = DeviceK
    type AttrGetType DeviceNAxesPropertyInfo = Word32
    type AttrLabel DeviceNAxesPropertyInfo = "Device::n-axes"
    attrGet _ = getDeviceNAxes
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceName :: (MonadIO m, DeviceK o) => o -> m T.Text
getDeviceName obj = liftIO $ getObjectPropertyString obj "name"

constructDeviceName :: T.Text -> IO ([Char], GValue)
constructDeviceName val = constructObjectPropertyString "name" val

data DeviceNamePropertyInfo
instance AttrInfo DeviceNamePropertyInfo where
    type AttrAllowedOps DeviceNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceNamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DeviceNamePropertyInfo = DeviceK
    type AttrGetType DeviceNamePropertyInfo = T.Text
    type AttrLabel DeviceNamePropertyInfo = "Device::name"
    attrGet _ = getDeviceName
    attrSet _ = undefined
    attrConstruct _ = constructDeviceName

-- VVV Prop "product-id"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceProductId :: (MonadIO m, DeviceK o) => o -> m T.Text
getDeviceProductId obj = liftIO $ getObjectPropertyString obj "product-id"

constructDeviceProductId :: T.Text -> IO ([Char], GValue)
constructDeviceProductId val = constructObjectPropertyString "product-id" val

data DeviceProductIdPropertyInfo
instance AttrInfo DeviceProductIdPropertyInfo where
    type AttrAllowedOps DeviceProductIdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceProductIdPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DeviceProductIdPropertyInfo = DeviceK
    type AttrGetType DeviceProductIdPropertyInfo = T.Text
    type AttrLabel DeviceProductIdPropertyInfo = "Device::product-id"
    attrGet _ = getDeviceProductId
    attrSet _ = undefined
    attrConstruct _ = constructDeviceProductId

-- VVV Prop "type"
   -- Type: TInterface "Gdk" "DeviceType"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceType :: (MonadIO m, DeviceK o) => o -> m DeviceType
getDeviceType obj = liftIO $ getObjectPropertyEnum obj "type"

constructDeviceType :: DeviceType -> IO ([Char], GValue)
constructDeviceType val = constructObjectPropertyEnum "type" val

data DeviceTypePropertyInfo
instance AttrInfo DeviceTypePropertyInfo where
    type AttrAllowedOps DeviceTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceTypePropertyInfo = (~) DeviceType
    type AttrBaseTypeConstraint DeviceTypePropertyInfo = DeviceK
    type AttrGetType DeviceTypePropertyInfo = DeviceType
    type AttrLabel DeviceTypePropertyInfo = "Device::type"
    attrGet _ = getDeviceType
    attrSet _ = undefined
    attrConstruct _ = constructDeviceType

-- VVV Prop "vendor-id"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDeviceVendorId :: (MonadIO m, DeviceK o) => o -> m T.Text
getDeviceVendorId obj = liftIO $ getObjectPropertyString obj "vendor-id"

constructDeviceVendorId :: T.Text -> IO ([Char], GValue)
constructDeviceVendorId val = constructObjectPropertyString "vendor-id" val

data DeviceVendorIdPropertyInfo
instance AttrInfo DeviceVendorIdPropertyInfo where
    type AttrAllowedOps DeviceVendorIdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DeviceVendorIdPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DeviceVendorIdPropertyInfo = DeviceK
    type AttrGetType DeviceVendorIdPropertyInfo = T.Text
    type AttrLabel DeviceVendorIdPropertyInfo = "Device::vendor-id"
    attrGet _ = getDeviceVendorId
    attrSet _ = undefined
    attrConstruct _ = constructDeviceVendorId

type instance AttributeList Device = DeviceAttributeList
type DeviceAttributeList = ('[ '("associated-device", DeviceAssociatedDevicePropertyInfo), '("device-manager", DeviceDeviceManagerPropertyInfo), '("display", DeviceDisplayPropertyInfo), '("has-cursor", DeviceHasCursorPropertyInfo), '("input-mode", DeviceInputModePropertyInfo), '("input-source", DeviceInputSourcePropertyInfo), '("n-axes", DeviceNAxesPropertyInfo), '("name", DeviceNamePropertyInfo), '("product-id", DeviceProductIdPropertyInfo), '("type", DeviceTypePropertyInfo), '("vendor-id", DeviceVendorIdPropertyInfo)] :: [(Symbol, *)])

data DeviceChangedSignalInfo
instance SignalInfo DeviceChangedSignalInfo where
    type HaskellCallbackType DeviceChangedSignalInfo = DeviceChangedCallback
    connectSignal _ = connectDeviceChanged

type instance SignalList Device = DeviceSignalList
type DeviceSignalList = ('[ '("changed", DeviceChangedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Device::get_associated_device
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Device"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_associated_device" gdk_device_get_associated_device :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO (Ptr Device)


deviceGetAssociatedDevice ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Device
deviceGetAssociatedDevice _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_associated_device _obj'
    checkUnexpectedReturnNULL "gdk_device_get_associated_device" result
    result' <- (newObject Device) result
    touchManagedPtr _obj
    return result'

-- method Device::get_axis_use
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "AxisUse"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_axis_use" gdk_device_get_axis_use :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Word32 ->                               -- index_ : TBasicType TUInt32
    IO CUInt


deviceGetAxisUse ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- index_
    m AxisUse
deviceGetAxisUse _obj index_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_axis_use _obj' index_
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Device::get_device_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "DeviceType"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_device_type" gdk_device_get_device_type :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CUInt


deviceGetDeviceType ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m DeviceType
deviceGetDeviceType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_device_type _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Device::get_display
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Display"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_display" gdk_device_get_display :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO (Ptr Display)


deviceGetDisplay ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Display
deviceGetDisplay _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_display _obj'
    checkUnexpectedReturnNULL "gdk_device_get_display" result
    result' <- (newObject Display) result
    touchManagedPtr _obj
    return result'

-- method Device::get_has_cursor
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_has_cursor" gdk_device_get_has_cursor :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CInt


deviceGetHasCursor ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Bool
deviceGetHasCursor _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_has_cursor _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Device::get_key
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keyval", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "modifiers", argType = TInterface "Gdk" "ModifierType", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_key" gdk_device_get_key :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Word32 ->                               -- index_ : TBasicType TUInt32
    Ptr Word32 ->                           -- keyval : TBasicType TUInt32
    Ptr CUInt ->                            -- modifiers : TInterface "Gdk" "ModifierType"
    IO CInt


deviceGetKey ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- index_
    m (Bool,Word32,[ModifierType])
deviceGetKey _obj index_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    keyval <- allocMem :: IO (Ptr Word32)
    modifiers <- allocMem :: IO (Ptr CUInt)
    result <- gdk_device_get_key _obj' index_ keyval modifiers
    let result' = (/= 0) result
    keyval' <- peek keyval
    modifiers' <- peek modifiers
    let modifiers'' = wordToGFlags modifiers'
    touchManagedPtr _obj
    freeMem keyval
    freeMem modifiers
    return (result', keyval', modifiers'')

-- method Device::get_last_event_window
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_last_event_window" gdk_device_get_last_event_window :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO (Ptr Window)


deviceGetLastEventWindow ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Window
deviceGetLastEventWindow _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_last_event_window _obj'
    checkUnexpectedReturnNULL "gdk_device_get_last_event_window" result
    result' <- (newObject Window) result
    touchManagedPtr _obj
    return result'

-- method Device::get_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "InputMode"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_mode" gdk_device_get_mode :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CUInt


deviceGetMode ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m InputMode
deviceGetMode _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_mode _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Device::get_n_axes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_n_axes" gdk_device_get_n_axes :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO Int32


deviceGetNAxes ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Int32
deviceGetNAxes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_n_axes _obj'
    touchManagedPtr _obj
    return result

-- method Device::get_n_keys
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_n_keys" gdk_device_get_n_keys :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO Int32


deviceGetNKeys ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m Int32
deviceGetNKeys _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_n_keys _obj'
    touchManagedPtr _obj
    return result

-- method Device::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_name" gdk_device_get_name :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CString


deviceGetName ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m T.Text
deviceGetName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_name _obj'
    checkUnexpectedReturnNULL "gdk_device_get_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Device::get_position
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "screen", argType = TInterface "Gdk" "Screen", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "y", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_position" gdk_device_get_position :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr (Ptr Screen) ->                     -- screen : TInterface "Gdk" "Screen"
    Ptr Int32 ->                            -- x : TBasicType TInt32
    Ptr Int32 ->                            -- y : TBasicType TInt32
    IO ()


deviceGetPosition ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m (Screen,Int32,Int32)
deviceGetPosition _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    screen <- allocMem :: IO (Ptr (Ptr Screen))
    x <- allocMem :: IO (Ptr Int32)
    y <- allocMem :: IO (Ptr Int32)
    gdk_device_get_position _obj' screen x y
    screen' <- peek screen
    screen'' <- (newObject Screen) screen'
    x' <- peek x
    y' <- peek y
    touchManagedPtr _obj
    freeMem screen
    freeMem x
    freeMem y
    return (screen'', x', y')

-- method Device::get_position_double
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "screen", argType = TInterface "Gdk" "Screen", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "y", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_position_double" gdk_device_get_position_double :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr (Ptr Screen) ->                     -- screen : TInterface "Gdk" "Screen"
    Ptr CDouble ->                          -- x : TBasicType TDouble
    Ptr CDouble ->                          -- y : TBasicType TDouble
    IO ()


deviceGetPositionDouble ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m (Screen,Double,Double)
deviceGetPositionDouble _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    screen <- allocMem :: IO (Ptr (Ptr Screen))
    x <- allocMem :: IO (Ptr CDouble)
    y <- allocMem :: IO (Ptr CDouble)
    gdk_device_get_position_double _obj' screen x y
    screen' <- peek screen
    screen'' <- (newObject Screen) screen'
    x' <- peek x
    let x'' = realToFrac x'
    y' <- peek y
    let y'' = realToFrac y'
    touchManagedPtr _obj
    freeMem screen
    freeMem x
    freeMem y
    return (screen'', x'', y'')

-- method Device::get_product_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_product_id" gdk_device_get_product_id :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CString


deviceGetProductId ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m T.Text
deviceGetProductId _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_product_id _obj'
    checkUnexpectedReturnNULL "gdk_device_get_product_id" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Device::get_source
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "InputSource"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_source" gdk_device_get_source :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CUInt


deviceGetSource ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m InputSource
deviceGetSource _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_source _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Device::get_vendor_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_vendor_id" gdk_device_get_vendor_id :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO CString


deviceGetVendorId ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m T.Text
deviceGetVendorId _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_get_vendor_id _obj'
    checkUnexpectedReturnNULL "gdk_device_get_vendor_id" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Device::get_window_at_position
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "win_x", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "win_y", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_window_at_position" gdk_device_get_window_at_position :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr Int32 ->                            -- win_x : TBasicType TInt32
    Ptr Int32 ->                            -- win_y : TBasicType TInt32
    IO (Ptr Window)


deviceGetWindowAtPosition ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m (Window,Int32,Int32)
deviceGetWindowAtPosition _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    win_x <- allocMem :: IO (Ptr Int32)
    win_y <- allocMem :: IO (Ptr Int32)
    result <- gdk_device_get_window_at_position _obj' win_x win_y
    checkUnexpectedReturnNULL "gdk_device_get_window_at_position" result
    result' <- (newObject Window) result
    win_x' <- peek win_x
    win_y' <- peek win_y
    touchManagedPtr _obj
    freeMem win_x
    freeMem win_y
    return (result', win_x', win_y')

-- method Device::get_window_at_position_double
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "win_x", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "win_y", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_get_window_at_position_double" gdk_device_get_window_at_position_double :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr CDouble ->                          -- win_x : TBasicType TDouble
    Ptr CDouble ->                          -- win_y : TBasicType TDouble
    IO (Ptr Window)


deviceGetWindowAtPositionDouble ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m (Window,Double,Double)
deviceGetWindowAtPositionDouble _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    win_x <- allocMem :: IO (Ptr CDouble)
    win_y <- allocMem :: IO (Ptr CDouble)
    result <- gdk_device_get_window_at_position_double _obj' win_x win_y
    checkUnexpectedReturnNULL "gdk_device_get_window_at_position_double" result
    result' <- (newObject Window) result
    win_x' <- peek win_x
    let win_x'' = realToFrac win_x'
    win_y' <- peek win_y
    let win_y'' = realToFrac win_y'
    touchManagedPtr _obj
    freeMem win_x
    freeMem win_y
    return (result', win_x'', win_y'')

-- method Device::grab
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gdk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "grab_ownership", argType = TInterface "Gdk" "GrabOwnership", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_events", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "event_mask", argType = TInterface "Gdk" "EventMask", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cursor", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "time_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gdk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "grab_ownership", argType = TInterface "Gdk" "GrabOwnership", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_events", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "event_mask", argType = TInterface "Gdk" "EventMask", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cursor", argType = TInterface "Gdk" "Cursor", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "time_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gdk" "GrabStatus"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_grab" gdk_device_grab :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr Window ->                           -- window : TInterface "Gdk" "Window"
    CUInt ->                                -- grab_ownership : TInterface "Gdk" "GrabOwnership"
    CInt ->                                 -- owner_events : TBasicType TBoolean
    CUInt ->                                -- event_mask : TInterface "Gdk" "EventMask"
    Ptr Cursor ->                           -- cursor : TInterface "Gdk" "Cursor"
    Word32 ->                               -- time_ : TBasicType TUInt32
    IO CUInt


deviceGrab ::
    (MonadIO m, DeviceK a, WindowK b, CursorK c) =>
    a ->                                    -- _obj
    b ->                                    -- window
    GrabOwnership ->                        -- grab_ownership
    Bool ->                                 -- owner_events
    [EventMask] ->                          -- event_mask
    Maybe (c) ->                            -- cursor
    Word32 ->                               -- time_
    m GrabStatus
deviceGrab _obj window grab_ownership owner_events event_mask cursor time_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let window' = unsafeManagedPtrCastPtr window
    let grab_ownership' = (fromIntegral . fromEnum) grab_ownership
    let owner_events' = (fromIntegral . fromEnum) owner_events
    let event_mask' = gflagsToWord event_mask
    maybeCursor <- case cursor of
        Nothing -> return nullPtr
        Just jCursor -> do
            let jCursor' = unsafeManagedPtrCastPtr jCursor
            return jCursor'
    result <- gdk_device_grab _obj' window' grab_ownership' owner_events' event_mask' maybeCursor time_
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    touchManagedPtr window
    whenJust cursor touchManagedPtr
    return result'

-- method Device::list_axes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gdk" "Atom")
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_list_axes" gdk_device_list_axes :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO (Ptr (GList (Ptr Atom)))


deviceListAxes ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m [Atom]
deviceListAxes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_list_axes _obj'
    checkUnexpectedReturnNULL "gdk_device_list_axes" result
    -- XXX Wrapping a foreign struct/union with no known destructor, leak?
    result' <- unpackGList result
    result'' <- mapM (\x -> Atom <$> newForeignPtr_ x) result'
    g_list_free result
    touchManagedPtr _obj
    return result''

-- method Device::list_slave_devices
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gdk" "Device")
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_list_slave_devices" gdk_device_list_slave_devices :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    IO (Ptr (GList (Ptr Device)))


deviceListSlaveDevices ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    m [Device]
deviceListSlaveDevices _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_device_list_slave_devices _obj'
    checkUnexpectedReturnNULL "gdk_device_list_slave_devices" result
    result' <- unpackGList result
    result'' <- mapM (newObject Device) result'
    g_list_free result
    touchManagedPtr _obj
    return result''

-- method Device::set_axis_use
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "use", argType = TInterface "Gdk" "AxisUse", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "use", argType = TInterface "Gdk" "AxisUse", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_set_axis_use" gdk_device_set_axis_use :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Word32 ->                               -- index_ : TBasicType TUInt32
    CUInt ->                                -- use : TInterface "Gdk" "AxisUse"
    IO ()


deviceSetAxisUse ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- index_
    AxisUse ->                              -- use
    m ()
deviceSetAxisUse _obj index_ use = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let use' = (fromIntegral . fromEnum) use
    gdk_device_set_axis_use _obj' index_ use'
    touchManagedPtr _obj
    return ()

-- method Device::set_key
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keyval", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "modifiers", argType = TInterface "Gdk" "ModifierType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keyval", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "modifiers", argType = TInterface "Gdk" "ModifierType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_set_key" gdk_device_set_key :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Word32 ->                               -- index_ : TBasicType TUInt32
    Word32 ->                               -- keyval : TBasicType TUInt32
    CUInt ->                                -- modifiers : TInterface "Gdk" "ModifierType"
    IO ()


deviceSetKey ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- index_
    Word32 ->                               -- keyval
    [ModifierType] ->                       -- modifiers
    m ()
deviceSetKey _obj index_ keyval modifiers = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let modifiers' = gflagsToWord modifiers
    gdk_device_set_key _obj' index_ keyval modifiers'
    touchManagedPtr _obj
    return ()

-- method Device::set_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mode", argType = TInterface "Gdk" "InputMode", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mode", argType = TInterface "Gdk" "InputMode", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_set_mode" gdk_device_set_mode :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    CUInt ->                                -- mode : TInterface "Gdk" "InputMode"
    IO CInt


deviceSetMode ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    InputMode ->                            -- mode
    m Bool
deviceSetMode _obj mode = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let mode' = (fromIntegral . fromEnum) mode
    result <- gdk_device_set_mode _obj' mode'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Device::ungrab
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "time_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "time_", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_ungrab" gdk_device_ungrab :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Word32 ->                               -- time_ : TBasicType TUInt32
    IO ()


deviceUngrab ::
    (MonadIO m, DeviceK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- time_
    m ()
deviceUngrab _obj time_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    gdk_device_ungrab _obj' time_
    touchManagedPtr _obj
    return ()

-- method Device::warp
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "screen", argType = TInterface "Gdk" "Screen", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "screen", argType = TInterface "Gdk" "Screen", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "x", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "y", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_warp" gdk_device_warp :: 
    Ptr Device ->                           -- _obj : TInterface "Gdk" "Device"
    Ptr Screen ->                           -- screen : TInterface "Gdk" "Screen"
    Int32 ->                                -- x : TBasicType TInt32
    Int32 ->                                -- y : TBasicType TInt32
    IO ()


deviceWarp ::
    (MonadIO m, DeviceK a, ScreenK b) =>
    a ->                                    -- _obj
    b ->                                    -- screen
    Int32 ->                                -- x
    Int32 ->                                -- y
    m ()
deviceWarp _obj screen x y = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let screen' = unsafeManagedPtrCastPtr screen
    gdk_device_warp _obj' screen' x y
    touchManagedPtr _obj
    touchManagedPtr screen
    return ()

-- method Device::grab_info_libgtk_only
-- method type : MemberFunction
-- Args : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "device", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "grab_window", argType = TInterface "Gdk" "Window", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_events", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "display", argType = TInterface "Gdk" "Display", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "device", argType = TInterface "Gdk" "Device", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gdk_device_grab_info_libgtk_only" gdk_device_grab_info_libgtk_only :: 
    Ptr Display ->                          -- display : TInterface "Gdk" "Display"
    Ptr Device ->                           -- device : TInterface "Gdk" "Device"
    Ptr (Ptr Window) ->                     -- grab_window : TInterface "Gdk" "Window"
    Ptr CInt ->                             -- owner_events : TBasicType TBoolean
    IO CInt

{-# DEPRECATED deviceGrabInfoLibgtkOnly ["(Since version 3.16)","The symbol was never meant to be used outside","  of GTK+"]#-}
deviceGrabInfoLibgtkOnly ::
    (MonadIO m, DisplayK a, DeviceK b) =>
    a ->                                    -- display
    b ->                                    -- device
    m (Bool,Window,Bool)
deviceGrabInfoLibgtkOnly display device = liftIO $ do
    let display' = unsafeManagedPtrCastPtr display
    let device' = unsafeManagedPtrCastPtr device
    grab_window <- allocMem :: IO (Ptr (Ptr Window))
    owner_events <- allocMem :: IO (Ptr CInt)
    result <- gdk_device_grab_info_libgtk_only display' device' grab_window owner_events
    let result' = (/= 0) result
    grab_window' <- peek grab_window
    grab_window'' <- (newObject Window) grab_window'
    owner_events' <- peek owner_events
    let owner_events'' = (/= 0) owner_events'
    touchManagedPtr display
    touchManagedPtr device
    freeMem grab_window
    freeMem owner_events
    return (result', grab_window'', owner_events'')