module XMonad.Actions.PerWindowKeys (
bindAll,
bindFirst
) where
import XMonad
bindAll :: [(Query Bool, X ())] -> X ()
bindAll :: [(Query Bool, X ())] -> X ()
bindAll = ((Query Bool, X ()) -> X ()) -> [(Query Bool, X ())] -> X ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Query Bool, X ()) -> X ()
choose where
choose :: (Query Bool, X ()) -> X ()
choose (Query Bool
mh,X ()
action) = (Window -> X ()) -> X ()
withFocused ((Window -> X ()) -> X ()) -> (Window -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Window
w -> X Bool -> X () -> X ()
whenX (Query Bool -> Window -> X Bool
forall a. Query a -> Window -> X a
runQuery Query Bool
mh Window
w) X ()
action
bindFirst :: [(Query Bool, X ())] -> X ()
bindFirst :: [(Query Bool, X ())] -> X ()
bindFirst = (Window -> X ()) -> X ()
withFocused ((Window -> X ()) -> X ())
-> ([(Query Bool, X ())] -> Window -> X ())
-> [(Query Bool, X ())]
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Query Bool, X ())] -> Window -> X ()
chooseOne
chooseOne :: [(Query Bool, X ())] -> Window -> X ()
chooseOne :: [(Query Bool, X ())] -> Window -> X ()
chooseOne [] Window
_ = () -> X ()
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
chooseOne ((Query Bool
mh,X ()
a):[(Query Bool, X ())]
bs) Window
w = do
Bool
c <- Query Bool -> Window -> X Bool
forall a. Query a -> Window -> X a
runQuery Query Bool
mh Window
w
if Bool
c then X ()
a
else [(Query Bool, X ())] -> Window -> X ()
chooseOne [(Query Bool, X ())]
bs Window
w