module Cursor where
import Command
import Event
import Fudget
import Xrequest
import Xcommand
import Xtypes

createFontCursor :: Int -> Cont (K b c) CursorId
createFontCursor Int
shape =
    let cmd :: XRequest
cmd = Int -> XRequest
CreateFontCursor Int
shape
        expected :: XResponse -> Maybe CursorId
expected (CursorCreated CursorId
cursor) = CursorId -> Maybe CursorId
forall a. a -> Maybe a
Just CursorId
cursor
        expected XResponse
_ = Maybe CursorId
forall a. Maybe a
Nothing
    in  XRequest -> (XResponse -> Maybe CursorId) -> Cont (K b c) CursorId
forall a b c. XRequest -> (XResponse -> Maybe a) -> Cont (K b c) a
xrequestK XRequest
cmd XResponse -> Maybe CursorId
expected

setFontCursor :: Int -> K a b -> K a b
setFontCursor :: Int -> K a b -> K a b
setFontCursor Int
shape K a b
process =
    Int -> Cont (K a b) CursorId
forall b c. Int -> Cont (K b c) CursorId
createFontCursor Int
shape Cont (K a b) CursorId -> Cont (K a b) CursorId
forall a b. (a -> b) -> a -> b
$ \ CursorId
cursor ->
    XCommand -> K a b -> K a b
forall i o. XCommand -> K i o -> K i o
xcommandK ([WindowAttributes] -> XCommand
ChangeWindowAttributes [CursorId -> WindowAttributes
CWCursor CursorId
cursor]) (K a b -> K a b) -> K a b -> K a b
forall a b. (a -> b) -> a -> b
$
    K a b
process

defineCursor :: CursorId -> K i o -> K i o
defineCursor CursorId
cursor = XCommand -> K i o -> K i o
forall i o. XCommand -> K i o -> K i o
xcommandK ([WindowAttributes] -> XCommand
ChangeWindowAttributes [CursorId -> WindowAttributes
CWCursor CursorId
cursor])
undefineCusror :: K i o -> K i o
undefineCusror = XCommand -> K i o -> K i o
forall i o. XCommand -> K i o -> K i o
xcommandK ([WindowAttributes] -> XCommand
ChangeWindowAttributes [CursorId -> WindowAttributes
CWCursor CursorId
cursorNone])