    {-# LINE 1 "Graphics/X11/Xlib/Atom.hsc" #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Graphics.X11.Xlib.Atom
    -- Copyright   :  (c) Alastair Reid, 1999-2003
    -- License     :  BSD-style (see the file libraries/base/LICENSE)
    --
    -- Maintainer  :  libraries@haskell.org
    -- Stability   :  provisional
    -- Portability :  portable
    --
    -- A collection of type declarations for interfacing with X11 Atoms.
    --
    -----------------------------------------------------------------------------

    module Graphics.X11.Xlib.Atom(
            internAtom,
            getAtomName,
            getAtomNames,

            pRIMARY,
            sECONDARY,
            aRC,
            aTOM,
            bITMAP,
            cARDINAL,
            cOLORMAP,
            cURSOR,
            cUT_BUFFER0,
            cUT_BUFFER1,
            cUT_BUFFER2,
            cUT_BUFFER3,
            cUT_BUFFER4,
            cUT_BUFFER5,
            cUT_BUFFER6,
            cUT_BUFFER7,
            dRAWABLE,
            fONT,
            iNTEGER,
            pIXMAP,
            pOINT,
            rECTANGLE,
            rESOURCE_MANAGER,
            rGB_COLOR_MAP,
            rGB_BEST_MAP,
            rGB_BLUE_MAP,
            rGB_DEFAULT_MAP,
            rGB_GRAY_MAP,
            rGB_GREEN_MAP,
            rGB_RED_MAP,
            sTRING,
            vISUALID,
            wINDOW,
            wM_COMMAND,
            wM_HINTS,
            wM_CLIENT_MACHINE,
            wM_ICON_NAME,
            wM_ICON_SIZE,
            wM_NAME,
            wM_NORMAL_HINTS,
            wM_SIZE_HINTS,
            wM_ZOOM_HINTS,
            mIN_SPACE,
            nORM_SPACE,
            mAX_SPACE,
            eND_SPACE,
            sUPERSCRIPT_X,
            sUPERSCRIPT_Y,
            sUBSCRIPT_X,
            sUBSCRIPT_Y,
            uNDERLINE_POSITION,
            uNDERLINE_THICKNESS,
            sTRIKEOUT_ASCENT,
            sTRIKEOUT_DESCENT,
            iTALIC_ANGLE,
            x_HEIGHT,
            qUAD_WIDTH,
            wEIGHT,
            pOINT_SIZE,
            rESOLUTION,
            cOPYRIGHT,
            nOTICE,
            fONT_NAME,
            fAMILY_NAME,
            fULL_NAME,
            cAP_HEIGHT,
            wM_CLASS,
            wM_TRANSIENT_FOR,
            lAST_PREDEFINED,

            ) where

    import Graphics.X11.Types
    import Graphics.X11.Xlib.Internal
    import Graphics.X11.Xlib.Types

    import Foreign hiding ( void )
    import Foreign.C.Types
    import Foreign.C.String

    ----------------------------------------------------------------
    -- Atoms
    ----------------------------------------------------------------

    -- AC, 1/9/2000: Added definition for XInternAtom

    -- | interface to the X11 library function @XInternAtom()@.
    internAtom :: Display -> String -> Bool -> IO Atom
    internAtom :: Display -> String -> Bool -> IO Atom
    internAtom Display
    display String
    atom_name Bool
    only_if_exists =
            String -> (Ptr CChar -> IO Atom) -> IO Atom
    forall a. String -> (Ptr CChar -> IO a) -> IO a
    withCString String
    atom_name ((Ptr CChar -> IO Atom) -> IO Atom)
    -> (Ptr CChar -> IO Atom) -> IO Atom
    forall a b. (a -> b) -> a -> b
    $ \ Ptr CChar
    c_atom_name ->
            Display -> Ptr CChar -> Bool -> IO Atom
    xInternAtom Display
    display Ptr CChar
    c_atom_name Bool
    only_if_exists
    foreign import ccall unsafe "XInternAtom"
            xInternAtom :: Display -> CString -> Bool -> IO Atom

    -- jrk, 22.11.2012: getAtomName{,s}

    getAtomName :: Display -> Atom -> IO (Maybe String)
    getAtomName :: Display -> Atom -> IO (Maybe String)
    getAtomName Display
    dpy Atom
    atom = do
        p <- Display -> Atom -> IO (Ptr CChar)
    cXGetAtomName Display
    dpy Atom
    atom
        if p == nullPtr
            then return Nothing
            else do
                res <- peekCString p
                _ <- xFree p
                return $ Just res

    foreign import ccall "XGetAtomName"
        cXGetAtomName :: Display -> Atom -> IO (Ptr CChar)

    getAtomNames :: Display -> [Atom] -> IO [String]
    getAtomNames :: Display -> [Atom] -> IO [String]
    getAtomNames Display
    dpy [Atom]
    atoms = (Pool -> IO [String]) -> IO [String]
    forall b. (Pool -> IO b) -> IO b
    withPool ((Pool -> IO [String]) -> IO [String])
    -> (Pool -> IO [String]) -> IO [String]
    forall a b. (a -> b) -> a -> b
    $ \Pool
    pool -> do
        atomsp <- (Pool -> Int -> IO (Ptr Atom)
    forall a. Storable a => Pool -> Int -> IO (Ptr a)
    pooledMallocArray Pool
    pool (Int -> IO (Ptr Atom)) -> Int -> IO (Ptr Atom)
    forall a b. (a -> b) -> a -> b
    $ [Atom] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Atom]
    atoms) :: IO (Ptr Atom)
        ccharp <- (pooledMallocArray pool $ length atoms) :: IO (Ptr (Ptr CChar))

        pokeArray atomsp atoms
        _ <- cXGetAtomNames dpy atomsp (fromIntegral $ length atoms :: CInt) ccharp

        res <- peekArray (length atoms) ccharp >>= mapM peekCString
        peekArray (length atoms) ccharp >>= mapM_ xFree

        return res

    foreign import ccall "XGetAtomNames"
        cXGetAtomNames :: Display -> Ptr Atom -> CInt -> Ptr (Ptr CChar) -> IO Status

    -- XConvertSelection omitted
    -- XListProperties omitted
    -- XChangeProperty omitted
    -- XDeleteProperty omitted

    pRIMARY               :: Atom
    pRIMARY :: Atom
    pRIMARY               =  Atom
    1
    sECONDARY             :: Atom
    sECONDARY :: Atom
    sECONDARY             =  Atom
    2
    aRC                   :: Atom
    aRC :: Atom
    aRC                   =  Atom
    3
    aTOM                  :: Atom
    aTOM :: Atom
    aTOM                  =  Atom
    4
    bITMAP                :: Atom
    bITMAP :: Atom
    bITMAP                =  Atom
    5
    cARDINAL              :: Atom
    cARDINAL :: Atom
    cARDINAL              =  Atom
    6
    cOLORMAP              :: Atom
    cOLORMAP :: Atom
    cOLORMAP              =  Atom
    7
    cURSOR                :: Atom
    cURSOR :: Atom
    cURSOR                =  Atom
    8
    cUT_BUFFER0           :: Atom
    cUT_BUFFER0 :: Atom
    cUT_BUFFER0           =  Atom
    9
    cUT_BUFFER1           :: Atom
    cUT_BUFFER1 :: Atom
    cUT_BUFFER1           =  Atom
    10
    cUT_BUFFER2           :: Atom
    cUT_BUFFER2 :: Atom
    cUT_BUFFER2           =  Atom
    11
    cUT_BUFFER3           :: Atom
    cUT_BUFFER3 :: Atom
    cUT_BUFFER3           =  Atom
    12
    cUT_BUFFER4           :: Atom
    cUT_BUFFER4 :: Atom
    cUT_BUFFER4           =  Atom
    13
    cUT_BUFFER5           :: Atom
    cUT_BUFFER5 :: Atom
    cUT_BUFFER5           =  Atom
    14
    cUT_BUFFER6           :: Atom
    cUT_BUFFER6 :: Atom
    cUT_BUFFER6           =  Atom
    15
    cUT_BUFFER7           :: Atom
    cUT_BUFFER7 :: Atom
    cUT_BUFFER7           =  Atom
    16
    dRAWABLE              :: Atom
    dRAWABLE :: Atom
    dRAWABLE              =  Atom
    17
    fONT                  :: Atom
    fONT :: Atom
    fONT                  =  Atom
    18
    iNTEGER               :: Atom
    iNTEGER :: Atom
    iNTEGER               =  Atom
    19
    pIXMAP                :: Atom
    pIXMAP :: Atom
    pIXMAP                =  Atom
    20
    pOINT                 :: Atom
    pOINT :: Atom
    pOINT                 =  Atom
    21
    rECTANGLE             :: Atom
    rECTANGLE :: Atom
    rECTANGLE             =  Atom
    22
    rESOURCE_MANAGER      :: Atom
    rESOURCE_MANAGER :: Atom
    rESOURCE_MANAGER      =  Atom
    23
    rGB_COLOR_MAP         :: Atom
    rGB_COLOR_MAP :: Atom
    rGB_COLOR_MAP         =  Atom
    24
    rGB_BEST_MAP          :: Atom
    rGB_BEST_MAP :: Atom
    rGB_BEST_MAP          =  Atom
    25
    rGB_BLUE_MAP          :: Atom
    rGB_BLUE_MAP :: Atom
    rGB_BLUE_MAP          =  Atom
    26
    rGB_DEFAULT_MAP       :: Atom
    rGB_DEFAULT_MAP :: Atom
    rGB_DEFAULT_MAP       =  Atom
    27
    rGB_GRAY_MAP          :: Atom
    rGB_GRAY_MAP :: Atom
    rGB_GRAY_MAP          =  Atom
    28
    rGB_GREEN_MAP         :: Atom
    rGB_GREEN_MAP :: Atom
    rGB_GREEN_MAP         =  Atom
    29
    rGB_RED_MAP           :: Atom
    rGB_RED_MAP :: Atom
    rGB_RED_MAP           =  Atom
    30
    sTRING                :: Atom
    sTRING :: Atom
    sTRING                =  Atom
    31
    vISUALID              :: Atom
    vISUALID :: Atom
    vISUALID              =  Atom
    32
    wINDOW                :: Atom
    wINDOW :: Atom
    wINDOW                =  Atom
    33
    wM_COMMAND            :: Atom
    wM_COMMAND :: Atom
    wM_COMMAND            =  Atom
    34
    wM_HINTS              :: Atom
    wM_HINTS :: Atom
    wM_HINTS              =  Atom
    35
    wM_CLIENT_MACHINE     :: Atom
    wM_CLIENT_MACHINE :: Atom
    wM_CLIENT_MACHINE     =  Atom
    36
    wM_ICON_NAME          :: Atom
    wM_ICON_NAME :: Atom
    wM_ICON_NAME          =  Atom
    37
    wM_ICON_SIZE          :: Atom
    wM_ICON_SIZE :: Atom
    wM_ICON_SIZE          =  Atom
    38
    wM_NAME               :: Atom
    wM_NAME :: Atom
    wM_NAME               =  Atom
    39
    wM_NORMAL_HINTS       :: Atom
    wM_NORMAL_HINTS :: Atom
    wM_NORMAL_HINTS       =  Atom
    40
    wM_SIZE_HINTS         :: Atom
    wM_SIZE_HINTS :: Atom
    wM_SIZE_HINTS         =  Atom
    41
    wM_ZOOM_HINTS         :: Atom
    wM_ZOOM_HINTS :: Atom
    wM_ZOOM_HINTS         =  Atom
    42
    mIN_SPACE             :: Atom
    mIN_SPACE :: Atom
    mIN_SPACE             =  Atom
    43
    nORM_SPACE            :: Atom
    nORM_SPACE :: Atom
    nORM_SPACE            =  Atom
    44
    mAX_SPACE             :: Atom
    mAX_SPACE :: Atom
    mAX_SPACE             =  Atom
    45
    eND_SPACE             :: Atom
    eND_SPACE :: Atom
    eND_SPACE             =  Atom
    46
    sUPERSCRIPT_X         :: Atom
    sUPERSCRIPT_X :: Atom
    sUPERSCRIPT_X         =  Atom
    47
    sUPERSCRIPT_Y         :: Atom
    sUPERSCRIPT_Y :: Atom
    sUPERSCRIPT_Y         =  Atom
    48
    sUBSCRIPT_X           :: Atom
    sUBSCRIPT_X :: Atom
    sUBSCRIPT_X           =  Atom
    49
    sUBSCRIPT_Y           :: Atom
    sUBSCRIPT_Y :: Atom
    sUBSCRIPT_Y           =  Atom
    50
    uNDERLINE_POSITION    :: Atom
    uNDERLINE_POSITION :: Atom
    uNDERLINE_POSITION    =  Atom
    51
    uNDERLINE_THICKNESS   :: Atom
    uNDERLINE_THICKNESS :: Atom
    uNDERLINE_THICKNESS   =  Atom
    52
    sTRIKEOUT_ASCENT      :: Atom
    sTRIKEOUT_ASCENT :: Atom
    sTRIKEOUT_ASCENT      =  Atom
    53
    sTRIKEOUT_DESCENT     :: Atom
    sTRIKEOUT_DESCENT :: Atom
    sTRIKEOUT_DESCENT     =  Atom
    54
    iTALIC_ANGLE          :: Atom
    iTALIC_ANGLE :: Atom
    iTALIC_ANGLE          =  Atom
    55
    x_HEIGHT              :: Atom
    x_HEIGHT :: Atom
    x_HEIGHT              =  Atom
    56
    qUAD_WIDTH            :: Atom
    qUAD_WIDTH :: Atom
    qUAD_WIDTH            =  Atom
    57
    wEIGHT                :: Atom
    wEIGHT :: Atom
    wEIGHT                =  Atom
    58
    pOINT_SIZE            :: Atom
    pOINT_SIZE :: Atom
    pOINT_SIZE            =  Atom
    59
    rESOLUTION            :: Atom
    rESOLUTION :: Atom
    rESOLUTION            =  Atom
    60
    cOPYRIGHT             :: Atom
    cOPYRIGHT :: Atom
    cOPYRIGHT             =  Atom
    61
    nOTICE                :: Atom
    nOTICE :: Atom
    nOTICE                =  Atom
    62
    fONT_NAME             :: Atom
    fONT_NAME :: Atom
    fONT_NAME             =  Atom
    63
    fAMILY_NAME           :: Atom
    fAMILY_NAME :: Atom
    fAMILY_NAME           =  Atom
    64
    fULL_NAME             :: Atom
    fULL_NAME :: Atom
    fULL_NAME             =  Atom
    65
    cAP_HEIGHT            :: Atom
    cAP_HEIGHT :: Atom
    cAP_HEIGHT            =  Atom
    66
    wM_CLASS              :: Atom
    wM_CLASS :: Atom
    wM_CLASS              =  Atom
    67
    wM_TRANSIENT_FOR      :: Atom
    wM_TRANSIENT_FOR :: Atom
    wM_TRANSIENT_FOR      =  Atom
    68
    lAST_PREDEFINED       :: Atom
    lAST_PREDEFINED :: Atom
    lAST_PREDEFINED       =  Atom
    68

    {-# LINE 223 "Graphics/X11/Xlib/Atom.hsc" #-}

    ----------------------------------------------------------------
    -- End
    ----------------------------------------------------------------