X11-xshape (empty) → 0.1.0
raw patch · 4 files changed
+276/−0 lines, 4 filesdep +X11dep +basesetup-changed
Dependencies added: X11, base
Files
- Graphics/X11/Xshape.hsc +223/−0
- LICENSE +26/−0
- Setup.hs +6/−0
- X11-xshape.cabal +21/−0
+ Graphics/X11/Xshape.hsc view
@@ -0,0 +1,223 @@+--------------------------------------------------------------------+-- |+-- Module : Graphics.X11.Xshape+-- Copyright : (c) Haskell.org, 2009+-- License : BSD3+--+-- Maintainer: Ewan Higgs <ewan_higgs@yahoo.co.uk>+-- Stability : unstable +-- Portability: unportable +--+--------------------------------------------------------------------+--+-- Interface to Xshape API+--++module Graphics.X11.Xshape( xshapeQueryExtension+ , xshapeQueryVersion+ , xshapeCombineRegion + , xshapeCombineRectangles + , xshapeCombineMask + , xshapeCombineShape + , xshapeOffsetShape + , xshapeQueryExtents + , xshapeSelectInput + , xshapeInputSelected+ -- , xshapeGetRectangles+ , shapeQueryVersion+ , shapeRectangles+ , shapeMask+ , shapeCombine+ , shapeOffset+ , shapeQueryExtents+ , shapeSelectInput+ , shapeInputSelected+ , shapeGetRectangles+ , shapeSet+ , shapeUnion+ , shapeIntersect+ , shapeSubtract+ , shapeInvert+ , shapeBounding+ , shapeClip+ , shapeInput+ , shapeNotifyMask+ , shapeNotify+ , shapeNumberEvents+) where++import Foreign+import Foreign.C.Types+import Graphics.X11.Xlib+import Control.Monad++data XShapeEvent = XShapeEvent+ { xse_type :: CInt+ , xse_serial :: CUInt+ , xse_send_event :: Bool+ , xse_display :: Display+ , xse_window :: Window+ , xse_kind :: CInt+ , xse_x :: CInt+ , xse_y :: CInt+ , xse_width :: CUInt+ , xse_height :: CUInt+ , xse_time :: Time+ , xse_shaped :: Bool + }+shapeQueryVersion :: CInt+shapeQueryVersion = 0+shapeRectangles :: CInt +shapeRectangles = 1+shapeMask :: CInt +shapeMask = 2+shapeCombine :: CInt +shapeCombine = 3+shapeOffset :: CInt +shapeOffset = 4+shapeQueryExtents :: CInt+shapeQueryExtents = 5+shapeSelectInput :: CInt+shapeSelectInput = 6+shapeInputSelected :: CInt+shapeInputSelected = 7+shapeGetRectangles :: CInt+shapeGetRectangles = 8++shapeSet :: CInt+shapeSet = 0+shapeUnion :: CInt+shapeUnion = 1+shapeIntersect :: CInt+shapeIntersect = 2+shapeSubtract :: CInt+shapeSubtract = 3+shapeInvert :: CInt+shapeInvert = 4++shapeBounding :: CInt+shapeBounding = 0+shapeClip :: CInt+shapeClip = 1+shapeInput :: CInt+shapeInput = 2++shapeNotifyMask :: Int+shapeNotifyMask = 1 `shiftL` 0+shapeNotify :: Int+shapeNotify = 0++shapeNumberEvents :: Int+shapeNumberEvents = shapeNotify + 1+++#ifdef HAVE_X11_EXTENSIONS_XSHAPE_H++-- We have Xinerama, so the library will actually work+compiledWithXshape :: Bool+compiledWithXshape = True++-- for XFree() (already included from Xdamage.h, but I don't know if I can count on that.)+#include <X11/Xlib.h>++#include <X11/extensions/shape.h>++xshapeQueryExtension :: Display -> IO (Maybe (CInt, CInt))+xshapeQueryExtension dpy = wrapPtr2 (cXshapeQueryExtension dpy) go+ where go False _ _ = Nothing+ go True eventbase errorbase = Just (fromIntegral eventbase, fromIntegral errorbase)++xshapeQueryVersion :: Display -> IO (Maybe (CInt, CInt))+xshapeQueryVersion dpy = wrapPtr2 (cXshapeQueryVersion dpy) go+ where go False _ _ = Nothing+ go True major minor = Just (fromIntegral major, fromIntegral minor)++foreign import ccall "XShapeQueryExtension"+ cXshapeQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO Bool++foreign import ccall "XShapeQueryVersion"+ cXshapeQueryVersion :: Display -> Ptr CInt -> Ptr CInt -> IO Bool++foreign import ccall "XShapeCombineRegion"+ xshapeCombineRegion :: Display -> Window -> CInt -> CInt -> CInt -> Ptr Region -> CInt -> IO()++foreign import ccall "XShapeCombineRectangles"+ xshapeCombineRectangles :: Display -> Window -> CInt -> CInt -> CInt -> Ptr Rectangle -> CInt -> CInt -> CInt -> IO()++foreign import ccall "XShapeCombineMask"+ xshapeCombineMask :: Display -> Window -> CInt -> CInt -> CInt -> Pixmap -> CInt -> IO ()++foreign import ccall "XShapeCombineShape"+ xshapeCombineShape :: Display -> Window -> CInt -> CInt -> CInt -> Window -> CInt -> CInt -> IO ()+++foreign import ccall "XShapeOffsetShape"+ xshapeOffsetShape :: Display -> Window -> CInt -> CInt -> CInt -> IO ()++foreign import ccall "XShapeQueryExtents"+ xshapeQueryExtents :: Display -> Window -> CInt -> CInt -> CUInt -> CUInt -> Bool -> CInt -> CInt -> CUInt -> CUInt -> IO ()++foreign import ccall "XShapeSelectInput"+ xshapeSelectInput :: Display -> Window -> CUInt -> IO()++foreign import ccall "XShapeInputSelected"+ xshapeInputSelected :: Display -> Window -> IO(CUInt)++ -- May leak the returned Rectangle; ask for help here+foreign import ccall "XShapeGetRectangles"+ xshapeGetRectangles :: Display -> Window -> CInt -> Ptr CInt -> Ptr CInt -> IO(Ptr Rectangle)++foreign import ccall "XFree"+ cXFree :: Ptr a -> IO CInt+++wrapPtr2 :: (Storable a, Storable b) => (Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d+wrapPtr2 cfun f =+ withPool $ \pool -> do aptr <- pooledMalloc pool+ bptr <- pooledMalloc pool+ ret <- cfun aptr bptr+ a <- peek aptr+ b <- peek bptr+ return (f ret a b)++#else++-- No Xshape, but if we fake a non-active Xdamage interface, we can still have+-- an active interface+compiledWithXshape :: Bool+compiledWithXshape = False++xshapeQueryExtension :: Display -> IO (Maybe (CInt, CInt))+xshapeQueryExtension _ = return Nothing++xshapeQueryVersion :: Display -> IO (Maybe (CInt, CInt))+xshapeQueryVersion _ = return Nothing++xshapeCombineRegion :: Display -> Window -> CInt -> CInt -> CInt -> Region -> CInt -> IO()+xshapeCombineRegion _ _ _ _ _ _ _ = return ()++xshapeCombineRectangles :: Display -> Window -> CInt -> CInt -> CInt -> Rectangle -> CInt -> CInt -> CInt -> IO()+xshapeCombineRectangles _ _ _ _ _ _ _ _ _ = return ()++xshapeCombineMask :: Display -> Window -> CInt -> CInt -> CInt -> Pixmap -> CInt -> IO ()+xshapeCombineMask _ _ _ _ _ _ _ = return ()++xshapeCombineShape :: Display -> Window -> CInt -> CInt -> CInt -> Window -> CInt -> CInt -> IO ()+xshapeCombineShape _ _ _ _ _ _ _ _ = return ()++xshapeOffsetShape :: Display -> Window -> CInt -> CInt -> CInt -> IO ()+xshapeOffsetShape _ _ _ _ _ = return ()++xshapeQueryExtents :: Display -> Window -> CInt -> CInt -> CUInt -> CUInt -> Bool -> CInt -> CInt -> CUInt -> CUInt -> IO ()+xshapeQueryExtents _ _ _ _ _ _ _ _ _ _ _ = return ()++xshapeSelectInput :: Display -> Window -> CUInt -> IO()+xshapeSelectInput _ _ _ = return ()++xshapeInputSelected :: Display -> Window -> IO(CUInt)+xshapeInputSelected _ _ = return 0++-- xshapeGetRectangles :: Display -> Window -> CInt -> Ptr CInt -> Ptr CInt -> IO(Ptr Rectangle)+-- xshapeGetRectangles _ _ _ _ _ = return $ Ptr (Rectangle 0 0 0 0)++#endif
+ LICENSE view
@@ -0,0 +1,26 @@+The HSX11xdamage Library is Copyright (c) Ewan Higgs,+2008, All rights reserved, and is distributed as free software+under the following license.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++- Redistributions of source code must retain the above copyright notice,+this list of conditions and the following disclaimer.++- Neither name of the copyright holders nor the names of its+contributors may be used to endorse or promote products derived from+this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,6 @@+module Main (main) where++import Distribution.Simple++main :: IO ()+main = defaultMainWithHooks simpleUserHooks
+ X11-xshape.cabal view
@@ -0,0 +1,21 @@+name: X11-xshape+version: 0.1.0+license: BSD3+license-file: LICENSE+copyright: Ewan Higgs, 2008, libraries@haskell.org 2008+maintainer: Ewan Higgs <ewan_higgs@yahoo.co.uk>+homepage: http://darcs.haskell.org/X11-xshape+category: Graphics+synopsis: A binding to the Xshape X11 extension library+description: A Haskell binding to the Xshape X11 extention graphics library.+ .+ The binding is a direct translation of the C binding; for+ documentation of these calls, refer to "The Xlib Programming+ Manual", available online at <http://tronche.com/gui/x/xlib/>.+exposed-modules:+ Graphics.X11.Xshape+extensions: ForeignFunctionInterface, CPP+build-depends: base >= 3 && < 10, X11+build-type: Simple+ghc-options: -funbox-strict-fields -Wall -fno-warn-unused-binds+ghc-prof-options: -prof -auto-all