module Graphics.X11.XTest
(fakeMotion,
fakeButtonPress,
movePointer)
where
import Graphics.X11.Xlib
import Foreign.C.Types
foreign import ccall unsafe "X11/extensions/XTest.h XTestFakeButtonEvent"
xFakeButtonEvent :: Display -> Button -> Bool -> Time -> IO Status
foreign import ccall unsafe "X11/extensions/XTest.h XTestFakeMotionEvent"
xFakeMotionEvent :: Display -> CInt -> CInt -> CInt -> Time -> IO Status
fakeMotion :: Display
-> ScreenNumber
-> Int
-> Int
-> IO ()
fakeMotion dpy sid x y = do
xFakeMotionEvent dpy (fromIntegral sid) (fromIntegral x) (fromIntegral y) 0
return ()
fakeButtonPress :: Display
-> Button
-> IO ()
fakeButtonPress dpy button = do
xFakeButtonEvent dpy button True 0
xFakeButtonEvent dpy button False 0
return ()
movePointer :: Display
-> ScreenNumber
-> XID
-> Int
-> Int
-> IO ()
movePointer dpy sid root dx dy = do
(_,_,_,x,y,_,_,_) <- queryPointer dpy root
fakeMotion dpy sid (fromIntegral x + dx) (fromIntegral y + dy)