module DoubleClickF where
import Fudget
import FRequest
import Xtypes
import Event
--import Font(FontStruct)
import Spops
--import Geometry(Point,Rect,Size(..))
import CompOps((>=..<))

doubleClickF :: Time -> F a b -> F a b
doubleClickF :: forall a b. Time -> F a b -> F a b
doubleClickF Time
timeout F a b
fudget = F a b
fudget forall {hi} {ho}. F hi ho -> SP TEvent TEvent -> F hi ho
>=..< forall {a}.
Eq a =>
Time -> (a, FResponse) -> SP (a, FResponse) (a, FResponse)
doubleClickSP Time
0 forall {a}. a
dummy
  where
    dummy :: a
dummy = forall a. HasCallStack => [Char] -> a
error [Char]
"bug in DoubleClickF.hs"
    doubleClickSP :: Time -> (a, FResponse) -> SP (a, FResponse) (a, FResponse)
doubleClickSP Time
n (a, FResponse)
last =
      forall a b. Cont (SP a b) a
getSP forall a b. (a -> b) -> a -> b
$ \ tev :: (a, FResponse)
tev@(a
path,FResponse
ev) ->
      case FResponse
ev of
        XEvt (ButtonEvent Time
t Point
wp Point
rp ModState
mods Pressed
press Button
btn) ->
	    if Time
nforall a. Eq a => a -> a -> Bool
==Time
0 Bool -> Bool -> Bool
|| Pressed
pressforall a. Eq a => a -> a -> Bool
/=Pressed
Pressed Bool -> Bool -> Bool
|| Time
tforall a. Ord a => a -> a -> Bool
>Time
lasttimeforall a. Num a => a -> a -> a
+Time
timeout Bool -> Bool -> Bool
||
	       Button
btnforall a. Eq a => a -> a -> Bool
/=Button
lastbtn Bool -> Bool -> Bool
|| ModState
modsforall a. Eq a => a -> a -> Bool
/=ModState
lastmods Bool -> Bool -> Bool
|| a
pathforall a. Eq a => a -> a -> Bool
/=a
lastpath
	    then forall b a. b -> SP a b -> SP a b
putSP (a, FResponse)
tev forall a b. (a -> b) -> a -> b
$ Time -> (a, FResponse) -> SP (a, FResponse) (a, FResponse)
doubleClickSP Time
1 (a, FResponse)
tev
	    else let n' :: Time
n' = Time
nforall a. Num a => a -> a -> a
+Time
1
		     tev' :: (a, FResponse)
tev' = (a
path,XEvent -> FResponse
XEvt (Time -> Point -> Point -> ModState -> Pressed -> Button -> XEvent
ButtonEvent Time
t Point
wp Point
rp ModState
mods (Time -> Pressed
MultiClick Time
n') Button
btn))
	         in forall b a. b -> SP a b -> SP a b
putSP (a, FResponse)
tev' forall a b. (a -> b) -> a -> b
$ Time -> (a, FResponse) -> SP (a, FResponse) (a, FResponse)
doubleClickSP Time
n' (a, FResponse)
tev'
	  where
	    (a
lastpath,XEvt (ButtonEvent Time
lasttime Point
_ Point
_ ModState
lastmods Pressed
_ Button
lastbtn)) = (a, FResponse)
last
	FResponse
_ -> forall b a. b -> SP a b -> SP a b
putSP (a, FResponse)
tev forall a b. (a -> b) -> a -> b
$ Time -> (a, FResponse) -> SP (a, FResponse) (a, FResponse)
doubleClickSP Time
n (a, FResponse)
last