1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
-----------------------------------------------------------------------------
-- |
-- Module : Graphics.X11.Xlib.Display
-- 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 FFI declarations for interfacing with Xlib Displays.
--
-----------------------------------------------------------------------------
module Graphics.X11.Xlib.Display(
allPlanes_aux,
blackPixel,
whitePixel,
connectionNumber,
defaultColormap,
defaultGC,
defaultDepth,
defaultScreen,
defaultScreenOfDisplay,
displayHeight,
displayHeightMM,
displayWidth,
displayWidthMM,
maxRequestSize,
displayMotionBufferSize,
resourceManagerString,
screenResourceString,
displayString,
imageByteOrder,
protocolRevision,
protocolVersion,
serverVendor,
screenCount,
defaultVisual,
displayCells,
displayPlanes,
screenOfDisplay,
defaultRootWindow,
rootWindow,
qLength,
noOp,
openDisplay,
closeDisplay,
) where
import Graphics.X11.Types
import Graphics.X11.Xlib.Types
import Foreign (throwIfNull, Ptr)
import Foreign.C
import System.IO.Unsafe
----------------------------------------------------------------
-- Display
----------------------------------------------------------------
-- | interface to the X11 library function @XAllPlanes()@.
foreign import ccall unsafe "HsXlib.h XAllPlanes"
allPlanes_aux :: Pixel
-- | interface to the X11 library function @XBlackPixel()@.
foreign import ccall unsafe "HsXlib.h XBlackPixel"
blackPixel :: Display -> ScreenNumber -> Pixel
-- | interface to the X11 library function @XWhitePixel()@.
foreign import ccall unsafe "HsXlib.h XWhitePixel"
whitePixel :: Display -> ScreenNumber -> Pixel
-- This may vary from one execution to another but I believe it
-- is constant during any given execution and so it can be made PURE
-- without breaking referential transparency.
--
-- Note: underneath the opaque name, it turns out that this
-- is the file descriptor. You need to know this if you want to
-- use select.
-- | interface to the X11 library function @XConnectionNumber()@.
foreign import ccall unsafe "HsXlib.h XConnectionNumber"
connectionNumber :: Display -> CInt
-- | interface to the X11 library function @XDefaultColormap()@.
foreign import ccall unsafe "HsXlib.h XDefaultColormap"
defaultColormap :: Display -> ScreenNumber -> Colormap
-- XListDepths :: Display -> ScreenNumber -> ListInt using res1 = XListDepths(arg1,arg2,&res1_size)
-- | interface to the X11 library function @XDefaultGC()@.
foreign import ccall unsafe "HsXlib.h XDefaultGC"
defaultGC :: Display -> ScreenNumber -> GC
-- | interface to the X11 library function @XDefaultDepth()@.
foreign import ccall unsafe "HsXlib.h XDefaultDepth"
defaultDepth :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XDefaultScreen()@.
foreign import ccall unsafe "HsXlib.h XDefaultScreen"
defaultScreen :: Display -> ScreenNumber
-- | interface to the X11 library function @XDefaultScreenOfDisplay()@.
foreign import ccall unsafe "HsXlib.h XDefaultScreenOfDisplay"
defaultScreenOfDisplay :: Display -> Screen
-- | interface to the X11 library function @XDisplayHeight()@.
foreign import ccall unsafe "HsXlib.h XDisplayHeight"
displayHeight :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XDisplayHeightMM()@.
foreign import ccall unsafe "HsXlib.h XDisplayHeightMM"
displayHeightMM :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XDisplayWidth()@.
foreign import ccall unsafe "HsXlib.h XDisplayWidth"
displayWidth :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XDisplayWidthMM()@.
foreign import ccall unsafe "HsXlib.h XDisplayWidthMM"
displayWidthMM :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XMaxRequestSize()@.
foreign import ccall unsafe "HsXlib.h XMaxRequestSize"
maxRequestSize :: Display -> CInt
-- | interface to the X11 library function @XDisplayMotionBufferSize()@.
foreign import ccall unsafe "HsXlib.h XDisplayMotionBufferSize"
displayMotionBufferSize :: Display -> CInt
--Disnae exist in X11R5 XExtendedMaxRequestSize :: Display -> Int
-- | interface to the X11 library function @XResourceManagerString()@.
resourceManagerString :: Display -> String
resourceManagerString display = xlibCString (xResourceManagerString display)
foreign import ccall unsafe "HsXlib.h XResourceManagerString"
xResourceManagerString :: Display -> IO CString
-- | interface to the X11 library function @XScreenResourceString()@.
screenResourceString :: Screen -> String
screenResourceString screen = xlibCString (xScreenResourceString screen)
foreign import ccall unsafe "HsXlib.h XScreenResourceString"
xScreenResourceString :: Screen -> IO CString
-- | interface to the X11 library function @XDisplayString()@.
displayString :: Display -> String
displayString display = xlibCString (xDisplayString display)
foreign import ccall unsafe "HsXlib.h XDisplayString"
xDisplayString :: Display -> IO CString
-- | interface to the X11 library function @XImageByteOrder()@.
foreign import ccall unsafe "HsXlib.h XImageByteOrder"
imageByteOrder :: Display -> CInt
-- | interface to the X11 library function @XProtocolRevision()@.
foreign import ccall unsafe "HsXlib.h XProtocolRevision"
protocolRevision :: Display -> CInt
-- | interface to the X11 library function @XProtocolVersion()@.
foreign import ccall unsafe "HsXlib.h XProtocolVersion"
protocolVersion :: Display -> CInt
-- | interface to the X11 library function @XServerVendor()@.
serverVendor :: Display -> String
serverVendor display = xlibCString (xServerVendor display)
foreign import ccall unsafe "HsXlib.h XServerVendor"
xServerVendor :: Display -> IO CString
--Disnae exist: XServerRelease :: Display -> Int
-- | interface to the X11 library function @XScreenCount()@.
foreign import ccall unsafe "HsXlib.h XScreenCount"
screenCount :: Display -> CInt
-- | interface to the X11 library function @XDefaultVisual()@.
foreign import ccall unsafe "HsXlib.h XDefaultVisual"
defaultVisual :: Display -> ScreenNumber -> Visual
-- | interface to the X11 library function @XDisplayCells()@.
foreign import ccall unsafe "HsXlib.h XDisplayCells"
displayCells :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XDisplayPlanes()@.
foreign import ccall unsafe "HsXlib.h XDisplayPlanes"
displayPlanes :: Display -> ScreenNumber -> CInt
-- | interface to the X11 library function @XScreenOfDisplay()@.
foreign import ccall unsafe "HsXlib.h XScreenOfDisplay"
screenOfDisplay :: Display -> ScreenNumber -> Screen
-- | interface to the X11 library function @XDefaultRootWindow()@.
foreign import ccall unsafe "HsXlib.h XDefaultRootWindow"
defaultRootWindow :: Display -> Window
-- The following are believed to be order dependent
-- | interface to the X11 library function @XRootWindow()@.
foreign import ccall unsafe "HsXlib.h XRootWindow"
rootWindow :: Display -> ScreenNumber -> IO Window
-- | interface to the X11 library function @XQLength()@.
foreign import ccall unsafe "HsXlib.h XQLength"
qLength :: Display -> IO CInt
-- | interface to the X11 library function @XNoOp()@.
foreign import ccall unsafe "HsXlib.h XNoOp"
noOp :: Display -> IO ()
-- | interface to the X11 library function @XOpenDisplay()@.
openDisplay :: String -> IO Display
openDisplay name =
withCString name $ \ c_name -> do
display <- throwIfNull "openDisplay" (xOpenDisplay c_name)
return (Display display)
foreign import ccall unsafe "HsXlib.h XOpenDisplay"
xOpenDisplay :: CString -> IO (Ptr Display)
-- | interface to the X11 library function @XCloseDisplay()@.
foreign import ccall unsafe "HsXlib.h XCloseDisplay"
closeDisplay :: Display -> IO ()
-- | convert a CString owned by Xlib to a Haskell String
xlibCString :: IO CString -> String
xlibCString act = unsafePerformIO $ do
cs <- act
peekCString cs
----------------------------------------------------------------
-- End
----------------------------------------------------------------
|