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

    In addition to a single pointer and keyboard for user interface input,
    GDK contains support for a variety of input devices, including graphics
    tablets, touchscreens and multiple pointers\/keyboards interacting
    simultaneously with the user interface. Such input devices often have
    additional features, such as sub-pixel positioning information and
    additional device-dependent information.

    In order to query the device hierarchy and be aware of changes in the
    device hierarchy (such as virtual devices being created or removed, or
    physical devices being plugged or unplugged), GDK provides
    'GI.Gdk.Objects.DeviceManager.DeviceManager'.

    By default, and if the platform supports it, GDK is aware of multiple
    keyboard\/pointer pairs and multitouch devices. This behavior can be
    changed by calling 'GI.Gdk.Functions.disableMultidevice' before 'GI.Gdk.Objects.Display.displayOpen'.
    There should rarely be a need to do that though, since GDK defaults
    to a compatibility mode in which it will emit just one enter\/leave
    event pair for all devices on a window. To enable per-device
    enter\/leave events and other multi-pointer interaction features,
    'GI.Gdk.Objects.Window.windowSetSupportMultidevice' must be called on
    @/GdkWindows/@ (or @/gtk_widget_set_support_multidevice()/@ on widgets).
    window. See the 'GI.Gdk.Objects.Window.windowSetSupportMultidevice' documentation
    for more information.

    On X11, multi-device support is implemented through XInput 2.
    Unless 'GI.Gdk.Functions.disableMultidevice' is called, the XInput 2
    'GI.Gdk.Objects.DeviceManager.DeviceManager' implementation will be used as the input source.
    Otherwise either the core or XInput 1 implementations will be used.

    For simple applications that don’t have any special interest in
    input devices, the so-called “client pointer”
    provides a reasonable approximation to a simple setup with a single
    pointer and keyboard. The device that has been set as the client
    pointer can be accessed via 'GI.Gdk.Objects.DeviceManager.deviceManagerGetClientPointer'.

    Conceptually, in multidevice mode there are 2 device types. Virtual
    devices (or master devices) are represented by the pointer cursors
    and keyboard foci that are seen on the screen. Physical devices (or
    slave devices) represent the hardware that is controlling the virtual
    devices, and thus have no visible cursor on the screen.

    Virtual devices are always paired, so there is a keyboard device for every
    pointer device. Associations between devices may be inspected through
    'GI.Gdk.Objects.Device.deviceGetAssociatedDevice'.

    There may be several virtual devices, and several physical devices could
    be controlling each of these virtual devices. Physical devices may also
    be “floating”, which means they are not attached to any virtual device.

    = Master and slave devices

    >
    >carlos@sacarino:~$ xinput list
    >⎡ Virtual core pointer                          id=2    [master pointer  (3)]
    >⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    >⎜   ↳ Wacom ISDv4 E6 Pen stylus                 id=10   [slave  pointer  (2)]
    >⎜   ↳ Wacom ISDv4 E6 Finger touch               id=11   [slave  pointer  (2)]
    >⎜   ↳ SynPS/2 Synaptics TouchPad                id=13   [slave  pointer  (2)]
    >⎜   ↳ TPPS/2 IBM TrackPoint                     id=14   [slave  pointer  (2)]
    >⎜   ↳ Wacom ISDv4 E6 Pen eraser                 id=16   [slave  pointer  (2)]
    >⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    >    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    >    ↳ Power Button                              id=6    [slave  keyboard (3)]
    >    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    >    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    >    ↳ Integrated Camera                         id=9    [slave  keyboard (3)]
    >    ↳ AT Translated Set 2 keyboard              id=12   [slave  keyboard (3)]
    >    ↳ ThinkPad Extra Buttons                    id=15   [slave  keyboard (3)]

    By default, GDK will automatically listen for events coming from all
    master devices, setting the 'GI.Gdk.Objects.Device.Device' for all events coming from input
    devices. Events containing device information are @/GDK_MOTION_NOTIFY/@,
    @/GDK_BUTTON_PRESS/@, @/GDK_2BUTTON_PRESS/@, @/GDK_3BUTTON_PRESS/@,
    @/GDK_BUTTON_RELEASE/@, @/GDK_SCROLL/@, @/GDK_KEY_PRESS/@, @/GDK_KEY_RELEASE/@,
    @/GDK_ENTER_NOTIFY/@, @/GDK_LEAVE_NOTIFY/@, @/GDK_FOCUS_CHANGE/@,
    @/GDK_PROXIMITY_IN/@, @/GDK_PROXIMITY_OUT/@, @/GDK_DRAG_ENTER/@, @/GDK_DRAG_LEAVE/@,
    @/GDK_DRAG_MOTION/@, @/GDK_DRAG_STATUS/@, @/GDK_DROP_START/@, @/GDK_DROP_FINISHED/@
    and @/GDK_GRAB_BROKEN/@. When dealing with an event on a master device,
    it is possible to get the source (slave) device that the event originated
    from via 'GI.Gdk.Unions.Event.eventGetSourceDevice'.

    On a standard session, all physical devices are connected by default to
    the \"Virtual Core Pointer\/Keyboard\" master devices, hence routing all events
    through these. This behavior is only modified by device grabs, where the
    slave device is temporarily detached for as long as the grab is held, and
    more permanently by user modifications to the device hierarchy.

    On certain application specific setups, it may make sense
    to detach a physical device from its master pointer, and mapping it to
    an specific window. This can be achieved by the combination of
    'GI.Gdk.Objects.Device.deviceGrab' and 'GI.Gdk.Objects.Device.deviceSetMode'.

    In order to listen for events coming from devices
    other than a virtual device, 'GI.Gdk.Objects.Window.windowSetDeviceEvents' must be
    called. Generally, this function can be used to modify the event mask
    for any given device.

    Input devices may also provide additional information besides X\/Y.
    For example, graphics tablets may also provide pressure and X\/Y tilt
    information. This information is device-dependent, and may be
    queried through @/gdk_device_get_axis()/@. In multidevice mode, virtual
    devices will change axes in order to always represent the physical
    device that is routing events through it. Whenever the physical device
    changes, the 'GI.Gdk.Objects.Device.Device':@/n-axes/@ property will be notified, and
    'GI.Gdk.Objects.Device.deviceListAxes' will return the new device axes.

    Devices may also have associated “keys” or
    macro buttons. Such keys can be globally set to map into normal X
    keyboard events. The mapping is set using 'GI.Gdk.Objects.Device.deviceSetKey'.

    In GTK+ 3.20, a new 'GI.Gdk.Objects.Seat.Seat' object has been introduced that
    supersedes 'GI.Gdk.Objects.DeviceManager.DeviceManager' and should be preferred in newly
    written code.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Gdk.Objects.DeviceManager
        (

    -- * Exported types
        DeviceManager(..)                       ,
        IsDeviceManager                         ,
        toDeviceManager                         ,
        noDeviceManager                         ,

     -- * Methods
    -- ** getClientPointer #method:getClientPointer#

    #if ENABLE_OVERLOADING
        DeviceManagerGetClientPointerMethodInfo ,
    #endif
        deviceManagerGetClientPointer           ,

    -- ** getDisplay #method:getDisplay#

    #if ENABLE_OVERLOADING
        DeviceManagerGetDisplayMethodInfo       ,
    #endif
        deviceManagerGetDisplay                 ,

    -- ** listDevices #method:listDevices#

    #if ENABLE_OVERLOADING
        DeviceManagerListDevicesMethodInfo      ,
    #endif
        deviceManagerListDevices                ,

     -- * Properties
    -- ** display #attr:display#
    {- | /No description available in the introspection data./
    -}
    #if ENABLE_OVERLOADING
        DeviceManagerDisplayPropertyInfo        ,
    #endif
        constructDeviceManagerDisplay           ,
    #if ENABLE_OVERLOADING
        deviceManagerDisplay                    ,
    #endif
        getDeviceManagerDisplay                 ,

     -- * Signals
    -- ** deviceAdded #signal:deviceAdded#

        C_DeviceManagerDeviceAddedCallback      ,
        DeviceManagerDeviceAddedCallback        ,
    #if ENABLE_OVERLOADING
        DeviceManagerDeviceAddedSignalInfo      ,
    #endif
        afterDeviceManagerDeviceAdded           ,
        genClosure_DeviceManagerDeviceAdded     ,
        mk_DeviceManagerDeviceAddedCallback     ,
        noDeviceManagerDeviceAddedCallback      ,
        onDeviceManagerDeviceAdded              ,
        wrap_DeviceManagerDeviceAddedCallback   ,

    -- ** deviceChanged #signal:deviceChanged#

        C_DeviceManagerDeviceChangedCallback    ,
        DeviceManagerDeviceChangedCallback      ,
    #if ENABLE_OVERLOADING
        DeviceManagerDeviceChangedSignalInfo    ,
    #endif
        afterDeviceManagerDeviceChanged         ,
        genClosure_DeviceManagerDeviceChanged   ,
        mk_DeviceManagerDeviceChangedCallback   ,
        noDeviceManagerDeviceChangedCallback    ,
        onDeviceManagerDeviceChanged            ,
        wrap_DeviceManagerDeviceChangedCallback ,

    -- ** deviceRemoved #signal:deviceRemoved#

        C_DeviceManagerDeviceRemovedCallback    ,
        DeviceManagerDeviceRemovedCallback      ,
    #if ENABLE_OVERLOADING
        DeviceManagerDeviceRemovedSignalInfo    ,
    #endif
        afterDeviceManagerDeviceRemoved         ,
        genClosure_DeviceManagerDeviceRemoved   ,
        mk_DeviceManagerDeviceRemovedCallback   ,
        noDeviceManagerDeviceRemovedCallback    ,
        onDeviceManagerDeviceRemoved            ,
        wrap_DeviceManagerDeviceRemovedCallback ,

        ) 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.GValue as B.GValue
    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 {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
    import {-# SOURCE #-} qualified GI.Gdk.Objects.Device as Gdk.Device
    import {-# SOURCE #-} qualified GI.Gdk.Objects.Display as Gdk.Display

    -- | Memory-managed wrapper type.
    newtype DeviceManager = DeviceManager (ManagedPtr DeviceManager)
    foreign import ccall "gdk_device_manager_get_type"
        c_gdk_device_manager_get_type :: IO GType

    instance GObject DeviceManager where
        gobjectType _ = c_gdk_device_manager_get_type

    -- | Type class for types which can be safely cast to `DeviceManager`, for instance with `toDeviceManager`.
    class GObject o => IsDeviceManager o
    #if MIN_VERSION_base(4,9,0)
    instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DeviceManager a) =>
        IsDeviceManager a
    #endif
    instance IsDeviceManager DeviceManager
    instance GObject.Object.IsObject DeviceManager

    -- | Cast to `DeviceManager`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
    toDeviceManager :: (MonadIO m, IsDeviceManager o) => o -> m DeviceManager
    toDeviceManager = liftIO . unsafeCastTo DeviceManager

    -- | A convenience alias for `Nothing` :: `Maybe` `DeviceManager`.
    noDeviceManager :: Maybe DeviceManager
    noDeviceManager = Nothing

    #if ENABLE_OVERLOADING
    type family ResolveDeviceManagerMethod (t :: Symbol) (o :: *) :: * where
        ResolveDeviceManagerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveDeviceManagerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveDeviceManagerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveDeviceManagerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveDeviceManagerMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveDeviceManagerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveDeviceManagerMethod "listDevices" o = DeviceManagerListDevicesMethodInfo
        ResolveDeviceManagerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveDeviceManagerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveDeviceManagerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveDeviceManagerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveDeviceManagerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveDeviceManagerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
        ResolveDeviceManagerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveDeviceManagerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveDeviceManagerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveDeviceManagerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveDeviceManagerMethod "getClientPointer" o = DeviceManagerGetClientPointerMethodInfo
        ResolveDeviceManagerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
        ResolveDeviceManagerMethod "getDisplay" o = DeviceManagerGetDisplayMethodInfo
        ResolveDeviceManagerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveDeviceManagerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveDeviceManagerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveDeviceManagerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveDeviceManagerMethod l o = O.MethodResolutionFailed l o

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

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

    #endif

    -- signal DeviceManager::device-added
    {- |
    The ::device-added signal is emitted either when a new master
    pointer is created, or when a slave (Hardware) input device
    is plugged in.
    -}
    type DeviceManagerDeviceAddedCallback =
        Gdk.Device.Device
        {- ^ /@device@/: the newly added 'GI.Gdk.Objects.Device.Device'. -}
        -> IO ()

    -- | A convenience synonym for @`Nothing` :: `Maybe` `DeviceManagerDeviceAddedCallback`@.
    noDeviceManagerDeviceAddedCallback :: Maybe DeviceManagerDeviceAddedCallback
    noDeviceManagerDeviceAddedCallback = Nothing

    -- | Type for the callback on the (unwrapped) C side.
    type C_DeviceManagerDeviceAddedCallback =
        Ptr () ->                               -- object
        Ptr Gdk.Device.Device ->
        Ptr () ->                               -- user_data
        IO ()

    -- | Generate a function pointer callable from C code, from a `C_DeviceManagerDeviceAddedCallback`.
    foreign import ccall "wrapper"
        mk_DeviceManagerDeviceAddedCallback :: C_DeviceManagerDeviceAddedCallback -> IO (FunPtr C_DeviceManagerDeviceAddedCallback)

    -- | Wrap the callback into a `Closure`.
    genClosure_DeviceManagerDeviceAdded :: DeviceManagerDeviceAddedCallback -> IO Closure
    genClosure_DeviceManagerDeviceAdded cb = do
        let cb' = wrap_DeviceManagerDeviceAddedCallback cb
        mk_DeviceManagerDeviceAddedCallback cb' >>= newCClosure

    -- | Wrap a `DeviceManagerDeviceAddedCallback` into a `C_DeviceManagerDeviceAddedCallback`.
    wrap_DeviceManagerDeviceAddedCallback ::
        DeviceManagerDeviceAddedCallback ->
        C_DeviceManagerDeviceAddedCallback
    wrap_DeviceManagerDeviceAddedCallback _cb _ device _ = do
        device' <- (newObject Gdk.Device.Device) device
        _cb  device'

    {- |
    Connect a signal handler for the “@device-added@” signal, to be run before the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.on' deviceManager #deviceAdded callback
    @
    -}
    onDeviceManagerDeviceAdded :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceAddedCallback -> m SignalHandlerId
    onDeviceManagerDeviceAdded obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceAddedCallback cb
        cb'' <- mk_DeviceManagerDeviceAddedCallback cb'
        connectSignalFunPtr obj "device-added" cb'' SignalConnectBefore

    {- |
    Connect a signal handler for the “@device-added@” signal, to be run after the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.after' deviceManager #deviceAdded callback
    @
    -}
    afterDeviceManagerDeviceAdded :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceAddedCallback -> m SignalHandlerId
    afterDeviceManagerDeviceAdded obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceAddedCallback cb
        cb'' <- mk_DeviceManagerDeviceAddedCallback cb'
        connectSignalFunPtr obj "device-added" cb'' SignalConnectAfter

    -- signal DeviceManager::device-changed
    {- |
    The ::device-changed signal is emitted whenever a device
    has changed in the hierarchy, either slave devices being
    disconnected from their master device or connected to
    another one, or master devices being added or removed
    a slave device.

    If a slave device is detached from all master devices
    ('GI.Gdk.Objects.Device.deviceGetAssociatedDevice' returns 'Nothing'), its
    'GI.Gdk.Enums.DeviceType' will change to 'GI.Gdk.Enums.DeviceTypeFloating',
    if it\'s attached, it will change to 'GI.Gdk.Enums.DeviceTypeSlave'.
    -}
    type DeviceManagerDeviceChangedCallback =
        Gdk.Device.Device
        {- ^ /@device@/: the 'GI.Gdk.Objects.Device.Device' that changed. -}
        -> IO ()

    -- | A convenience synonym for @`Nothing` :: `Maybe` `DeviceManagerDeviceChangedCallback`@.
    noDeviceManagerDeviceChangedCallback :: Maybe DeviceManagerDeviceChangedCallback
    noDeviceManagerDeviceChangedCallback = Nothing

    -- | Type for the callback on the (unwrapped) C side.
    type C_DeviceManagerDeviceChangedCallback =
        Ptr () ->                               -- object
        Ptr Gdk.Device.Device ->
        Ptr () ->                               -- user_data
        IO ()

    -- | Generate a function pointer callable from C code, from a `C_DeviceManagerDeviceChangedCallback`.
    foreign import ccall "wrapper"
        mk_DeviceManagerDeviceChangedCallback :: C_DeviceManagerDeviceChangedCallback -> IO (FunPtr C_DeviceManagerDeviceChangedCallback)

    -- | Wrap the callback into a `Closure`.
    genClosure_DeviceManagerDeviceChanged :: DeviceManagerDeviceChangedCallback -> IO Closure
    genClosure_DeviceManagerDeviceChanged cb = do
        let cb' = wrap_DeviceManagerDeviceChangedCallback cb
        mk_DeviceManagerDeviceChangedCallback cb' >>= newCClosure

    -- | Wrap a `DeviceManagerDeviceChangedCallback` into a `C_DeviceManagerDeviceChangedCallback`.
    wrap_DeviceManagerDeviceChangedCallback ::
        DeviceManagerDeviceChangedCallback ->
        C_DeviceManagerDeviceChangedCallback
    wrap_DeviceManagerDeviceChangedCallback _cb _ device _ = do
        device' <- (newObject Gdk.Device.Device) device
        _cb  device'

    {- |
    Connect a signal handler for the “@device-changed@” signal, to be run before the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.on' deviceManager #deviceChanged callback
    @
    -}
    onDeviceManagerDeviceChanged :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceChangedCallback -> m SignalHandlerId
    onDeviceManagerDeviceChanged obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceChangedCallback cb
        cb'' <- mk_DeviceManagerDeviceChangedCallback cb'
        connectSignalFunPtr obj "device-changed" cb'' SignalConnectBefore

    {- |
    Connect a signal handler for the “@device-changed@” signal, to be run after the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.after' deviceManager #deviceChanged callback
    @
    -}
    afterDeviceManagerDeviceChanged :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceChangedCallback -> m SignalHandlerId
    afterDeviceManagerDeviceChanged obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceChangedCallback cb
        cb'' <- mk_DeviceManagerDeviceChangedCallback cb'
        connectSignalFunPtr obj "device-changed" cb'' SignalConnectAfter

    -- signal DeviceManager::device-removed
    {- |
    The ::device-removed signal is emitted either when a master
    pointer is removed, or when a slave (Hardware) input device
    is unplugged.
    -}
    type DeviceManagerDeviceRemovedCallback =
        Gdk.Device.Device
        {- ^ /@device@/: the just removed 'GI.Gdk.Objects.Device.Device'. -}
        -> IO ()

    -- | A convenience synonym for @`Nothing` :: `Maybe` `DeviceManagerDeviceRemovedCallback`@.
    noDeviceManagerDeviceRemovedCallback :: Maybe DeviceManagerDeviceRemovedCallback
    noDeviceManagerDeviceRemovedCallback = Nothing

    -- | Type for the callback on the (unwrapped) C side.
    type C_DeviceManagerDeviceRemovedCallback =
        Ptr () ->                               -- object
        Ptr Gdk.Device.Device ->
        Ptr () ->                               -- user_data
        IO ()

    -- | Generate a function pointer callable from C code, from a `C_DeviceManagerDeviceRemovedCallback`.
    foreign import ccall "wrapper"
        mk_DeviceManagerDeviceRemovedCallback :: C_DeviceManagerDeviceRemovedCallback -> IO (FunPtr C_DeviceManagerDeviceRemovedCallback)

    -- | Wrap the callback into a `Closure`.
    genClosure_DeviceManagerDeviceRemoved :: DeviceManagerDeviceRemovedCallback -> IO Closure
    genClosure_DeviceManagerDeviceRemoved cb = do
        let cb' = wrap_DeviceManagerDeviceRemovedCallback cb
        mk_DeviceManagerDeviceRemovedCallback cb' >>= newCClosure

    -- | Wrap a `DeviceManagerDeviceRemovedCallback` into a `C_DeviceManagerDeviceRemovedCallback`.
    wrap_DeviceManagerDeviceRemovedCallback ::
        DeviceManagerDeviceRemovedCallback ->
        C_DeviceManagerDeviceRemovedCallback
    wrap_DeviceManagerDeviceRemovedCallback _cb _ device _ = do
        device' <- (newObject Gdk.Device.Device) device
        _cb  device'

    {- |
    Connect a signal handler for the “@device-removed@” signal, to be run before the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.on' deviceManager #deviceRemoved callback
    @
    -}
    onDeviceManagerDeviceRemoved :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceRemovedCallback -> m SignalHandlerId
    onDeviceManagerDeviceRemoved obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceRemovedCallback cb
        cb'' <- mk_DeviceManagerDeviceRemovedCallback cb'
        connectSignalFunPtr obj "device-removed" cb'' SignalConnectBefore

    {- |
    Connect a signal handler for the “@device-removed@” signal, to be run after the default handler.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Signals.after' deviceManager #deviceRemoved callback
    @
    -}
    afterDeviceManagerDeviceRemoved :: (IsDeviceManager a, MonadIO m) => a -> DeviceManagerDeviceRemovedCallback -> m SignalHandlerId
    afterDeviceManagerDeviceRemoved obj cb = liftIO $ do
        let cb' = wrap_DeviceManagerDeviceRemovedCallback cb
        cb'' <- mk_DeviceManagerDeviceRemovedCallback cb'
        connectSignalFunPtr obj "device-removed" cb'' SignalConnectAfter

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

    {- |
    Get the value of the “@display@” property.
    When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

    @
    'Data.GI.Base.Attributes.get' deviceManager #display
    @
    -}
    getDeviceManagerDisplay :: (MonadIO m, IsDeviceManager o) => o -> m (Maybe Gdk.Display.Display)
    getDeviceManagerDisplay obj = liftIO $ getObjectPropertyObject obj "display" Gdk.Display.Display

    {- |
    Construct a `GValueConstruct` with valid value for the “@display@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
    -}
    constructDeviceManagerDisplay :: (IsDeviceManager o, Gdk.Display.IsDisplay a) => a -> IO (GValueConstruct o)
    constructDeviceManagerDisplay val = constructObjectPropertyObject "display" (Just val)

    #if ENABLE_OVERLOADING
    data DeviceManagerDisplayPropertyInfo
    instance AttrInfo DeviceManagerDisplayPropertyInfo where
        type AttrAllowedOps DeviceManagerDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
        type AttrSetTypeConstraint DeviceManagerDisplayPropertyInfo = Gdk.Display.IsDisplay
        type AttrBaseTypeConstraint DeviceManagerDisplayPropertyInfo = IsDeviceManager
        type AttrGetType DeviceManagerDisplayPropertyInfo = (Maybe Gdk.Display.Display)
        type AttrLabel DeviceManagerDisplayPropertyInfo = "display"
        type AttrOrigin DeviceManagerDisplayPropertyInfo = DeviceManager
        attrGet _ = getDeviceManagerDisplay
        attrSet _ = undefined
        attrConstruct _ = constructDeviceManagerDisplay
        attrClear _ = undefined
    #endif

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList DeviceManager
    type instance O.AttributeList DeviceManager = DeviceManagerAttributeList
    type DeviceManagerAttributeList = ('[ '("display", DeviceManagerDisplayPropertyInfo)] :: [(Symbol, *)])
    #endif

    #if ENABLE_OVERLOADING
    deviceManagerDisplay :: AttrLabelProxy "display"
    deviceManagerDisplay = AttrLabelProxy

    #endif

    #if ENABLE_OVERLOADING
    data DeviceManagerDeviceAddedSignalInfo
    instance SignalInfo DeviceManagerDeviceAddedSignalInfo where
        type HaskellCallbackType DeviceManagerDeviceAddedSignalInfo = DeviceManagerDeviceAddedCallback
        connectSignal _ obj cb connectMode = do
            let cb' = wrap_DeviceManagerDeviceAddedCallback cb
            cb'' <- mk_DeviceManagerDeviceAddedCallback cb'
            connectSignalFunPtr obj "device-added" cb'' connectMode

    data DeviceManagerDeviceChangedSignalInfo
    instance SignalInfo DeviceManagerDeviceChangedSignalInfo where
        type HaskellCallbackType DeviceManagerDeviceChangedSignalInfo = DeviceManagerDeviceChangedCallback
        connectSignal _ obj cb connectMode = do
            let cb' = wrap_DeviceManagerDeviceChangedCallback cb
            cb'' <- mk_DeviceManagerDeviceChangedCallback cb'
            connectSignalFunPtr obj "device-changed" cb'' connectMode

    data DeviceManagerDeviceRemovedSignalInfo
    instance SignalInfo DeviceManagerDeviceRemovedSignalInfo where
        type HaskellCallbackType DeviceManagerDeviceRemovedSignalInfo = DeviceManagerDeviceRemovedCallback
        connectSignal _ obj cb connectMode = do
            let cb' = wrap_DeviceManagerDeviceRemovedCallback cb
            cb'' <- mk_DeviceManagerDeviceRemovedCallback cb'
            connectSignalFunPtr obj "device-removed" cb'' connectMode

    type instance O.SignalList DeviceManager = DeviceManagerSignalList
    type DeviceManagerSignalList = ('[ '("deviceAdded", DeviceManagerDeviceAddedSignalInfo), '("deviceChanged", DeviceManagerDeviceChangedSignalInfo), '("deviceRemoved", DeviceManagerDeviceRemovedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

    #endif

    -- method DeviceManager::get_client_pointer
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "device_manager", argType = TInterface (Name {namespace = "Gdk", name = "DeviceManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceManager", 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_device_manager_get_client_pointer" gdk_device_manager_get_client_pointer ::
        Ptr DeviceManager ->                    -- device_manager : TInterface (Name {namespace = "Gdk", name = "DeviceManager"})
        IO (Ptr Gdk.Device.Device)

    {-# DEPRECATED deviceManagerGetClientPointer ["(Since version 3.20)","Use 'GI.Gdk.Objects.Seat.seatGetPointer' instead."] #-}
    {- |
    Returns the client pointer, that is, the master pointer that acts as the core pointer
    for this application. In X11, window managers may change this depending on the interaction
    pattern under the presence of several pointers.

    You should use this function seldomly, only in code that isn’t triggered by a 'GI.Gdk.Unions.Event.Event'
    and there aren’t other means to get a meaningful 'GI.Gdk.Objects.Device.Device' to operate on.

    /Since: 3.0/
    -}
    deviceManagerGetClientPointer ::
        (B.CallStack.HasCallStack, MonadIO m, IsDeviceManager a) =>
        a
        {- ^ /@deviceManager@/: a 'GI.Gdk.Objects.DeviceManager.DeviceManager' -}
        -> m Gdk.Device.Device
        {- ^ __Returns:__ The client pointer. This memory is
             owned by GDK and must not be freed or unreferenced. -}
    deviceManagerGetClientPointer deviceManager = liftIO $ do
        deviceManager' <- unsafeManagedPtrCastPtr deviceManager
        result <- gdk_device_manager_get_client_pointer deviceManager'
        checkUnexpectedReturnNULL "deviceManagerGetClientPointer" result
        result' <- (newObject Gdk.Device.Device) result
        touchManagedPtr deviceManager
        return result'

    #if ENABLE_OVERLOADING
    data DeviceManagerGetClientPointerMethodInfo
    instance (signature ~ (m Gdk.Device.Device), MonadIO m, IsDeviceManager a) => O.MethodInfo DeviceManagerGetClientPointerMethodInfo a signature where
        overloadedMethod _ = deviceManagerGetClientPointer

    #endif

    -- method DeviceManager::get_display
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "device_manager", argType = TInterface (Name {namespace = "Gdk", name = "DeviceManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceManager", 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_device_manager_get_display" gdk_device_manager_get_display ::
        Ptr DeviceManager ->                    -- device_manager : TInterface (Name {namespace = "Gdk", name = "DeviceManager"})
        IO (Ptr Gdk.Display.Display)

    {- |
    Gets the 'GI.Gdk.Objects.Display.Display' associated to /@deviceManager@/.

    /Since: 3.0/
    -}
    deviceManagerGetDisplay ::
        (B.CallStack.HasCallStack, MonadIO m, IsDeviceManager a) =>
        a
        {- ^ /@deviceManager@/: a 'GI.Gdk.Objects.DeviceManager.DeviceManager' -}
        -> m (Maybe Gdk.Display.Display)
        {- ^ __Returns:__ the 'GI.Gdk.Objects.Display.Display' to which
             /@deviceManager@/ is associated to, or 'Nothing'. This memory is
             owned by GDK and must not be freed or unreferenced. -}
    deviceManagerGetDisplay deviceManager = liftIO $ do
        deviceManager' <- unsafeManagedPtrCastPtr deviceManager
        result <- gdk_device_manager_get_display deviceManager'
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (newObject Gdk.Display.Display) result'
            return result''
        touchManagedPtr deviceManager
        return maybeResult

    #if ENABLE_OVERLOADING
    data DeviceManagerGetDisplayMethodInfo
    instance (signature ~ (m (Maybe Gdk.Display.Display)), MonadIO m, IsDeviceManager a) => O.MethodInfo DeviceManagerGetDisplayMethodInfo a signature where
        overloadedMethod _ = deviceManagerGetDisplay

    #endif

    -- method DeviceManager::list_devices
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "device_manager", argType = TInterface (Name {namespace = "Gdk", name = "DeviceManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkDeviceManager", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Gdk", name = "DeviceType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "device type to get.", 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_device_manager_list_devices" gdk_device_manager_list_devices ::
        Ptr DeviceManager ->                    -- device_manager : TInterface (Name {namespace = "Gdk", name = "DeviceManager"})
        CUInt ->                                -- type : TInterface (Name {namespace = "Gdk", name = "DeviceType"})
        IO (Ptr (GList (Ptr Gdk.Device.Device)))

    {-# DEPRECATED deviceManagerListDevices ["(Since version 3.20)",", use 'GI.Gdk.Objects.Seat.seatGetPointer', 'GI.Gdk.Objects.Seat.seatGetKeyboard'","            and 'GI.Gdk.Objects.Seat.seatGetSlaves' instead."] #-}
    {- |
    Returns the list of devices of type /@type@/ currently attached to
    /@deviceManager@/.

    /Since: 3.0/
    -}
    deviceManagerListDevices ::
        (B.CallStack.HasCallStack, MonadIO m, IsDeviceManager a) =>
        a
        {- ^ /@deviceManager@/: a 'GI.Gdk.Objects.DeviceManager.DeviceManager' -}
        -> Gdk.Enums.DeviceType
        {- ^ /@type@/: device type to get. -}
        -> m [Gdk.Device.Device]
        {- ^ __Returns:__ a list of
             @/GdkDevices/@. The returned list must be
             freed with g_list_free (). The list elements are owned by
             GTK+ and must not be freed or unreffed. -}
    deviceManagerListDevices deviceManager type_ = liftIO $ do
        deviceManager' <- unsafeManagedPtrCastPtr deviceManager
        let type_' = (fromIntegral . fromEnum) type_
        result <- gdk_device_manager_list_devices deviceManager' type_'
        result' <- unpackGList result
        result'' <- mapM (newObject Gdk.Device.Device) result'
        g_list_free result
        touchManagedPtr deviceManager
        return result''

    #if ENABLE_OVERLOADING
    data DeviceManagerListDevicesMethodInfo
    instance (signature ~ (Gdk.Enums.DeviceType -> m [Gdk.Device.Device]), MonadIO m, IsDeviceManager a) => O.MethodInfo DeviceManagerListDevicesMethodInfo a signature where
        overloadedMethod _ = deviceManagerListDevices

    #endif