{-# LINE 1 "Graphics/X11/Xlib/Misc.hsc" #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Graphics.X11.Xlib.Misc(
rmInitialize,
autoRepeatOff,
autoRepeatOn,
bell,
setCloseDownMode,
lastKnownRequestProcessed,
getInputFocus,
setInputFocus,
grabButton,
ungrabButton,
grabPointer,
ungrabPointer,
grabKey,
ungrabKey,
grabKeyboard,
ungrabKeyboard,
grabServer,
ungrabServer,
queryBestTile,
queryBestStipple,
queryBestCursor,
queryBestSize,
queryPointer,
displayName,
setDefaultErrorHandler,
geometry,
getGeometry,
supportsLocale,
setLocaleModifiers,
AllowExposuresMode,
dontAllowExposures,
allowExposures,
defaultExposures,
PreferBlankingMode,
dontPreferBlanking,
preferBlanking,
defaultBlanking,
ScreenSaverMode,
screenSaverActive,
screenSaverReset,
getScreenSaver,
setScreenSaver,
activateScreenSaver,
resetScreenSaver,
forceScreenSaver,
getPointerControl,
warpPointer,
visualIDFromVisual,
VisualInfoMask,
visualNoMask,
visualIDMask,
visualScreenMask,
visualDepthMask,
visualClassMask,
visualRedMaskMask,
visualGreenMaskMask,
visualBlueMaskMask,
visualColormapSizeMask,
visualBitsPerRGBMask,
visualAllMask,
getVisualInfo,
matchVisualInfo,
initThreads,
lockDisplay,
unlockDisplay,
createPixmap,
freePixmap,
bitmapBitOrder,
bitmapUnit,
bitmapPad,
readBitmapFile,
displayKeycodes,
lookupKeysym,
keycodeToKeysym,
keysymToKeycode,
keysymToString,
stringToKeysym,
noSymbol,
lookupString,
getIconName,
setIconName,
defineCursor,
undefineCursor,
createPixmapCursor,
createGlyphCursor,
createFontCursor,
freeCursor,
recolorCursor,
setWMProtocols,
allocaSetWindowAttributes,
set_background_pixmap,
set_background_pixel,
set_border_pixmap,
set_border_pixel,
set_bit_gravity,
set_win_gravity,
set_backing_store,
set_backing_planes,
set_backing_pixel,
set_save_under,
set_event_mask,
set_do_not_propagate_mask,
set_override_redirect,
set_colormap,
set_cursor,
drawPoint,
drawPoints,
drawLine,
drawLines,
drawSegments,
drawRectangle,
drawRectangles,
drawArc,
drawArcs,
fillRectangle,
fillRectangles,
fillPolygon,
fillArc,
fillArcs,
copyArea,
copyPlane,
drawString,
drawImageString,
storeBuffer,
storeBytes,
fetchBuffer,
fetchBytes,
rotateBuffers,
setTextProperty,
) where
import Graphics.X11.Types
import Graphics.X11.Xlib.Types
import Graphics.X11.Xlib.Atom
import Graphics.X11.Xlib.Event
import Graphics.X11.Xlib.Font
import Graphics.X11.Xlib.Internal
import Foreign (Storable, Ptr, alloca, peek, throwIfNull, with, withArrayLen, allocaBytes, pokeByteOff, withArray, FunPtr, nullPtr, Word32, peekArray)
import Foreign.C
import System.IO.Unsafe
{-# LINE 195 "Graphics/X11/Xlib/Misc.hsc" #-}
import Data.Data
{-# LINE 197 "Graphics/X11/Xlib/Misc.hsc" #-}
foreign import ccall unsafe "HsXlib.h XrmInitialize"
rmInitialize :: IO ()
foreign import ccall unsafe "HsXlib.h XAutoRepeatOff"
autoRepeatOff :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XAutoRepeatOn"
autoRepeatOn :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XBell"
bell :: Display -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XSetCloseDownMode"
setCloseDownMode :: Display -> CloseDownMode -> IO ()
foreign import ccall unsafe "HsXlib.h XLastKnownRequestProcessed"
lastKnownRequestProcessed :: Display -> IO CInt
getInputFocus :: Display -> IO (Window, FocusMode)
getInputFocus display =
alloca $ \ focus_return ->
alloca $ \ revert_to_return -> do
xGetInputFocus display focus_return revert_to_return
focus <- peek focus_return
revert_to <- peek revert_to_return
return (focus, revert_to)
foreign import ccall unsafe "HsXlib.h XGetInputFocus"
xGetInputFocus :: Display -> Ptr Window -> Ptr FocusMode -> IO ()
foreign import ccall unsafe "HsXlib.h XSetInputFocus"
setInputFocus :: Display -> Window -> FocusMode -> Time -> IO ()
foreign import ccall unsafe "HsXlib.h XGrabButton"
grabButton :: Display -> Button -> ButtonMask -> Window -> Bool -> EventMask -> GrabMode -> GrabMode -> Window -> Cursor -> IO ()
foreign import ccall unsafe "HsXlib.h XUngrabButton"
ungrabButton :: Display -> Button -> ButtonMask -> Window -> IO ()
foreign import ccall unsafe "HsXlib.h XGrabPointer"
grabPointer :: Display -> Window -> Bool -> EventMask -> GrabMode -> GrabMode -> Window -> Cursor -> Time -> IO GrabStatus
foreign import ccall unsafe "HsXlib.h XUngrabPointer"
ungrabPointer :: Display -> Time -> IO ()
foreign import ccall unsafe "HsXlib.h XGrabKey"
grabKey :: Display -> KeyCode -> KeyMask -> Window -> Bool -> GrabMode -> GrabMode -> IO ()
foreign import ccall unsafe "HsXlib.h XUngrabKey"
ungrabKey :: Display -> KeyCode -> KeyMask -> Window -> IO ()
foreign import ccall unsafe "HsXlib.h XGrabKeyboard"
grabKeyboard :: Display -> Window -> Bool -> GrabMode -> GrabMode -> Time -> IO GrabStatus
foreign import ccall unsafe "HsXlib.h XUngrabKeyboard"
ungrabKeyboard :: Display -> Time -> IO ()
foreign import ccall unsafe "HsXlib.h XGrabServer"
grabServer :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XUngrabServer"
ungrabServer :: Display -> IO ()
queryBestTile :: Display -> Drawable -> Dimension -> Dimension ->
IO (Dimension, Dimension)
queryBestTile display which_screen width height =
outParameters2 (throwIfZero "queryBestTile") $
xQueryBestTile display which_screen width height
foreign import ccall unsafe "HsXlib.h XQueryBestTile"
xQueryBestTile :: Display -> Drawable -> Dimension -> Dimension ->
Ptr Dimension -> Ptr Dimension -> IO Status
queryBestStipple :: Display -> Drawable -> Dimension -> Dimension ->
IO (Dimension, Dimension)
queryBestStipple display which_screen width height =
outParameters2 (throwIfZero "queryBestStipple") $
xQueryBestStipple display which_screen width height
foreign import ccall unsafe "HsXlib.h XQueryBestStipple"
xQueryBestStipple :: Display -> Drawable -> Dimension -> Dimension ->
Ptr Dimension -> Ptr Dimension -> IO Status
queryBestCursor :: Display -> Drawable -> Dimension -> Dimension ->
IO (Dimension, Dimension)
queryBestCursor display d width height =
outParameters2 (throwIfZero "queryBestCursor") $
xQueryBestCursor display d width height
foreign import ccall unsafe "HsXlib.h XQueryBestCursor"
xQueryBestCursor :: Display -> Drawable -> Dimension -> Dimension ->
Ptr Dimension -> Ptr Dimension -> IO Status
queryBestSize :: Display -> QueryBestSizeClass -> Drawable ->
Dimension -> Dimension -> IO (Dimension, Dimension)
queryBestSize display shape_class which_screen width height =
outParameters2 (throwIfZero "queryBestSize") $
xQueryBestSize display shape_class which_screen width height
foreign import ccall unsafe "HsXlib.h XQueryBestSize"
xQueryBestSize :: Display -> QueryBestSizeClass -> Drawable ->
Dimension -> Dimension ->
Ptr Dimension -> Ptr Dimension -> IO Status
queryPointer :: Display -> Window ->
IO (Bool, Window, Window, CInt, CInt, CInt, CInt, Modifier)
queryPointer display w =
alloca $ \ root_return ->
alloca $ \ child_return ->
alloca $ \ root_x_return ->
alloca $ \ root_y_return ->
alloca $ \ win_x_return ->
alloca $ \ win_y_return ->
alloca $ \ mask_return -> do
rel <- xQueryPointer display w root_return child_return root_x_return
root_y_return win_x_return win_y_return mask_return
root <- peek root_return
child <- peek child_return
root_x <- peek root_x_return
root_y <- peek root_y_return
win_x <- peek win_x_return
win_y <- peek win_y_return
mask <- peek mask_return
return (rel, root, child, root_x, root_y, win_x, win_y, mask)
foreign import ccall unsafe "HsXlib.h XQueryPointer"
xQueryPointer :: Display -> Window ->
Ptr Window -> Ptr Window -> Ptr CInt -> Ptr CInt ->
Ptr CInt -> Ptr CInt -> Ptr Modifier -> IO Bool
displayName :: String -> String
displayName str = unsafePerformIO $
withCString str $ \ c_str -> do
c_name <- xDisplayName c_str
peekCString c_name
foreign import ccall unsafe "HsXlib.h XDisplayName"
xDisplayName :: CString -> IO CString
{-# CFILES cbits/auxiliaries.c #-}
newtype XErrorEvent = XErrorEvent (Ptr XErrorEvent)
{-# LINE 467 "Graphics/X11/Xlib/Misc.hsc" #-}
deriving (Eq, Ord, Show, Typeable, Data)
{-# LINE 471 "Graphics/X11/Xlib/Misc.hsc" #-}
type ErrorHandler = FunPtr (Display -> Ptr XErrorEvent -> IO CInt)
foreign import ccall unsafe "HsXlib.h &defaultErrorHandler"
defaultErrorHandler :: FunPtr (Display -> Ptr XErrorEvent -> IO CInt)
setDefaultErrorHandler :: IO ()
setDefaultErrorHandler = do
_ <- xSetErrorHandler defaultErrorHandler
return ()
foreign import ccall unsafe "HsXlib.h XSetErrorHandler"
xSetErrorHandler :: ErrorHandler -> IO ErrorHandler
geometry :: Display -> CInt -> String -> String ->
Dimension -> Dimension -> Dimension -> CInt -> CInt ->
IO (CInt, Position, Position, Dimension, Dimension)
geometry display screen position default_position
bwidth fwidth fheight xadder yadder =
withCString position $ \ c_position ->
withCString default_position $ \ c_default_position ->
alloca $ \ x_return ->
alloca $ \ y_return ->
alloca $ \ width_return ->
alloca $ \ height_return -> do
res <- xGeometry display screen c_position c_default_position
bwidth fwidth fheight xadder yadder
x_return y_return width_return height_return
x <- peek x_return
y <- peek y_return
width <- peek width_return
height <- peek height_return
return (res, x, y, width, height)
foreign import ccall unsafe "HsXlib.h XGeometry"
xGeometry :: Display -> CInt -> CString -> CString ->
Dimension -> Dimension -> Dimension -> CInt -> CInt ->
Ptr Position -> Ptr Position ->
Ptr Dimension -> Ptr Dimension -> IO CInt
getGeometry :: Display -> Drawable ->
IO (Window, Position, Position, Dimension, Dimension, Dimension, CInt)
getGeometry display d =
outParameters7 (throwIfZero "getGeometry") $
xGetGeometry display d
foreign import ccall unsafe "HsXlib.h XGetGeometry"
xGetGeometry :: Display -> Drawable ->
Ptr Window -> Ptr Position -> Ptr Position -> Ptr Dimension ->
Ptr Dimension -> Ptr Dimension -> Ptr CInt -> IO Status
foreign import ccall unsafe "HsXlib.h XSupportsLocale"
supportsLocale :: IO Bool
setLocaleModifiers :: String -> IO String
setLocaleModifiers mods =
withCString mods $ \ modifier_list -> do
c_str <- xSetLocaleModifiers modifier_list
peekCString c_str
foreign import ccall unsafe "HsXlib.h XSetLocaleModifiers"
xSetLocaleModifiers :: CString -> IO CString
type AllowExposuresMode = CInt
dontAllowExposures :: AllowExposuresMode
dontAllowExposures = 0
allowExposures :: AllowExposuresMode
allowExposures = 1
defaultExposures :: AllowExposuresMode
defaultExposures = 2
{-# LINE 633 "Graphics/X11/Xlib/Misc.hsc" #-}
type PreferBlankingMode = CInt
dontPreferBlanking :: PreferBlankingMode
dontPreferBlanking = 0
preferBlanking :: PreferBlankingMode
preferBlanking = 1
defaultBlanking :: PreferBlankingMode
defaultBlanking = 2
{-# LINE 640 "Graphics/X11/Xlib/Misc.hsc" #-}
type ScreenSaverMode = CInt
screenSaverActive :: ScreenSaverMode
screenSaverActive = 1
screenSaverReset :: ScreenSaverMode
screenSaverReset = 0
{-# LINE 646 "Graphics/X11/Xlib/Misc.hsc" #-}
getScreenSaver :: Display ->
IO (CInt, CInt, PreferBlankingMode, AllowExposuresMode)
getScreenSaver display = outParameters4 id (xGetScreenSaver display)
foreign import ccall unsafe "HsXlib.h XGetScreenSaver"
xGetScreenSaver :: Display -> Ptr CInt -> Ptr CInt ->
Ptr PreferBlankingMode -> Ptr AllowExposuresMode -> IO ()
foreign import ccall unsafe "HsXlib.h XSetScreenSaver"
setScreenSaver :: Display -> CInt -> CInt ->
PreferBlankingMode -> AllowExposuresMode -> IO ()
foreign import ccall unsafe "HsXlib.h XActivateScreenSaver"
activateScreenSaver :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XResetScreenSaver"
resetScreenSaver :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XForceScreenSaver"
forceScreenSaver :: Display -> ScreenSaverMode -> IO ()
getPointerControl :: Display -> IO (CInt, CInt, CInt)
getPointerControl display = outParameters3 id (xGetPointerControl display)
foreign import ccall unsafe "HsXlib.h XGetPointerControl"
xGetPointerControl :: Display -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XWarpPointer"
warpPointer :: Display -> Window -> Window -> Position -> Position ->
Dimension -> Dimension -> Position -> Position -> IO ()
foreign import ccall unsafe "HsXlib.h XVisualIDFromVisual"
visualIDFromVisual :: Visual -> IO VisualID
type VisualInfoMask = CLong
visualNoMask :: VisualInfoMask
visualNoMask = 0
visualIDMask :: VisualInfoMask
visualIDMask = 1
visualScreenMask :: VisualInfoMask
visualScreenMask = 2
visualDepthMask :: VisualInfoMask
visualDepthMask = 4
visualClassMask :: VisualInfoMask
visualClassMask = 8
visualRedMaskMask :: VisualInfoMask
visualRedMaskMask = 16
visualGreenMaskMask :: VisualInfoMask
visualGreenMaskMask = 32
visualBlueMaskMask :: VisualInfoMask
visualBlueMaskMask = 64
visualColormapSizeMask :: VisualInfoMask
visualColormapSizeMask = 128
visualBitsPerRGBMask :: VisualInfoMask
visualBitsPerRGBMask = 256
visualAllMask :: VisualInfoMask
visualAllMask = 511
{-# LINE 711 "Graphics/X11/Xlib/Misc.hsc" #-}
getVisualInfo :: Display -> VisualInfoMask -> VisualInfo -> IO [VisualInfo]
getVisualInfo dpy mask template =
alloca $ \nItemsPtr ->
with template $ \templatePtr -> do
itemsPtr <- xGetVisualInfo dpy mask templatePtr nItemsPtr
if itemsPtr == nullPtr
then return []
else do
nItems <- peek nItemsPtr
items <- peekArray (fromIntegral nItems) itemsPtr
_ <- xFree itemsPtr
return items
foreign import ccall unsafe "XGetVisualInfo"
xGetVisualInfo :: Display -> VisualInfoMask -> Ptr VisualInfo ->
Ptr CInt -> IO (Ptr VisualInfo)
matchVisualInfo
:: Display -> ScreenNumber -> CInt -> CInt -> IO (Maybe VisualInfo)
matchVisualInfo dpy screen depth class_ =
alloca $ \infoPtr -> do
status <- xMatchVisualInfo dpy screen depth class_ infoPtr
if status == 0
then return Nothing
else do
info <- peek infoPtr
return $ Just info
foreign import ccall unsafe "XMatchVisualInfo"
xMatchVisualInfo :: Display -> ScreenNumber -> CInt -> CInt ->
Ptr VisualInfo -> IO Status
foreign import ccall unsafe "HsXlib.h XInitThreads"
initThreads :: IO Status
foreign import ccall unsafe "HsXlib.h XLockDisplay"
lockDisplay :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XUnlockDisplay"
unlockDisplay :: Display -> IO ()
foreign import ccall unsafe "HsXlib.h XCreatePixmap"
createPixmap :: Display -> Drawable -> Dimension -> Dimension -> CInt -> IO Pixmap
foreign import ccall unsafe "HsXlib.h XFreePixmap"
freePixmap :: Display -> Pixmap -> IO ()
foreign import ccall unsafe "HsXlib.h XBitmapBitOrder"
bitmapBitOrder :: Display -> ByteOrder
foreign import ccall unsafe "HsXlib.h XBitmapUnit"
bitmapUnit :: Display -> CInt
foreign import ccall unsafe "HsXlib.h XBitmapPad"
bitmapPad :: Display -> CInt
readBitmapFile :: Display -> Drawable -> String
-> IO (Either String (Dimension, Dimension, Pixmap, Maybe CInt, Maybe CInt))
readBitmapFile display d filename =
withCString filename $ \ c_filename ->
alloca $ \ width_return ->
alloca $ \ height_return ->
alloca $ \ bitmap_return ->
alloca $ \ x_hot_return ->
alloca $ \ y_hot_return -> do
rv <- xReadBitmapFile display d c_filename width_return height_return
bitmap_return x_hot_return y_hot_return
width <- peek width_return
height <- peek height_return
bitmap <- peek bitmap_return
x_hot <- peek x_hot_return
y_hot <- peek y_hot_return
let m_x_hot | x_hot == -1 = Nothing
| otherwise = Just x_hot
m_y_hot | y_hot == -1 = Nothing
| otherwise = Just y_hot
case rv of
0 -> return $ Right (width, height, bitmap, m_x_hot, m_y_hot)
1 -> return $ Left "readBitmapFile: BitmapOpenFailed"
2 -> return $ Left "readBitmapFile: BitmapFileInvalid"
3 -> return $ Left "readBitmapFile: BitmapNoMemory"
_ -> return $ Left "readBitmapFile: BitmapUnknownError"
foreign import ccall unsafe "X11/Xlib.h XReadBitmapFile"
xReadBitmapFile :: Display -> Drawable -> CString -> Ptr Dimension -> Ptr Dimension
-> Ptr Pixmap -> Ptr CInt -> Ptr CInt -> IO CInt
displayKeycodes :: Display -> (CInt,CInt)
displayKeycodes display =
unsafePerformIO $ outParameters2 id $ xDisplayKeycodes display
foreign import ccall unsafe "HsXlib.h XDisplayKeycodes"
xDisplayKeycodes :: Display -> Ptr CInt -> Ptr CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XLookupKeysym"
lookupKeysym :: XKeyEventPtr -> CInt -> IO KeySym
foreign import ccall unsafe "HsXlib.h XKeycodeToKeysym"
keycodeToKeysym :: Display -> KeyCode -> CInt -> IO KeySym
foreign import ccall unsafe "HsXlib.h XKeysymToKeycode"
keysymToKeycode :: Display -> KeySym -> IO KeyCode
keysymToString :: KeySym -> String
keysymToString keysym = unsafePerformIO $ do
c_str <- xKeysymToString keysym
peekCString c_str
foreign import ccall unsafe "HsXlib.h XKeysymToString"
xKeysymToString :: KeySym -> IO CString
stringToKeysym :: String -> KeySym
stringToKeysym str = unsafePerformIO $
withCString str $ \ c_str ->
xStringToKeysym c_str
foreign import ccall unsafe "HsXlib.h XStringToKeysym"
xStringToKeysym :: CString -> IO KeySym
noSymbol :: KeySym
noSymbol = 0
{-# LINE 897 "Graphics/X11/Xlib/Misc.hsc" #-}
newtype XComposeStatus = XComposeStatus (Ptr XComposeStatus)
{-# LINE 900 "Graphics/X11/Xlib/Misc.hsc" #-}
deriving (Eq, Ord, Show, Typeable, Data)
{-# LINE 904 "Graphics/X11/Xlib/Misc.hsc" #-}
lookupString :: XKeyEventPtr -> IO (Maybe KeySym, String)
lookupString event_ptr =
allocaBytes 100 $ \ buf ->
alloca $ \ keysym_return -> do
n <- xLookupString event_ptr buf 100 keysym_return nullPtr
str <- peekCStringLen (buf, fromIntegral n)
keysym <- peek keysym_return
return (if keysym == noSymbol then Nothing else Just keysym, str)
foreign import ccall unsafe "HsXlib.h XLookupString"
xLookupString :: XKeyEventPtr -> CString -> CInt ->
Ptr KeySym -> Ptr XComposeStatus -> IO CInt
getIconName :: Display -> Window -> IO String
getIconName display w =
alloca $ \ icon_name_return -> do
throwIfZero "getIconName" $
xGetIconName display w icon_name_return
c_icon_name <- peek icon_name_return
peekCString c_icon_name
foreign import ccall unsafe "HsXlib.h XGetIconName"
xGetIconName :: Display -> Window -> Ptr CString -> IO Status
setIconName :: Display -> Window -> String -> IO ()
setIconName display w icon_name =
withCString icon_name $ \ c_icon_name ->
xSetIconName display w c_icon_name
foreign import ccall unsafe "HsXlib.h XSetIconName"
xSetIconName :: Display -> Window -> CString -> IO ()
foreign import ccall unsafe "HsXlib.h XDefineCursor"
defineCursor :: Display -> Window -> Cursor -> IO ()
foreign import ccall unsafe "HsXlib.h XUndefineCursor"
undefineCursor :: Display -> Window -> IO ()
createPixmapCursor :: Display -> Pixmap -> Pixmap -> Color -> Color ->
Dimension -> Dimension -> IO Cursor
createPixmapCursor display source mask fg_color bg_color x y =
with fg_color $ \ fg_color_ptr ->
with bg_color $ \ bg_color_ptr ->
xCreatePixmapCursor display source mask fg_color_ptr bg_color_ptr x y
foreign import ccall unsafe "HsXlib.h XCreatePixmapCursor"
xCreatePixmapCursor :: Display -> Pixmap -> Pixmap ->
Ptr Color -> Ptr Color -> Dimension -> Dimension -> IO Cursor
createGlyphCursor :: Display -> Font -> Font -> Glyph -> Glyph ->
Color -> Color -> IO Cursor
createGlyphCursor display source_font mask_font source_char mask_char
fg_color bg_color =
with fg_color $ \ fg_color_ptr ->
with bg_color $ \ bg_color_ptr ->
xCreateGlyphCursor display source_font mask_font source_char mask_char
fg_color_ptr bg_color_ptr
foreign import ccall unsafe "HsXlib.h XCreateGlyphCursor"
xCreateGlyphCursor :: Display -> Font -> Font -> Glyph -> Glyph ->
Ptr Color -> Ptr Color -> IO Cursor
foreign import ccall unsafe "HsXlib.h XCreateFontCursor"
createFontCursor :: Display -> Glyph -> IO Cursor
foreign import ccall unsafe "HsXlib.h XFreeCursor"
freeCursor :: Display -> Font -> IO ()
recolorCursor :: Display -> Cursor -> Color -> Color -> IO ()
recolorCursor display cursor fg_color bg_color =
with fg_color $ \ fg_color_ptr ->
with bg_color $ \ bg_color_ptr ->
xRecolorCursor display cursor fg_color_ptr bg_color_ptr
foreign import ccall unsafe "HsXlib.h XRecolorCursor"
xRecolorCursor :: Display -> Cursor -> Ptr Color -> Ptr Color -> IO ()
setWMProtocols :: Display -> Window -> [Atom] -> IO ()
setWMProtocols display w protocols =
withArray protocols $ \ protocol_array ->
xSetWMProtocols display w protocol_array (fromIntegral $ length protocols)
foreign import ccall unsafe "HsXlib.h XSetWMProtocols"
xSetWMProtocols :: Display -> Window -> Ptr Atom -> CInt -> IO ()
allocaSetWindowAttributes :: (Ptr SetWindowAttributes -> IO a) -> IO a
allocaSetWindowAttributes = allocaBytes (112)
{-# LINE 1035 "Graphics/X11/Xlib/Misc.hsc" #-}
set_background_pixmap :: Ptr SetWindowAttributes -> Pixmap -> IO ()
set_background_pixmap = (\hsc_ptr -> pokeByteOff hsc_ptr 0)
{-# LINE 1040 "Graphics/X11/Xlib/Misc.hsc" #-}
set_background_pixel :: Ptr SetWindowAttributes -> Pixel -> IO ()
set_background_pixel = (\hsc_ptr -> pokeByteOff hsc_ptr 8)
{-# LINE 1043 "Graphics/X11/Xlib/Misc.hsc" #-}
set_border_pixmap :: Ptr SetWindowAttributes -> Pixmap -> IO ()
set_border_pixmap = (\hsc_ptr -> pokeByteOff hsc_ptr 16)
{-# LINE 1046 "Graphics/X11/Xlib/Misc.hsc" #-}
set_border_pixel :: Ptr SetWindowAttributes -> Pixel -> IO ()
set_border_pixel = (\hsc_ptr -> pokeByteOff hsc_ptr 24)
{-# LINE 1049 "Graphics/X11/Xlib/Misc.hsc" #-}
set_bit_gravity :: Ptr SetWindowAttributes -> BitGravity -> IO ()
set_bit_gravity = (\hsc_ptr -> pokeByteOff hsc_ptr 32)
{-# LINE 1052 "Graphics/X11/Xlib/Misc.hsc" #-}
set_win_gravity :: Ptr SetWindowAttributes -> WindowGravity -> IO ()
set_win_gravity = (\hsc_ptr -> pokeByteOff hsc_ptr 36)
{-# LINE 1055 "Graphics/X11/Xlib/Misc.hsc" #-}
set_backing_store :: Ptr SetWindowAttributes -> BackingStore -> IO ()
set_backing_store = (\hsc_ptr -> pokeByteOff hsc_ptr 40)
{-# LINE 1058 "Graphics/X11/Xlib/Misc.hsc" #-}
set_backing_planes :: Ptr SetWindowAttributes -> Pixel -> IO ()
set_backing_planes = (\hsc_ptr -> pokeByteOff hsc_ptr 48)
{-# LINE 1061 "Graphics/X11/Xlib/Misc.hsc" #-}
set_backing_pixel :: Ptr SetWindowAttributes -> Pixel -> IO ()
set_backing_pixel = (\hsc_ptr -> pokeByteOff hsc_ptr 56)
{-# LINE 1064 "Graphics/X11/Xlib/Misc.hsc" #-}
set_save_under :: Ptr SetWindowAttributes -> Bool -> IO ()
set_save_under = (\hsc_ptr -> pokeByteOff hsc_ptr 64)
{-# LINE 1067 "Graphics/X11/Xlib/Misc.hsc" #-}
set_event_mask :: Ptr SetWindowAttributes -> EventMask -> IO ()
set_event_mask = (\hsc_ptr -> pokeByteOff hsc_ptr 72)
{-# LINE 1070 "Graphics/X11/Xlib/Misc.hsc" #-}
set_do_not_propagate_mask :: Ptr SetWindowAttributes -> EventMask -> IO ()
set_do_not_propagate_mask = (\hsc_ptr -> pokeByteOff hsc_ptr 80)
{-# LINE 1073 "Graphics/X11/Xlib/Misc.hsc" #-}
set_override_redirect :: Ptr SetWindowAttributes -> Bool -> IO ()
set_override_redirect = (\hsc_ptr -> pokeByteOff hsc_ptr 88)
{-# LINE 1076 "Graphics/X11/Xlib/Misc.hsc" #-}
set_colormap :: Ptr SetWindowAttributes -> Colormap -> IO ()
set_colormap = (\hsc_ptr -> pokeByteOff hsc_ptr 96)
{-# LINE 1079 "Graphics/X11/Xlib/Misc.hsc" #-}
set_cursor :: Ptr SetWindowAttributes -> Cursor -> IO ()
set_cursor = (\hsc_ptr -> pokeByteOff hsc_ptr 104)
{-# LINE 1082 "Graphics/X11/Xlib/Misc.hsc" #-}
foreign import ccall unsafe "HsXlib.h XDrawPoint"
drawPoint :: Display -> Drawable -> GC -> Position -> Position -> IO ()
drawPoints :: Display -> Drawable -> GC -> [Point] -> CoordinateMode -> IO ()
drawPoints display d gc points mode =
withArrayLen points $ \ npoints point_array ->
xDrawPoints display d gc point_array (fromIntegral npoints) mode
foreign import ccall unsafe "HsXlib.h XDrawPoints"
xDrawPoints :: Display -> Drawable -> GC -> Ptr Point -> CInt ->
CoordinateMode -> IO ()
foreign import ccall unsafe "HsXlib.h XDrawLine"
drawLine :: Display -> Drawable -> GC -> Position -> Position ->
Position -> Position -> IO ()
drawLines :: Display -> Drawable -> GC -> [Point] -> CoordinateMode -> IO ()
drawLines display d gc points mode =
withArrayLen points $ \ npoints point_array ->
xDrawLines display d gc point_array (fromIntegral npoints) mode
foreign import ccall unsafe "HsXlib.h XDrawLines"
xDrawLines :: Display -> Drawable -> GC -> Ptr Point -> CInt ->
CoordinateMode -> IO ()
drawSegments :: Display -> Drawable -> GC -> [Segment] -> IO ()
drawSegments display d gc segments =
withArrayLen segments $ \ nsegments segment_array ->
xDrawSegments display d gc segment_array (fromIntegral nsegments)
foreign import ccall unsafe "HsXlib.h XDrawSegments"
xDrawSegments :: Display -> Drawable -> GC -> Ptr Segment -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XDrawRectangle"
drawRectangle :: Display -> Drawable -> GC -> Position -> Position -> Dimension -> Dimension -> IO ()
drawRectangles :: Display -> Drawable -> GC -> [Rectangle] -> IO ()
drawRectangles display d gc rectangles =
withArrayLen rectangles $ \ nrectangles rectangle_array ->
xDrawRectangles display d gc rectangle_array (fromIntegral nrectangles)
foreign import ccall unsafe "HsXlib.h XDrawRectangles"
xDrawRectangles :: Display -> Drawable -> GC -> Ptr Rectangle -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XDrawArc"
drawArc :: Display -> Drawable -> GC -> Position -> Position ->
Dimension -> Dimension -> Angle -> Angle -> IO ()
drawArcs :: Display -> Drawable -> GC -> [Arc] -> IO ()
drawArcs display d gc arcs =
withArrayLen arcs $ \ narcs arc_array ->
xDrawArcs display d gc arc_array (fromIntegral narcs)
foreign import ccall unsafe "HsXlib.h XDrawArcs"
xDrawArcs :: Display -> Drawable -> GC -> Ptr Arc -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XFillRectangle"
fillRectangle :: Display -> Drawable -> GC -> Position -> Position ->
Dimension -> Dimension -> IO ()
fillRectangles :: Display -> Drawable -> GC -> [Rectangle] -> IO ()
fillRectangles display d gc rectangles =
withArrayLen rectangles $ \ nrectangles rectangle_array ->
xFillRectangles display d gc rectangle_array (fromIntegral nrectangles)
foreign import ccall unsafe "HsXlib.h XFillRectangles"
xFillRectangles :: Display -> Drawable -> GC -> Ptr Rectangle -> CInt -> IO ()
fillPolygon :: Display -> Drawable -> GC -> [Point] -> PolygonShape -> CoordinateMode -> IO ()
fillPolygon display d gc points shape mode =
withArrayLen points $ \ npoints point_array ->
xFillPolygon display d gc point_array (fromIntegral npoints) shape mode
foreign import ccall unsafe "HsXlib.h XFillPolygon"
xFillPolygon :: Display -> Drawable -> GC -> Ptr Point -> CInt -> PolygonShape -> CoordinateMode -> IO ()
foreign import ccall unsafe "HsXlib.h XFillArc"
fillArc :: Display -> Drawable -> GC -> Position -> Position ->
Dimension -> Dimension -> Angle -> Angle -> IO ()
fillArcs :: Display -> Drawable -> GC -> [Arc] -> IO ()
fillArcs display d gc arcs =
withArrayLen arcs $ \ narcs arc_array ->
xFillArcs display d gc arc_array (fromIntegral narcs)
foreign import ccall unsafe "HsXlib.h XFillArcs"
xFillArcs :: Display -> Drawable -> GC -> Ptr Arc -> CInt -> IO ()
foreign import ccall unsafe "HsXlib.h XCopyArea"
copyArea :: Display -> Drawable -> Drawable -> GC -> Position -> Position -> Dimension -> Dimension -> Position -> Position -> IO ()
foreign import ccall unsafe "HsXlib.h XCopyPlane"
copyPlane :: Display -> Drawable -> Drawable -> GC -> Position -> Position -> Dimension -> Dimension -> Position -> Position -> Pixel -> IO ()
drawString :: Display -> Drawable -> GC -> Position -> Position -> String -> IO ()
drawString display d gc x y str =
withCStringLen str $ \ (c_str, len) ->
xDrawString display d gc x y c_str (fromIntegral len)
foreign import ccall unsafe "HsXlib.h XDrawString"
xDrawString :: Display -> Drawable -> GC -> Position -> Position -> CString -> CInt -> IO ()
drawImageString :: Display -> Drawable -> GC -> Position -> Position -> String -> IO ()
drawImageString display d gc x y str =
withCStringLen str $ \ (c_str, len) ->
xDrawImageString display d gc x y c_str (fromIntegral len)
foreign import ccall unsafe "HsXlib.h XDrawImageString"
xDrawImageString :: Display -> Drawable -> GC -> Position -> Position -> CString -> CInt -> IO ()
storeBuffer :: Display -> String -> CInt -> IO ()
storeBuffer display bytes buffer =
withCStringLen bytes $ \ (c_bytes, nbytes) ->
throwIfZero "storeBuffer" $
xStoreBuffer display c_bytes (fromIntegral nbytes) buffer
foreign import ccall unsafe "HsXlib.h XStoreBuffer"
xStoreBuffer :: Display -> CString -> CInt -> CInt -> IO Status
storeBytes :: Display -> String -> IO ()
storeBytes display bytes =
withCStringLen bytes $ \ (c_bytes, nbytes) ->
throwIfZero "storeBytes" $
xStoreBytes display c_bytes (fromIntegral nbytes)
foreign import ccall unsafe "HsXlib.h XStoreBytes"
xStoreBytes :: Display -> CString -> CInt -> IO Status
fetchBuffer :: Display -> CInt -> IO String
fetchBuffer display buffer =
alloca $ \ nbytes_return -> do
c_bytes <- throwIfNull "fetchBuffer" $
xFetchBuffer display nbytes_return buffer
nbytes <- peek nbytes_return
bytes <- peekCStringLen (c_bytes, (fromIntegral nbytes))
_ <- xFree c_bytes
return bytes
foreign import ccall unsafe "HsXlib.h XFetchBuffer"
xFetchBuffer :: Display -> Ptr CInt -> CInt -> IO CString
fetchBytes :: Display -> IO String
fetchBytes display =
alloca $ \ nbytes_return -> do
c_bytes <- throwIfNull "fetchBytes" $
xFetchBytes display nbytes_return
nbytes <- peek nbytes_return
bytes <- peekCStringLen (c_bytes, (fromIntegral nbytes))
_ <- xFree c_bytes
return bytes
foreign import ccall unsafe "HsXlib.h XFetchBytes"
xFetchBytes :: Display -> Ptr CInt -> IO CString
rotateBuffers :: Display -> CInt -> IO ()
rotateBuffers display rot =
throwIfZero "rotateBuffers" $
xRotateBuffers display rot
foreign import ccall unsafe "HsXlib.h XRotateBuffers"
xRotateBuffers :: Display -> CInt -> IO Status
newtype XTextProperty = XTextProperty (Ptr XTextProperty)
{-# LINE 1276 "Graphics/X11/Xlib/Misc.hsc" #-}
deriving (Eq, Ord, Show, Typeable, Data)
{-# LINE 1280 "Graphics/X11/Xlib/Misc.hsc" #-}
setTextProperty :: Display -> Window -> String -> Atom -> IO ()
setTextProperty display w value property =
withCStringLen value $ \ (c_value, value_len) ->
allocaBytes (32) $ \ text_prop -> do
{-# LINE 1286 "Graphics/X11/Xlib/Misc.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 0) text_prop c_value
{-# LINE 1287 "Graphics/X11/Xlib/Misc.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) text_prop sTRING
{-# LINE 1288 "Graphics/X11/Xlib/Misc.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 16) text_prop (8::CInt)
{-# LINE 1289 "Graphics/X11/Xlib/Misc.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 24) text_prop (fromIntegral value_len::Word32)
{-# LINE 1290 "Graphics/X11/Xlib/Misc.hsc" #-}
xSetTextProperty display w text_prop property
foreign import ccall unsafe "HsXlib.h XSetTextProperty"
xSetTextProperty :: Display -> Window -> Ptr XTextProperty -> Atom -> IO ()
outParameters2 :: (Storable a, Storable b) =>
(IO r -> IO ()) -> (Ptr a -> Ptr b -> IO r) -> IO (a,b)
outParameters2 check fn =
alloca $ \ a_return ->
alloca $ \ b_return -> do
check (fn a_return b_return)
a <- peek a_return
b <- peek b_return
return (a,b)
outParameters3 :: (Storable a, Storable b, Storable c) =>
(IO r -> IO ()) -> (Ptr a -> Ptr b -> Ptr c -> IO r) -> IO (a,b,c)
outParameters3 check fn =
alloca $ \ a_return ->
alloca $ \ b_return ->
alloca $ \ c_return -> do
check (fn a_return b_return c_return)
a <- peek a_return
b <- peek b_return
c <- peek c_return
return (a,b,c)
outParameters4 :: (Storable a, Storable b, Storable c, Storable d) =>
(IO r -> IO ()) -> (Ptr a -> Ptr b -> Ptr c -> Ptr d -> IO r) ->
IO (a,b,c,d)
outParameters4 check fn =
alloca $ \ a_return ->
alloca $ \ b_return ->
alloca $ \ c_return ->
alloca $ \ d_return -> do
check (fn a_return b_return c_return d_return)
a <- peek a_return
b <- peek b_return
c <- peek c_return
d <- peek d_return
return (a,b,c,d)
outParameters7 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) =>
(IO r -> IO ()) -> (Ptr a -> Ptr b -> Ptr c -> Ptr d -> Ptr e -> Ptr f -> Ptr g -> IO r) ->
IO (a,b,c,d,e,f,g)
outParameters7 check fn =
alloca $ \ a_return ->
alloca $ \ b_return ->
alloca $ \ c_return ->
alloca $ \ d_return ->
alloca $ \ e_return ->
alloca $ \ f_return ->
alloca $ \ g_return -> do
check (fn a_return b_return c_return d_return e_return f_return g_return)
a <- peek a_return
b <- peek b_return
c <- peek c_return
d <- peek d_return
e <- peek e_return
f <- peek f_return
g <- peek g_return
return (a,b,c,d,e,f,g)