packages feed

X11-xfixes (empty) → 0.1.1

raw patch · 4 files changed

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

Dependencies added: X11, base

Files

+ Graphics/X11/Xfixes.hsc view
@@ -0,0 +1,140 @@++++-- This is an incomplete binding, patches welcome for binding the rest+-- of the specification, which is available at+-- http://cgit.freedesktop.org/xorg/proto/fixesproto/plain/fixesproto.txt++module Graphics.X11.Xfixes (+    xfixesQueryExtension,+    xfixesQueryVersion,+    Region,+    WindowRegion,+    windowRegionBounding,+    windowRegionClip,+    xfixesCreateRegion,+    xfixesCreateRegionFromBitmap,+    xfixesCreateRegionFromWindow,+    xfixesCreateRegionFromGC,+    xfixesDestroyRegion,+    xfixesSetRegion,+    xfixesCopyRegion,+    xfixesUnionRegion,+    xfixesIntersectRegion,+    xfixesSubtractRegion,+    xfixesInvertRegion,+    xfixesTranslateRegion,+    xfixesRegionExtents,+    xfixesFetchRegion,+    xfixesSetGCClipRegion,+    xfixesExpandRegion+    ) where++import Foreign+import Foreign.C.Types+import Graphics.X11.Xlib hiding (Region) -- xfixes has its own Region based on XID++#include <X11/Xlib.h>++#include <X11/extensions/Xfixes.h>+++xfixesQueryExtension :: Display -> IO (Maybe (CInt, CInt))+xfixesQueryExtension dpy = wrapPtr2 (cXfixesQueryExtension dpy) go+    where go False _ _                = Nothing+          go True eventbase errorbase = Just (fromIntegral eventbase, fromIntegral errorbase)++xfixesQueryVersion :: Display -> IO (Maybe (CInt, CInt))+xfixesQueryVersion dpy = wrapPtr2 (cXfixesQueryVersion dpy) go+    where go False _ _        = Nothing+          go True major minor = Just (fromIntegral major, fromIntegral minor)++foreign import ccall "XFixesQueryExtension"+    cXfixesQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO Bool++foreign import ccall "XFixesQueryVersion"+    cXfixesQueryVersion :: Display -> Ptr CInt -> Ptr CInt -> IO Bool+++-- Borrowed from the Xdamage bindings+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)+++type WindowRegion = CInt++type Region = XID++windowRegionBounding :: WindowRegion+windowRegionBounding = 0+windowRegionClip :: WindowRegion+windowRegionClip = 1+++foreign import ccall "XFixesCreateRegion"+    xfixesCreateRegion :: Display -> Ptr Rectangle -> CInt -> IO Region++foreign import ccall "XFixesCreateRegionFromBitmap"+    xfixesCreateRegionFromBitmap :: Display -> Pixmap -> IO Region++foreign import ccall "XFixesCreateRegionFromWindow"+    xfixesCreateRegionFromWindow :: Display -> Window -> WindowRegion -> IO Region++foreign import ccall "XFixesCreateRegionFromGC"+    xfixesCreateRegionFromGC :: Display -> GC -> IO Region++-- Disabled due to lack of binding for Picture+--foreign import ccall "XFixesCreateRegionFromPicture"+--    xfixesCreateRegionFromPicture :: Display -> Picture -> IO Region++foreign import ccall "XFixesDestroyRegion"+    xfixesDestroyRegion :: Display -> Region -> IO ()++foreign import ccall "XFixesSetRegion"+    xfixesSetRegion :: Display -> Region -> Ptr Rectangle -> CInt -> IO ()++foreign import ccall "XFixesCopyRegion"+    xfixesCopyRegion :: Display -> Region -> Region -> IO ()++foreign import ccall "XFixesUnionRegion"+    xfixesUnionRegion :: Display -> Region -> Region -> Region -> IO ()++foreign import ccall "XFixesIntersectRegion"+    xfixesIntersectRegion :: Display -> Region -> Region -> Region -> IO ()++foreign import ccall "XFixesSubtractRegion"+    xfixesSubtractRegion :: Display -> Region -> Region -> Region -> IO ()++foreign import ccall "XFixesInvertRegion"+    xfixesInvertRegion :: Display -> Region -> Ptr Rectangle -> Region -> IO ()++foreign import ccall "XFixesTranslateRegion"+    xfixesTranslateRegion :: Display -> Region -> CInt -> CInt -> IO ()++foreign import ccall "XFixesRegionExtents"+    xfixesRegionExtents :: Display -> Region -> Region -> IO ()++foreign import ccall "XFixesFetchRegion"+    xfixesFetchRegion :: Display -> Region -> CInt -> IO ()++foreign import ccall "XFixesSetGCClipRegion"+    xfixesSetGCClipRegion :: Display -> GC -> CInt -> CInt -> Region -> IO ()++-- Disabled as we don't have a binding for the Shape type from the shape extension+--foreign import ccall "XFixesSetWindowShapeRegion"+--    xfixesSetWindowShapeRegion :: Display -> Window -> Shape -> CInt -> CInt -> Region -> IO ()++-- Disabled due to lack of binding for Picture+--foreign import ccall "XFixesSetPictureClipRegion"+--    xfixesSetPictureClipRegion :: Display -> Picture -> CInt -> CInt -> Region -> IO ()++-- Only available in XFixes version 3 or higher+foreign import ccall "XFixesExpandRegion"+    xfixesExpandRegion :: Display -> Region -> Region -> CInt -> CInt -> CInt -> CInt -> IO ()+
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (C) 2011 by Aren Olson <reacocard@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++import Distribution.Simple+main = defaultMain
+ X11-xfixes.cabal view
@@ -0,0 +1,23 @@+name:		        X11-xfixes+version:	        0.1.1+license:	        MIT+license-file:	        LICENSE+copyright:	        Aren Olson, 2011+maintainer:	        Aren Olson <reacocard@gmail.com>+homepage:               https://github.com/reacocard/x11-xfixes+category:	        Graphics+synopsis:	        A binding to the Xfixes X11 extension library+description:	        A Haskell binding to the Xfixes X11 extention graphics library.+	.+	The binding is a direct translation of the C binding; for+	documentation of these calls, refer to man xfixes(3)+cabal-version:          >= 1.4+build-type:         Simple++Library+    exposed-modules:    Graphics.X11.Xfixes+    extensions:	        ForeignFunctionInterface, CPP+    extra-libraries:    "Xfixes"+    build-depends:	base >= 3 && < 5, X11+    ghc-options:        -funbox-strict-fields -Wall -fno-warn-unused-binds+    ghc-prof-options:   -prof -auto-all