{-# LINE 1 "Graphics/X11/XScreenSaver.hsc" #-}
{-# LANGUAGE DeriveDataTypeable, ForeignFunctionInterface #-}
module Graphics.X11.XScreenSaver (
getXIdleTime,
XScreenSaverState(..),
XScreenSaverKind(..),
XScreenSaverInfo(..),
XScreenSaverNotifyEvent,
xScreenSaverQueryExtension,
xScreenSaverQueryVersion,
xScreenSaverQueryInfo,
xScreenSaverSelectInput,
xScreenSaverSetAttributes,
xScreenSaverUnsetAttributes,
xScreenSaverSaverRegister,
xScreenSaverUnregister,
xScreenSaverGetRegistered,
xScreenSaverSuspend,
get_XScreenSaverNotifyEvent,
compiledWithXScreenSaver
) where
import Graphics.X11.Types
import Graphics.X11.Xlib.Types
import Foreign
import Foreign.C.Types
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Internal
import Control.Monad
data XScreenSaverState
= ScreenSaverOff
| ScreenSaverOn
| ScreenSaverCycle
| ScreenSaverDisabled
deriving Int -> XScreenSaverState -> ShowS
[XScreenSaverState] -> ShowS
XScreenSaverState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XScreenSaverState] -> ShowS
$cshowList :: [XScreenSaverState] -> ShowS
show :: XScreenSaverState -> String
$cshow :: XScreenSaverState -> String
showsPrec :: Int -> XScreenSaverState -> ShowS
$cshowsPrec :: Int -> XScreenSaverState -> ShowS
Show
data XScreenSaverKind
= ScreenSaverBlanked
| ScreenSaverInternal
| ScreenSaverExternal
deriving Int -> XScreenSaverKind -> ShowS
[XScreenSaverKind] -> ShowS
XScreenSaverKind -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XScreenSaverKind] -> ShowS
$cshowList :: [XScreenSaverKind] -> ShowS
show :: XScreenSaverKind -> String
$cshow :: XScreenSaverKind -> String
showsPrec :: Int -> XScreenSaverKind -> ShowS
$cshowsPrec :: Int -> XScreenSaverKind -> ShowS
Show
data XScreenSaverInfo = XScreenSaverInfo
{ XScreenSaverInfo -> Window
xssi_window :: !Window
, XScreenSaverInfo -> XScreenSaverState
xssi_state :: !XScreenSaverState
, XScreenSaverInfo -> XScreenSaverKind
xssi_kind :: !XScreenSaverKind
, XScreenSaverInfo -> CULong
xssi_til_or_since :: !CULong
, XScreenSaverInfo -> CULong
xssi_idle :: !CULong
, XScreenSaverInfo -> CULong
xssi_event_mask :: !CULong
} deriving (Int -> XScreenSaverInfo -> ShowS
[XScreenSaverInfo] -> ShowS
XScreenSaverInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XScreenSaverInfo] -> ShowS
$cshowList :: [XScreenSaverInfo] -> ShowS
show :: XScreenSaverInfo -> String
$cshow :: XScreenSaverInfo -> String
showsPrec :: Int -> XScreenSaverInfo -> ShowS
$cshowsPrec :: Int -> XScreenSaverInfo -> ShowS
Show)
getXIdleTime :: Display -> IO Int
getXIdleTime :: Display -> IO Int
getXIdleTime Display
dpy =
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. XScreenSaverInfo -> CULong
xssi_idle) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Display -> IO (Maybe XScreenSaverInfo)
xScreenSaverQueryInfo Display
dpy
compiledWithXScreenSaver :: Bool
compiledWithXScreenSaver :: Bool
compiledWithXScreenSaver = Bool
True
{-# DEPRECATED compiledWithXScreenSaver "X11 now always compiles with XScreenSaver support" #-}
xScreenSaverState2CInt :: XScreenSaverState -> CInt
xScreenSaverState2CInt :: XScreenSaverState -> Status
xScreenSaverState2CInt XScreenSaverState
ScreenSaverOn = Status
1
{-# LINE 118 "Graphics/X11/XScreenSaver.hsc" #-}
xScreenSaverState2CInt ScreenSaverOff = 0
{-# LINE 119 "Graphics/X11/XScreenSaver.hsc" #-}
xScreenSaverState2CInt ScreenSaverCycle = 2
{-# LINE 120 "Graphics/X11/XScreenSaver.hsc" #-}
xScreenSaverState2CInt ScreenSaverDisabled = 3
{-# LINE 121 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverState :: CInt -> XScreenSaverState
cInt2XScreenSaverState :: Status -> XScreenSaverState
cInt2XScreenSaverState (Status
1) = XScreenSaverState
ScreenSaverOn
{-# LINE 124 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverState (0) = ScreenSaverOff
{-# LINE 125 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverState (2) = ScreenSaverCycle
{-# LINE 126 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverState (3) = ScreenSaverDisabled
{-# LINE 127 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverState s = error $
"Unknown state in xScreenSaverQueryInfo for XScreenSaverState: " ++ show s
instance Storable XScreenSaverState where
sizeOf :: XScreenSaverState -> Int
sizeOf XScreenSaverState
_ = forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: CInt)
alignment :: XScreenSaverState -> Int
alignment XScreenSaverState
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverState -> XScreenSaverState -> IO ()
poke Ptr XScreenSaverState
p XScreenSaverState
xsss = forall a. Storable a => Ptr a -> a -> IO ()
poke (forall a b. Ptr a -> Ptr b
castPtr Ptr XScreenSaverState
p) (XScreenSaverState -> Status
xScreenSaverState2CInt XScreenSaverState
xsss)
peek :: Ptr XScreenSaverState -> IO XScreenSaverState
peek Ptr XScreenSaverState
p = Status -> XScreenSaverState
cInt2XScreenSaverState forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Storable a => Ptr a -> IO a
peek (forall a b. Ptr a -> Ptr b
castPtr Ptr XScreenSaverState
p)
xScreenSaverKind2CInt :: XScreenSaverKind -> CInt
xScreenSaverKind2CInt :: XScreenSaverKind -> Status
xScreenSaverKind2CInt XScreenSaverKind
ScreenSaverBlanked = Status
0
{-# LINE 139 "Graphics/X11/XScreenSaver.hsc" #-}
xScreenSaverKind2CInt ScreenSaverInternal = 1
{-# LINE 140 "Graphics/X11/XScreenSaver.hsc" #-}
xScreenSaverKind2CInt ScreenSaverExternal = 2
{-# LINE 141 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverKind :: CInt -> XScreenSaverKind
cInt2XScreenSaverKind :: Status -> XScreenSaverKind
cInt2XScreenSaverKind (Status
0) = XScreenSaverKind
ScreenSaverBlanked
{-# LINE 144 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverKind (1) = ScreenSaverInternal
{-# LINE 145 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverKind (2) = ScreenSaverExternal
{-# LINE 146 "Graphics/X11/XScreenSaver.hsc" #-}
cInt2XScreenSaverKind s = error $
"Unknown kind in xScreenSaverQueryInfo for XScreenSaverKind: " ++ show s
instance Storable XScreenSaverKind where
sizeOf :: XScreenSaverKind -> Int
sizeOf XScreenSaverKind
_ = forall a. Storable a => a -> Int
sizeOf (forall a. HasCallStack => a
undefined :: CInt)
alignment :: XScreenSaverKind -> Int
alignment XScreenSaverKind
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverKind -> XScreenSaverKind -> IO ()
poke Ptr XScreenSaverKind
p XScreenSaverKind
xsss = forall a. Storable a => Ptr a -> a -> IO ()
poke (forall a b. Ptr a -> Ptr b
castPtr Ptr XScreenSaverKind
p) (XScreenSaverKind -> Status
xScreenSaverKind2CInt XScreenSaverKind
xsss)
peek :: Ptr XScreenSaverKind -> IO XScreenSaverKind
peek Ptr XScreenSaverKind
p = Status -> XScreenSaverKind
cInt2XScreenSaverKind forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Storable a => Ptr a -> IO a
peek (forall a b. Ptr a -> Ptr b
castPtr Ptr XScreenSaverKind
p)
instance Storable XScreenSaverInfo where
sizeOf :: XScreenSaverInfo -> Int
sizeOf XScreenSaverInfo
_ = (Int
40)
{-# LINE 158 "Graphics/X11/XScreenSaver.hsc" #-}
alignment :: XScreenSaverInfo -> Int
alignment XScreenSaverInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverInfo -> XScreenSaverInfo -> IO ()
poke Ptr XScreenSaverInfo
p XScreenSaverInfo
xssi = do
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
0) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> Window
xssi_window XScreenSaverInfo
xssi
{-# LINE 163 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
8) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> XScreenSaverState
xssi_state XScreenSaverInfo
xssi
{-# LINE 164 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
12) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> XScreenSaverKind
xssi_kind XScreenSaverInfo
xssi
{-# LINE 165 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
16) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> CULong
xssi_til_or_since XScreenSaverInfo
xssi
{-# LINE 166 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
24) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> CULong
xssi_idle XScreenSaverInfo
xssi
{-# LINE 167 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
32) Ptr XScreenSaverInfo
p forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> CULong
xssi_event_mask XScreenSaverInfo
xssi
{-# LINE 168 "Graphics/X11/XScreenSaver.hsc" #-}
peek :: Ptr XScreenSaverInfo -> IO XScreenSaverInfo
peek Ptr XScreenSaverInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Window
-> XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo
XScreenSaverInfo
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
0) Ptr XScreenSaverInfo
p)
{-# LINE 171 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
8) Ptr XScreenSaverInfo
p)
{-# LINE 172 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
12) Ptr XScreenSaverInfo
p)
{-# LINE 173 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
16) Ptr XScreenSaverInfo
p)
{-# LINE 174 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
24) Ptr XScreenSaverInfo
p)
{-# LINE 175 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverInfo
hsc_ptr Int
32) Ptr XScreenSaverInfo
p)
{-# LINE 176 "Graphics/X11/XScreenSaver.hsc" #-}
type XScreenSaverNotifyEvent =
( Window
, Window
, CInt
, CInt
, Bool
, Time
)
pokeXScreenSaverNotifyEvent :: Ptr XScreenSaverNotifyEvent
-> XScreenSaverNotifyEvent -> IO ()
pokeXScreenSaverNotifyEvent :: Ptr XScreenSaverNotifyEvent -> XScreenSaverNotifyEvent -> IO ()
pokeXScreenSaverNotifyEvent Ptr XScreenSaverNotifyEvent
p (Window
window, Window
root, Status
state, Status
kind, Bool
forced, Window
time) = do
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
32) Ptr XScreenSaverNotifyEvent
p Window
window
{-# LINE 190 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
40) Ptr XScreenSaverNotifyEvent
p Window
root
{-# LINE 191 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
48) Ptr XScreenSaverNotifyEvent
p Status
state
{-# LINE 192 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
52) Ptr XScreenSaverNotifyEvent
p Status
kind
{-# LINE 193 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
56) Ptr XScreenSaverNotifyEvent
p Bool
forced
{-# LINE 194 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
64) Ptr XScreenSaverNotifyEvent
p Window
time
{-# LINE 195 "Graphics/X11/XScreenSaver.hsc" #-}
peekXScreenSaverNotifyEvent :: Ptr XScreenSaverNotifyEvent
-> IO XScreenSaverNotifyEvent
peekXScreenSaverNotifyEvent :: Ptr XScreenSaverNotifyEvent -> IO XScreenSaverNotifyEvent
peekXScreenSaverNotifyEvent Ptr XScreenSaverNotifyEvent
p = do
Window
window <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
32) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 200 "Graphics/X11/XScreenSaver.hsc" #-}
Window
root <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
40) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 201 "Graphics/X11/XScreenSaver.hsc" #-}
Status
state <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
48) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 202 "Graphics/X11/XScreenSaver.hsc" #-}
Status
kind <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
52) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 203 "Graphics/X11/XScreenSaver.hsc" #-}
Bool
forced <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
56) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 204 "Graphics/X11/XScreenSaver.hsc" #-}
Window
time <- ((\Ptr XScreenSaverNotifyEvent
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XScreenSaverNotifyEvent
hsc_ptr Int
64) Ptr XScreenSaverNotifyEvent
p )
{-# LINE 205 "Graphics/X11/XScreenSaver.hsc" #-}
forall (m :: * -> *) a. Monad m => a -> m a
return (Window
window, Window
root, Status
state, Status
kind, Bool
forced, Window
time)
get_XScreenSaverNotifyEvent :: XEventPtr -> IO XScreenSaverNotifyEvent
get_XScreenSaverNotifyEvent :: XEventPtr -> IO XScreenSaverNotifyEvent
get_XScreenSaverNotifyEvent XEventPtr
p = Ptr XScreenSaverNotifyEvent -> IO XScreenSaverNotifyEvent
peekXScreenSaverNotifyEvent (forall a b. Ptr a -> Ptr b
castPtr XEventPtr
p)
xScreenSaverQueryExtension :: Display -> IO (Maybe (CInt, CInt))
xScreenSaverQueryExtension :: Display -> IO (Maybe (Status, Status))
xScreenSaverQueryExtension Display
dpy = forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 (Display -> Ptr Status -> Ptr Status -> IO Bool
cXScreenSaverQueryExtension Display
dpy) forall {a} {a} {a} {b}.
(Integral a, Integral a, Num a, Num b) =>
Bool -> a -> a -> Maybe (a, b)
go
where go :: Bool -> a -> a -> Maybe (a, b)
go Bool
False a
_ a
_ = forall a. Maybe a
Nothing
go Bool
True a
eventbase a
errorbase = forall a. a -> Maybe a
Just ( forall a b. (Integral a, Num b) => a -> b
fromIntegral a
eventbase
, forall a b. (Integral a, Num b) => a -> b
fromIntegral a
errorbase
)
xScreenSaverQueryVersion :: Display -> IO (Maybe (CInt, CInt))
xScreenSaverQueryVersion :: Display -> IO (Maybe (Status, Status))
xScreenSaverQueryVersion Display
dpy = forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 (Display -> Ptr Status -> Ptr Status -> IO Bool
cXScreenSaverQueryVersion Display
dpy) forall {a} {a} {a} {b}.
(Integral a, Integral a, Num a, Num b) =>
Bool -> a -> a -> Maybe (a, b)
go
where go :: Bool -> a -> a -> Maybe (a, b)
go Bool
False a
_ a
_ = forall a. Maybe a
Nothing
go Bool
True a
major a
minor = forall a. a -> Maybe a
Just (forall a b. (Integral a, Num b) => a -> b
fromIntegral a
major, forall a b. (Integral a, Num b) => a -> b
fromIntegral a
minor)
wrapPtr2 :: (Storable a, Storable b)
=> (Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 :: forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 Ptr a -> Ptr b -> IO c
cfun c -> a -> b -> d
f = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr a
aptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
Ptr b
bptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
c
ret <- Ptr a -> Ptr b -> IO c
cfun Ptr a
aptr Ptr b
bptr
a
a <- forall a. Storable a => Ptr a -> IO a
peek Ptr a
aptr
b
b <- forall a. Storable a => Ptr a -> IO a
peek Ptr b
bptr
forall (m :: * -> *) a. Monad m => a -> m a
return (c -> a -> b -> d
f c
ret a
a b
b)
xScreenSaverQueryInfo :: Display -> IO (Maybe XScreenSaverInfo)
xScreenSaverQueryInfo :: Display -> IO (Maybe XScreenSaverInfo)
xScreenSaverQueryInfo Display
dpy = do
Ptr XScreenSaverInfo
p <- IO (Ptr XScreenSaverInfo)
cXScreenSaverAllocInfo
if Ptr XScreenSaverInfo
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing else do
Status
s <- Display -> Window -> Ptr XScreenSaverInfo -> IO Status
cXScreenSaverQueryInfo Display
dpy (Display -> Window
defaultRootWindow Display
dpy) Ptr XScreenSaverInfo
p
if Status
s forall a. Eq a => a -> a -> Bool
== Status
0 then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing else do
XScreenSaverInfo
xssi <- forall a. Storable a => Ptr a -> IO a
peek Ptr XScreenSaverInfo
p
Status
_ <- forall a. Ptr a -> IO Status
xFree Ptr XScreenSaverInfo
p
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just XScreenSaverInfo
xssi)
xScreenSaverSelectInput :: Display -> EventMask -> IO ()
xScreenSaverSelectInput :: Display -> Window -> IO ()
xScreenSaverSelectInput Display
dpy Window
xssem = do
Ptr XScreenSaverInfo
p <- IO (Ptr XScreenSaverInfo)
cXScreenSaverAllocInfo
if Ptr XScreenSaverInfo
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then forall (m :: * -> *) a. Monad m => a -> m a
return () else do
Display -> Window -> Window -> IO ()
cXScreenSaverSelectInput Display
dpy (Display -> Window
defaultRootWindow Display
dpy) Window
xssem
xScreenSaverSetAttributes :: Display
-> Position
-> Position
-> Dimension
-> Dimension
-> Dimension
-> CInt
-> WindowClass
-> Visual
-> AttributeMask
-> Ptr SetWindowAttributes
-> IO ()
xScreenSaverSetAttributes :: Display
-> Position
-> Position
-> Dimension
-> Dimension
-> Dimension
-> Status
-> Status
-> Visual
-> Window
-> Ptr SetWindowAttributes
-> IO ()
xScreenSaverSetAttributes Display
dpy Position
x Position
y Dimension
w Dimension
h Dimension
bw Status
d Status
wc Visual
v Window
am Ptr SetWindowAttributes
pswa = do
Display
-> Window
-> Position
-> Position
-> Dimension
-> Dimension
-> Dimension
-> Status
-> Status
-> Visual
-> Window
-> Ptr SetWindowAttributes
-> IO ()
cXScreenSaverSetAttributes Display
dpy (Display -> Window
defaultRootWindow Display
dpy)
Position
x Position
y Dimension
w Dimension
h Dimension
bw Status
d Status
wc Visual
v Window
am Ptr SetWindowAttributes
pswa
xScreenSaverUnsetAttributes :: Display -> IO ()
xScreenSaverUnsetAttributes :: Display -> IO ()
xScreenSaverUnsetAttributes Display
dpy =
Display -> Window -> IO ()
cXScreenSaverUnsetAttributes Display
dpy (Display -> Window
defaultRootWindow Display
dpy)
xScreenSaverSaverRegister :: Display -> ScreenNumber -> XID -> Atom -> IO ()
xScreenSaverSaverRegister :: Display -> Dimension -> Window -> Window -> IO ()
xScreenSaverSaverRegister = Display -> Dimension -> Window -> Window -> IO ()
cXScreenSaverSaverRegister
xScreenSaverUnregister :: Display -> ScreenNumber -> IO Status
xScreenSaverUnregister :: Display -> Dimension -> IO Status
xScreenSaverUnregister = Display -> Dimension -> IO Status
cXScreenSaverUnregister
xScreenSaverGetRegistered :: Display -> ScreenNumber -> XID -> Atom -> IO Status
xScreenSaverGetRegistered :: Display -> Dimension -> Window -> Window -> IO Status
xScreenSaverGetRegistered = Display -> Dimension -> Window -> Window -> IO Status
cXScreenSaverGetRegistered
xScreenSaverSuspend :: Display -> Bool -> IO ()
xScreenSaverSuspend :: Display -> Bool -> IO ()
xScreenSaverSuspend = Display -> Bool -> IO ()
cXScreenSaverSuspend
foreign import ccall "XScreenSaverQueryExtension"
cXScreenSaverQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO Bool
foreign import ccall "XScreenSaverQueryVersion"
cXScreenSaverQueryVersion :: Display -> Ptr CInt -> Ptr CInt -> IO Bool
foreign import ccall "XScreenSaverAllocInfo"
cXScreenSaverAllocInfo :: IO (Ptr XScreenSaverInfo)
foreign import ccall "XScreenSaverQueryInfo"
cXScreenSaverQueryInfo :: Display -> Drawable -> Ptr XScreenSaverInfo
-> IO Status
foreign import ccall "XScreenSaverSelectInput"
cXScreenSaverSelectInput :: Display -> Drawable -> EventMask -> IO ()
foreign import ccall "XScreenSaverSetAttributes"
cXScreenSaverSetAttributes :: Display -> Drawable -> Position -> Position
-> Dimension -> Dimension -> Dimension
-> CInt
-> WindowClass
-> Visual
-> AttributeMask
-> Ptr SetWindowAttributes
-> IO ()
foreign import ccall "XScreenSaverUnsetAttributes"
cXScreenSaverUnsetAttributes :: Display -> Drawable -> IO ()
foreign import ccall "XScreenSaverRegister"
cXScreenSaverSaverRegister :: Display -> ScreenNumber -> XID -> Atom
-> IO ()
foreign import ccall "XScreenSaverUnregister"
cXScreenSaverUnregister :: Display -> ScreenNumber -> IO Status
foreign import ccall "XScreenSaverGetRegistered"
cXScreenSaverGetRegistered :: Display -> ScreenNumber -> XID -> Atom
-> IO Status
foreign import ccall "XScreenSaverSuspend"
cXScreenSaverSuspend :: Display -> Bool -> IO ()