{-# INCLUDE <X11_extras_config.h> #-}{-# INCLUDE <X11/Xlib.h> #-}{-# INCLUDE <X11/extensions/Xinerama.h> #-}{-# LINE 1 "Graphics/X11/Xinerama.hsc" #-}-- | Interface to Xinerama API{-# LINE 2 "Graphics/X11/Xinerama.hsc" #-}moduleGraphics.X11.Xinerama(XineramaScreenInfo(..),xineramaIsActive,xineramaQueryExtension,xineramaQueryVersion,xineramaQueryScreens,compiledWithXinerama,getScreenInfo)where{-# LINE 12 "Graphics/X11/Xinerama.hsc" #-}importForeignimportForeign.C.TypesimportGraphics.X11.XlibimportGraphics.X11.Xlib.Extras(WindowAttributes(..),getWindowAttributes)importControl.Monad-- | Representation of the XineramaScreenInfo structdataXineramaScreenInfo=XineramaScreenInfo{xsi_screen_number::CInt,xsi_x_org::CShort,xsi_y_org::CShort,xsi_width::CShort,xsi_height::CShort}deriving(Show)-- | Wrapper around xineramaQueryScreens that fakes a single screen when-- Xinerama is not active. This is the preferred interface to-- Graphics.X11.Xinerama.getScreenInfo::Display->IO[Rectangle]getScreenInfodpy=domxs<-xineramaQueryScreensdpycasemxsofJustxs->return.mapxsiToRect$xsNothing->dowa<-getWindowAttributesdpy(defaultRootWindowdpy)return$[Rectangle{rect_x=fromIntegral$wa_xwa,rect_y=fromIntegral$wa_ywa,rect_width=fromIntegral$wa_widthwa,rect_height=fromIntegral$wa_heightwa}]wherexsiToRectxsi=Rectangle{rect_x=fromIntegral$xsi_x_orgxsi,rect_y=fromIntegral$xsi_y_orgxsi,rect_width=fromIntegral$xsi_widthxsi,rect_height=fromIntegral$xsi_heightxsi}{-# LINE 52 "Graphics/X11/Xinerama.hsc" #-}-- We have Xinerama, so the library will actually workcompiledWithXinerama::BoolcompiledWithXinerama=True-- for XFree() (already included from Xinerama.h, but I don't know if I can count on that.){-# LINE 58 "Graphics/X11/Xinerama.hsc" #-}{-# LINE 60 "Graphics/X11/Xinerama.hsc" #-}instanceStorableXineramaScreenInfowheresizeOf_=(12){-# LINE 63 "Graphics/X11/Xinerama.hsc" #-}-- FIXME: Is this right?alignment_=alignment(undefined::CInt)pokepxsi=do(\hsc_ptr->pokeByteOffhsc_ptr0)p$xsi_screen_numberxsi{-# LINE 68 "Graphics/X11/Xinerama.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr4)p$xsi_x_orgxsi{-# LINE 69 "Graphics/X11/Xinerama.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr6)p$xsi_y_orgxsi{-# LINE 70 "Graphics/X11/Xinerama.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr8)p$xsi_widthxsi{-# LINE 71 "Graphics/X11/Xinerama.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr10)p$xsi_heightxsi{-# LINE 72 "Graphics/X11/Xinerama.hsc" #-}peekp=returnXineramaScreenInfo`ap`((\hsc_ptr->peekByteOffhsc_ptr0)p){-# LINE 75 "Graphics/X11/Xinerama.hsc" #-}`ap`((\hsc_ptr->peekByteOffhsc_ptr4)p){-# LINE 76 "Graphics/X11/Xinerama.hsc" #-}`ap`((\hsc_ptr->peekByteOffhsc_ptr6)p){-# LINE 77 "Graphics/X11/Xinerama.hsc" #-}`ap`((\hsc_ptr->peekByteOffhsc_ptr8)p){-# LINE 78 "Graphics/X11/Xinerama.hsc" #-}`ap`((\hsc_ptr->peekByteOffhsc_ptr10)p){-# LINE 79 "Graphics/X11/Xinerama.hsc" #-}foreignimportccall"XineramaIsActive"xineramaIsActive::Display->IOBoolxineramaQueryExtension::Display->IO(Maybe(CInt,CInt))xineramaQueryExtensiondpy=wrapPtr2(cXineramaQueryExtensiondpy)gowheregoFalse__=NothinggoTrueeventbaseerrorbase=Just(fromIntegraleventbase,fromIntegralerrorbase)xineramaQueryVersion::Display->IO(Maybe(CInt,CInt))xineramaQueryVersiondpy=wrapPtr2(cXineramaQueryVersiondpy)gowheregoFalse__=NothinggoTruemajorminor=Just(fromIntegralmajor,fromIntegralminor)xineramaQueryScreens::Display->IO(Maybe[XineramaScreenInfo])xineramaQueryScreensdpy=withPool$\pool->dointp<-pooledMallocpoolp<-cXineramaQueryScreensdpyintpifp==nullPtrthenreturnNothingelsedonscreens<-peekintpscreens<-peekArray(fromIntegralnscreens)pcXFreepreturn(Justscreens)foreignimportccall"XineramaQueryExtension"cXineramaQueryExtension::Display->PtrCInt->PtrCInt->IOBoolforeignimportccall"XineramaQueryVersion"cXineramaQueryVersion::Display->PtrCInt->PtrCInt->IOBoolforeignimportccall"XineramaQueryScreens"cXineramaQueryScreens::Display->PtrCInt->IO(PtrXineramaScreenInfo)foreignimportccall"XFree"cXFree::Ptra->IOCIntwrapPtr2::(Storablea,Storableb)=>(Ptra->Ptrb->IOc)->(c->a->b->d)->IOdwrapPtr2cfunf=withPool$\pool->doaptr<-pooledMallocpoolbptr<-pooledMallocpoolret<-cfunaptrbptra<-peekaptrb<-peekbptrreturn(fretab){-# LINE 141 "Graphics/X11/Xinerama.hsc" #-}