packages feed

X11-xdamage (empty) → 0.1.0

raw patch · 4 files changed

+188/−0 lines, 4 filesdep +X11dep +basesetup-changed

Dependencies added: X11, base

Files

+ Graphics/X11/Xdamage.hsc view
@@ -0,0 +1,134 @@+--------------------------------------------------------------------+-- |+-- Module    : Graphics.X11.Xdamage+-- Copyright : (c) Haskell.org, 2008+-- License   : BSD3+--+-- Maintainer: Ewan Higgs <ewan_higgs@yahoo.co.uk>+-- Stability : unstable +-- Portability: unportable +--+--------------------------------------------------------------------+--+-- Interface to Xdamage API+--++module Graphics.X11.Xdamage(+    DamageReportLevel,+    DamageNotify(..), +    xdamageCreate,+    xdamageDestroy,+    xdamageSubtract,+    xdamageQueryExtension,+    xdamageQueryVersion+ ) where++import Foreign+import Foreign.C.Types+import Graphics.X11.Xlib+import Graphics.X11.Xlib.Region+import Control.Monad++-- | DAMAGE is a 32 bit value where the top three bits are guaranteed to be 0+type Damage = CInt++-- | +type DamageReportLevel = CInt++{--+                         DamageReportRawRectangles+                       | DamageReportDeltaRectangles+                       | DamageReportBoundingBox+                       | DamageReportNonEmpty+--}+data DamageNotify  = DamageNotify+                   { xdn_type       :: CInt,+                     xdn_serial     :: CUInt,+                     xdn_send_event :: Bool,+                     xdn_display    :: Display,+                     xdn_drawable   :: Drawable,+                     xdn_damage     :: Damage,+                     xdn_level      :: CInt,+                     xdn_more       :: Bool,+                     xdn_timestamp  :: Time,+                     xdn_area       :: Rectangle,+                     xdn_geometry   :: Rectangle }++#ifdef HAVE_X11_EXTENSIONS_XDAMAGE_H++-- We have Xinerama, so the library will actually work+compiledWithXdamage :: Bool+compiledWithXdamage = 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/Xdamage.h>++-- | Creates a damage object to monitor changes to Drawable+foreign import ccall "XDamageCreate"+    xdamageCreate :: Display-> Drawable -> DamageReportLevel -> IO(Damage)+        +-- | Destroys damage.+foreign import ccall "XDamageDestroy"+    xdamageDestroy :: Display -> Damage -> IO ()++foreign import ccall "XDamageSubtract"+    xdamageSubtract :: Display -> Damage -> Ptr Region -> Ptr Region -> IO ()++foreign import ccall "XDamageAdd"+    xdamageAdd :: Display -> Drawable -> Ptr Region -> IO ()++xdamageQueryExtension :: Display -> IO (Maybe (CInt, CInt))+xdamageQueryExtension dpy = wrapPtr2 (cXdamageQueryExtension dpy) go+  where go False _ _                = Nothing+        go True eventbase errorbase = Just (fromIntegral eventbase, fromIntegral errorbase)++xdamageQueryVersion :: Display -> IO (Maybe (CInt, CInt))+xdamageQueryVersion dpy = wrapPtr2 (cXdamageQueryVersion dpy) go+  where go False _ _        = Nothing+        go True major minor = Just (fromIntegral major, fromIntegral minor)++foreign import ccall "XDamageQueryExtension"+  cXdamageQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO Bool++foreign import ccall "XDamageQueryVersion"+  cXdamageQueryVersion :: Display -> Ptr CInt -> Ptr CInt -> IO Bool++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 Xdamage, but if we fake a non-active Xdamage interface, we can still have+-- an active interface+compiledWithXdamage :: Bool+compiledWithXdamage = False++xdamageIsActive :: Display -> IO Bool+xdamageIsActive _ = return False++xdamageQueryExtension :: Display -> IO (Maybe (CInt, CInt))+xdamageQueryExtension _  = return Nothing++xdamageQueryVersion :: Display -> IO (Maybe (CInt, CInt))+xdamageQueryVersion _ = return Nothing++xdamageCreate :: Display -> Drawable -> DamageReportLevel -> IO(Damage)+xdamageCreate _ _ _ = return 0++xdamageDestroy :: Display -> Damage -> IO()+xdamageDestroy _ _ = return ()++xdamageSubtract :: Display -> Damage -> Region -> Region -> IO()+xdamageSubtract _ _ _ _ = return ()+#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-xdamage.cabal view
@@ -0,0 +1,22 @@+name:		        X11-xdamage+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-xdamage+category:	        Graphics+synopsis:	        A binding to the Xdamage X11 extension library+description:	    A Haskell binding to the Xdamage 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.Xdamage+extensions:	        ForeignFunctionInterface, CPP+extra-libraries:    "Xdamage"+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