-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GdkX11.Functions
    ( 

 -- * Methods


-- ** x11DeviceGetId #method:x11DeviceGetId#

    x11DeviceGetId                          ,


-- ** x11DeviceManagerLookup #method:x11DeviceManagerLookup#

    x11DeviceManagerLookup                  ,


-- ** x11FreeCompoundText #method:x11FreeCompoundText#

    x11FreeCompoundText                     ,


-- ** x11FreeTextList #method:x11FreeTextList#

    x11FreeTextList                         ,


-- ** x11GetServerTime #method:x11GetServerTime#

    x11GetServerTime                        ,


-- ** x11GetXatomByNameForDisplay #method:x11GetXatomByNameForDisplay#

    x11GetXatomByNameForDisplay             ,


-- ** x11GetXatomNameForDisplay #method:x11GetXatomNameForDisplay#

    x11GetXatomNameForDisplay               ,


-- ** x11LookupXdisplay #method:x11LookupXdisplay#

    x11LookupXdisplay                       ,


-- ** x11SetSmClientId #method:x11SetSmClientId#

    x11SetSmClientId                        ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
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 GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import {-# SOURCE #-} qualified GI.GdkX11.Objects.X11DeviceManagerXI2 as GdkX11.X11DeviceManagerXI2
import {-# SOURCE #-} qualified GI.GdkX11.Objects.X11DeviceXI2 as GdkX11.X11DeviceXI2
import {-# SOURCE #-} qualified GI.GdkX11.Objects.X11Display as GdkX11.X11Display
import {-# SOURCE #-} qualified GI.GdkX11.Objects.X11Surface as GdkX11.X11Surface
import qualified GI.Xlib.Structs.Display as Xlib.Display

-- function x11_set_sm_client_id
-- Args: [ Arg
--           { argCName = "sm_client_id"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the client id assigned by the session manager\n   when the connection was opened, or %NULL to remove the property."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_set_sm_client_id" gdk_x11_set_sm_client_id :: 
    CString ->                              -- sm_client_id : TBasicType TUTF8
    IO ()

-- | Sets the @SM_CLIENT_ID@ property on the application’s leader window so that
-- the window manager can save the application’s state using the X11R6 ICCCM
-- session management protocol.
-- 
-- See the X Session Management Library documentation for more information on
-- session management and the Inter-Client Communication Conventions Manual
x11SetSmClientId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@smClientId@/: the client id assigned by the session manager
    --    when the connection was opened, or 'P.Nothing' to remove the property.
    -> m ()
x11SetSmClientId :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m ()
x11SetSmClientId Maybe Text
smClientId = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CChar
maybeSmClientId <- case Maybe Text
smClientId of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jSmClientId -> do
            Ptr CChar
jSmClientId' <- Text -> IO (Ptr CChar)
textToCString Text
jSmClientId
            Ptr CChar -> IO (Ptr CChar)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jSmClientId'
    Ptr CChar -> IO ()
gdk_x11_set_sm_client_id Ptr CChar
maybeSmClientId
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeSmClientId
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function x11_lookup_xdisplay
-- Args: [ Arg
--           { argCName = "xdisplay"
--           , argType =
--               TInterface Name { namespace = "xlib" , name = "Display" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a pointer to an X Display"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkX11" , name = "X11Display" })
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_lookup_xdisplay" gdk_x11_lookup_xdisplay :: 
    Ptr Xlib.Display.Display ->             -- xdisplay : TInterface (Name {namespace = "xlib", name = "Display"})
    IO (Ptr GdkX11.X11Display.X11Display)

-- | Find the @GdkDisplay@ corresponding to /@xdisplay@/, if any exists.
x11LookupXdisplay ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Xlib.Display.Display
    -- ^ /@xdisplay@/: a pointer to an X Display
    -> m GdkX11.X11Display.X11Display
    -- ^ __Returns:__ the @GdkDisplay@, if found, otherwise 'P.Nothing'.
x11LookupXdisplay :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Display -> m X11Display
x11LookupXdisplay Display
xdisplay = IO X11Display -> m X11Display
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO X11Display -> m X11Display) -> IO X11Display -> m X11Display
forall a b. (a -> b) -> a -> b
$ do
    Ptr Display
xdisplay' <- Display -> IO (Ptr Display)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Display
xdisplay
    Ptr X11Display
result <- Ptr Display -> IO (Ptr X11Display)
gdk_x11_lookup_xdisplay Ptr Display
xdisplay'
    Text -> Ptr X11Display -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"x11LookupXdisplay" Ptr X11Display
result
    X11Display
result' <- ((ManagedPtr X11Display -> X11Display)
-> Ptr X11Display -> IO X11Display
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr X11Display -> X11Display
GdkX11.X11Display.X11Display) Ptr X11Display
result
    Display -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Display
xdisplay
    X11Display -> IO X11Display
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return X11Display
result'


-- function x11_get_xatom_name_for_display
-- Args: [ Arg
--           { argCName = "display"
--           , argType =
--               TInterface Name { namespace = "GdkX11" , name = "X11Display" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the `GdkDisplay` where @xatom is defined"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "xatom"
--           , argType = TBasicType TULong
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an X atom" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_get_xatom_name_for_display" gdk_x11_get_xatom_name_for_display :: 
    Ptr GdkX11.X11Display.X11Display ->     -- display : TInterface (Name {namespace = "GdkX11", name = "X11Display"})
    CULong ->                               -- xatom : TBasicType TULong
    IO CString

-- | Returns the name of an X atom for its display. This
-- function is meant mainly for debugging, so for convenience, unlike
-- @/XAtomName()/@ and the result doesn’t need to
-- be freed.
x11GetXatomNameForDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, GdkX11.X11Display.IsX11Display a) =>
    a
    -- ^ /@display@/: the @GdkDisplay@ where /@xatom@/ is defined
    -> CULong
    -- ^ /@xatom@/: an X atom
    -> m T.Text
    -- ^ __Returns:__ name of the X atom; this string is owned by GDK,
    --   so it shouldn’t be modified or freed.
x11GetXatomNameForDisplay :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsX11Display a) =>
a -> CULong -> m Text
x11GetXatomNameForDisplay a
display CULong
xatom = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr X11Display
display' <- a -> IO (Ptr X11Display)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
display
    Ptr CChar
result <- Ptr X11Display -> CULong -> IO (Ptr CChar)
gdk_x11_get_xatom_name_for_display Ptr X11Display
display' CULong
xatom
    Text -> Ptr CChar -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"x11GetXatomNameForDisplay" Ptr CChar
result
    Text
result' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
display
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function x11_get_xatom_by_name_for_display
-- Args: [ Arg
--           { argCName = "display"
--           , argType =
--               TInterface Name { namespace = "GdkX11" , name = "X11Display" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GdkDisplay`" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "atom_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TULong)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_get_xatom_by_name_for_display" gdk_x11_get_xatom_by_name_for_display :: 
    Ptr GdkX11.X11Display.X11Display ->     -- display : TInterface (Name {namespace = "GdkX11", name = "X11Display"})
    CString ->                              -- atom_name : TBasicType TUTF8
    IO CULong

-- | Returns the X atom for a @GdkDisplay@ corresponding to /@atomName@/.
-- This function caches the result, so if called repeatedly it is much
-- faster than @/XInternAtom()/@, which is a round trip to the server each time.
x11GetXatomByNameForDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, GdkX11.X11Display.IsX11Display a) =>
    a
    -- ^ /@display@/: a @GdkDisplay@
    -> T.Text
    -- ^ /@atomName@/: a string
    -> m CULong
    -- ^ __Returns:__ a X atom for a @GdkDisplay@
x11GetXatomByNameForDisplay :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsX11Display a) =>
a -> Text -> m CULong
x11GetXatomByNameForDisplay a
display Text
atomName = IO CULong -> m CULong
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CULong -> m CULong) -> IO CULong -> m CULong
forall a b. (a -> b) -> a -> b
$ do
    Ptr X11Display
display' <- a -> IO (Ptr X11Display)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
display
    Ptr CChar
atomName' <- Text -> IO (Ptr CChar)
textToCString Text
atomName
    CULong
result <- Ptr X11Display -> Ptr CChar -> IO CULong
gdk_x11_get_xatom_by_name_for_display Ptr X11Display
display' Ptr CChar
atomName'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
display
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
atomName'
    CULong -> IO CULong
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CULong
result


-- function x11_get_server_time
-- Args: [ Arg
--           { argCName = "surface"
--           , argType =
--               TInterface Name { namespace = "GdkX11" , name = "X11Surface" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a `GdkSurface`, used for communication\n  with the server. The surface must have `GDK_PROPERTY_CHANGE_MASK` in\n  its events mask or a hang will result."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_get_server_time" gdk_x11_get_server_time :: 
    Ptr GdkX11.X11Surface.X11Surface ->     -- surface : TInterface (Name {namespace = "GdkX11", name = "X11Surface"})
    IO Word32

-- | Routine to get the current X server time stamp.
x11GetServerTime ::
    (B.CallStack.HasCallStack, MonadIO m, GdkX11.X11Surface.IsX11Surface a) =>
    a
    -- ^ /@surface@/: a @GdkSurface@, used for communication
    --   with the server. The surface must have @GDK_PROPERTY_CHANGE_MASK@ in
    --   its events mask or a hang will result.
    -> m Word32
    -- ^ __Returns:__ the time stamp
x11GetServerTime :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsX11Surface a) =>
a -> m Word32
x11GetServerTime a
surface = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr X11Surface
surface' <- a -> IO (Ptr X11Surface)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
surface
    Word32
result <- Ptr X11Surface -> IO Word32
gdk_x11_get_server_time Ptr X11Surface
surface'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
surface
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function x11_free_text_list
-- Args: [ Arg
--           { argCName = "list"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the value stored in the @list parameter by\n  a call to gdk_x11_display_text_property_to_text_list()."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_free_text_list" gdk_x11_free_text_list :: 
    CString ->                              -- list : TBasicType TUTF8
    IO ()

-- | Frees the array of strings created by
-- 'GI.GdkX11.Objects.X11Display.x11DisplayTextPropertyToTextList'.
x11FreeTextList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@list@/: the value stored in the /@list@/ parameter by
    --   a call to 'GI.GdkX11.Objects.X11Display.x11DisplayTextPropertyToTextList'.
    -> m ()
x11FreeTextList :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m ()
x11FreeTextList Text
list = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CChar
list' <- Text -> IO (Ptr CChar)
textToCString Text
list
    Ptr CChar -> IO ()
gdk_x11_free_text_list Ptr CChar
list'
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
list'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function x11_free_compound_text
-- Args: [ Arg
--           { argCName = "ctext"
--           , argType = TBasicType TUInt8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "The pointer stored in @ctext from a call to\n  gdk_x11_display_string_to_compound_text()."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_free_compound_text" gdk_x11_free_compound_text :: 
    Word8 ->                                -- ctext : TBasicType TUInt8
    IO ()

-- | Frees the data returned from 'GI.GdkX11.Objects.X11Display.x11DisplayStringToCompoundText'.
x11FreeCompoundText ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word8
    -- ^ /@ctext@/: The pointer stored in /@ctext@/ from a call to
    --   'GI.GdkX11.Objects.X11Display.x11DisplayStringToCompoundText'.
    -> m ()
x11FreeCompoundText :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Word8 -> m ()
x11FreeCompoundText Word8
ctext = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Word8 -> IO ()
gdk_x11_free_compound_text Word8
ctext
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function x11_device_manager_lookup
-- Args: [ Arg
--           { argCName = "device_manager"
--           , argType =
--               TInterface
--                 Name { namespace = "GdkX11" , name = "X11DeviceManagerXI2" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GdkDeviceManager`"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "device_id"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a device ID, as understood by the XInput2 protocol"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkX11" , name = "X11DeviceXI2" })
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_device_manager_lookup" gdk_x11_device_manager_lookup :: 
    Ptr GdkX11.X11DeviceManagerXI2.X11DeviceManagerXI2 -> -- device_manager : TInterface (Name {namespace = "GdkX11", name = "X11DeviceManagerXI2"})
    Int32 ->                                -- device_id : TBasicType TInt
    IO (Ptr GdkX11.X11DeviceXI2.X11DeviceXI2)

-- | Returns the @GdkDevice@ that wraps the given device ID.
x11DeviceManagerLookup ::
    (B.CallStack.HasCallStack, MonadIO m, GdkX11.X11DeviceManagerXI2.IsX11DeviceManagerXI2 a) =>
    a
    -- ^ /@deviceManager@/: a @GdkDeviceManager@
    -> Int32
    -- ^ /@deviceId@/: a device ID, as understood by the XInput2 protocol
    -> m (Maybe GdkX11.X11DeviceXI2.X11DeviceXI2)
    -- ^ __Returns:__ The
    --   @GdkDevice@ wrapping the device ID, or 'P.Nothing' if the given ID
    --   doesn’t currently represent a device.
x11DeviceManagerLookup :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsX11DeviceManagerXI2 a) =>
a -> Int32 -> m (Maybe X11DeviceXI2)
x11DeviceManagerLookup a
deviceManager Int32
deviceId = IO (Maybe X11DeviceXI2) -> m (Maybe X11DeviceXI2)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe X11DeviceXI2) -> m (Maybe X11DeviceXI2))
-> IO (Maybe X11DeviceXI2) -> m (Maybe X11DeviceXI2)
forall a b. (a -> b) -> a -> b
$ do
    Ptr X11DeviceManagerXI2
deviceManager' <- a -> IO (Ptr X11DeviceManagerXI2)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
deviceManager
    Ptr X11DeviceXI2
result <- Ptr X11DeviceManagerXI2 -> Int32 -> IO (Ptr X11DeviceXI2)
gdk_x11_device_manager_lookup Ptr X11DeviceManagerXI2
deviceManager' Int32
deviceId
    Maybe X11DeviceXI2
maybeResult <- Ptr X11DeviceXI2
-> (Ptr X11DeviceXI2 -> IO X11DeviceXI2) -> IO (Maybe X11DeviceXI2)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr X11DeviceXI2
result ((Ptr X11DeviceXI2 -> IO X11DeviceXI2) -> IO (Maybe X11DeviceXI2))
-> (Ptr X11DeviceXI2 -> IO X11DeviceXI2) -> IO (Maybe X11DeviceXI2)
forall a b. (a -> b) -> a -> b
$ \Ptr X11DeviceXI2
result' -> do
        X11DeviceXI2
result'' <- ((ManagedPtr X11DeviceXI2 -> X11DeviceXI2)
-> Ptr X11DeviceXI2 -> IO X11DeviceXI2
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr X11DeviceXI2 -> X11DeviceXI2
GdkX11.X11DeviceXI2.X11DeviceXI2) Ptr X11DeviceXI2
result'
        X11DeviceXI2 -> IO X11DeviceXI2
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return X11DeviceXI2
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
deviceManager
    Maybe X11DeviceXI2 -> IO (Maybe X11DeviceXI2)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe X11DeviceXI2
maybeResult


-- function x11_device_get_id
-- Args: [ Arg
--           { argCName = "device"
--           , argType =
--               TInterface Name { namespace = "GdkX11" , name = "X11DeviceXI2" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GdkDevice`" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_x11_device_get_id" gdk_x11_device_get_id :: 
    Ptr GdkX11.X11DeviceXI2.X11DeviceXI2 -> -- device : TInterface (Name {namespace = "GdkX11", name = "X11DeviceXI2"})
    IO Int32

-- | Returns the device ID as seen by XInput2.
x11DeviceGetId ::
    (B.CallStack.HasCallStack, MonadIO m, GdkX11.X11DeviceXI2.IsX11DeviceXI2 a) =>
    a
    -- ^ /@device@/: a @GdkDevice@
    -> m Int32
    -- ^ __Returns:__ the XInput2 device ID
x11DeviceGetId :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsX11DeviceXI2 a) =>
a -> m Int32
x11DeviceGetId a
device = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr X11DeviceXI2
device' <- a -> IO (Ptr X11DeviceXI2)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
device
    Int32
result <- Ptr X11DeviceXI2 -> IO Int32
gdk_x11_device_get_id Ptr X11DeviceXI2
device'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
device
    Int32 -> IO Int32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result