{-# 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
(Int -> XScreenSaverState -> ShowS)
-> (XScreenSaverState -> String)
-> ([XScreenSaverState] -> ShowS)
-> Show XScreenSaverState
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
(Int -> XScreenSaverKind -> ShowS)
-> (XScreenSaverKind -> String)
-> ([XScreenSaverKind] -> ShowS)
-> Show XScreenSaverKind
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
(Int -> XScreenSaverInfo -> ShowS)
-> (XScreenSaverInfo -> String)
-> ([XScreenSaverInfo] -> ShowS)
-> Show XScreenSaverInfo
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 =
Int -> (XScreenSaverInfo -> Int) -> Maybe XScreenSaverInfo -> Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 (CULong -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CULong -> Int)
-> (XScreenSaverInfo -> CULong) -> XScreenSaverInfo -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XScreenSaverInfo -> CULong
xssi_idle) (Maybe XScreenSaverInfo -> Int)
-> IO (Maybe XScreenSaverInfo) -> IO Int
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
_ = Status -> Int
forall a. Storable a => a -> Int
sizeOf (Status
forall a. HasCallStack => a
undefined :: CInt)
alignment :: XScreenSaverState -> Int
alignment XScreenSaverState
_ = Status -> Int
forall a. Storable a => a -> Int
alignment (Status
forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverState -> XScreenSaverState -> IO ()
poke Ptr XScreenSaverState
p XScreenSaverState
xsss = Ptr Status -> Status -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr XScreenSaverState -> Ptr Status
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 (Status -> XScreenSaverState) -> IO Status -> IO XScreenSaverState
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Ptr Status -> IO Status
forall a. Storable a => Ptr a -> IO a
peek (Ptr XScreenSaverState -> Ptr Status
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
_ = Status -> Int
forall a. Storable a => a -> Int
sizeOf (Status
forall a. HasCallStack => a
undefined :: CInt)
alignment :: XScreenSaverKind -> Int
alignment XScreenSaverKind
_ = Status -> Int
forall a. Storable a => a -> Int
alignment (Status
forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverKind -> XScreenSaverKind -> IO ()
poke Ptr XScreenSaverKind
p XScreenSaverKind
xsss = Ptr Status -> Status -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr XScreenSaverKind -> Ptr Status
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 (Status -> XScreenSaverKind) -> IO Status -> IO XScreenSaverKind
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Ptr Status -> IO Status
forall a. Storable a => Ptr a -> IO a
peek (Ptr XScreenSaverKind -> Ptr Status
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
_ = Status -> Int
forall a. Storable a => a -> Int
alignment (Status
forall a. HasCallStack => a
undefined :: CInt)
poke :: Ptr XScreenSaverInfo -> XScreenSaverInfo -> IO ()
poke Ptr XScreenSaverInfo
p XScreenSaverInfo
xssi = do
(\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> Window -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
0) Ptr XScreenSaverInfo
p (Window -> IO ()) -> Window -> IO ()
forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> Window
xssi_window XScreenSaverInfo
xssi
{-# LINE 163 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> XScreenSaverState -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
8) Ptr XScreenSaverInfo
p (XScreenSaverState -> IO ()) -> XScreenSaverState -> IO ()
forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> XScreenSaverState
xssi_state XScreenSaverInfo
xssi
{-# LINE 164 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> XScreenSaverKind -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
12) Ptr XScreenSaverInfo
p (XScreenSaverKind -> IO ()) -> XScreenSaverKind -> IO ()
forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> XScreenSaverKind
xssi_kind XScreenSaverInfo
xssi
{-# LINE 165 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> CULong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
16) Ptr XScreenSaverInfo
p (CULong -> IO ()) -> CULong -> IO ()
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 -> Ptr XScreenSaverInfo -> Int -> CULong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
24) Ptr XScreenSaverInfo
p (CULong -> IO ()) -> CULong -> IO ()
forall a b. (a -> b) -> a -> b
$ XScreenSaverInfo -> CULong
xssi_idle XScreenSaverInfo
xssi
{-# LINE 167 "Graphics/X11/XScreenSaver.hsc" #-}
(\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> CULong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XScreenSaverInfo
hsc_ptr Int
32) Ptr XScreenSaverInfo
p (CULong -> IO ()) -> CULong -> IO ()
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 = (Window
-> XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo)
-> IO
(Window
-> XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Window
-> XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo
XScreenSaverInfo
IO
(Window
-> XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo)
-> IO Window
-> IO
(XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo)
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO Window
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" #-}
IO
(XScreenSaverState
-> XScreenSaverKind
-> CULong
-> CULong
-> CULong
-> XScreenSaverInfo)
-> IO XScreenSaverState
-> IO
(XScreenSaverKind
-> CULong -> CULong -> CULong -> XScreenSaverInfo)
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO XScreenSaverState
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" #-}
IO
(XScreenSaverKind
-> CULong -> CULong -> CULong -> XScreenSaverInfo)
-> IO XScreenSaverKind
-> IO (CULong -> CULong -> CULong -> XScreenSaverInfo)
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO XScreenSaverKind
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" #-}
IO (CULong -> CULong -> CULong -> XScreenSaverInfo)
-> IO CULong -> IO (CULong -> CULong -> XScreenSaverInfo)
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO CULong
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" #-}
IO (CULong -> CULong -> XScreenSaverInfo)
-> IO CULong -> IO (CULong -> XScreenSaverInfo)
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO CULong
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" #-}
IO (CULong -> XScreenSaverInfo) -> IO CULong -> IO XScreenSaverInfo
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XScreenSaverInfo
hsc_ptr -> Ptr XScreenSaverInfo -> Int -> IO CULong
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Window -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Window -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Status -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Status -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Bool -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> Window -> IO ()
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Window
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Window
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Status
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Status
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Bool
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 -> Ptr XScreenSaverNotifyEvent -> Int -> IO Window
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" #-}
XScreenSaverNotifyEvent -> IO XScreenSaverNotifyEvent
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 (XEventPtr -> Ptr XScreenSaverNotifyEvent
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 = (Ptr Status -> Ptr Status -> IO Bool)
-> (Bool -> Status -> Status -> Maybe (Status, Status))
-> IO (Maybe (Status, Status))
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) Bool -> Status -> Status -> Maybe (Status, Status)
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
_ = Maybe (a, b)
forall a. Maybe a
Nothing
go Bool
True a
eventbase a
errorbase = (a, b) -> Maybe (a, b)
forall a. a -> Maybe a
Just ( a -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
eventbase
, a -> b
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 = (Ptr Status -> Ptr Status -> IO Bool)
-> (Bool -> Status -> Status -> Maybe (Status, Status))
-> IO (Maybe (Status, Status))
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) Bool -> Status -> Status -> Maybe (Status, Status)
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
_ = Maybe (a, b)
forall a. Maybe a
Nothing
go Bool
True a
major a
minor = (a, b) -> Maybe (a, b)
forall a. a -> Maybe a
Just (a -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
major, a -> b
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 = (Pool -> IO d) -> IO d
forall b. (Pool -> IO b) -> IO b
withPool ((Pool -> IO d) -> IO d) -> (Pool -> IO d) -> IO d
forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr a
aptr <- Pool -> IO (Ptr a)
forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
Ptr b
bptr <- Pool -> IO (Ptr b)
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 <- Ptr a -> IO a
forall a. Storable a => Ptr a -> IO a
peek Ptr a
aptr
b
b <- Ptr b -> IO b
forall a. Storable a => Ptr a -> IO a
peek Ptr b
bptr
d -> IO d
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 Ptr XScreenSaverInfo -> Ptr XScreenSaverInfo -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr XScreenSaverInfo
forall a. Ptr a
nullPtr then Maybe XScreenSaverInfo -> IO (Maybe XScreenSaverInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe XScreenSaverInfo
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 Status -> Status -> Bool
forall a. Eq a => a -> a -> Bool
== Status
0 then Maybe XScreenSaverInfo -> IO (Maybe XScreenSaverInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe XScreenSaverInfo
forall a. Maybe a
Nothing else do
XScreenSaverInfo
xssi <- Ptr XScreenSaverInfo -> IO XScreenSaverInfo
forall a. Storable a => Ptr a -> IO a
peek Ptr XScreenSaverInfo
p
Status
_ <- Ptr XScreenSaverInfo -> IO Status
forall a. Ptr a -> IO Status
xFree Ptr XScreenSaverInfo
p
Maybe XScreenSaverInfo -> IO (Maybe XScreenSaverInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (XScreenSaverInfo -> Maybe XScreenSaverInfo
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 Ptr XScreenSaverInfo -> Ptr XScreenSaverInfo -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr XScreenSaverInfo
forall a. Ptr a
nullPtr then () -> IO ()
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 ()