From 85310f18ac936032ea8eb4e3e177684d2d738b7c Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 12 Apr 2022 19:10:27 -0600 Subject: Replace submap and friends with my own versions that do the timeout. --- src/Rahm/Desktop/Submap.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/Rahm/Desktop') diff --git a/src/Rahm/Desktop/Submap.hs b/src/Rahm/Desktop/Submap.hs index 5dc6fb0..2306ee6 100644 --- a/src/Rahm/Desktop/Submap.hs +++ b/src/Rahm/Desktop/Submap.hs @@ -5,7 +5,9 @@ module Rahm.Desktop.Submap ( nextButton, nextMotion, nextMotionOrButton, - module X) where + submap, + submapDefault, + submapDefaultWithKey) where import XMonad hiding (keys) import Control.Monad.Fix (fix) @@ -14,8 +16,6 @@ import Data.Map (Map) import Control.Concurrent (threadDelay) import Data.Word (Word64) -import XMonad.Actions.Submap as X - getMaskEventWithTimeout :: Int -> Display -> Word64 -> (XEventPtr -> IO a) -> IO (Maybe a) @@ -74,6 +74,16 @@ mapNextStringWithKeysym fn = do mapNextString :: (KeyMask -> String -> X ()) -> X () mapNextString fn = mapNextStringWithKeysym (\m _ s -> fn m s) +submapDefaultWithKey :: ((KeyMask, KeySym) -> X ()) -> Map (KeyMask, KeySym) (X ()) -> X () +submapDefaultWithKey def m = mapNextStringWithKeysym $ \mask sym _ -> do + Map.findWithDefault (def (mask, sym)) (mask, sym) m + +submapDefault :: X () -> Map (KeyMask, KeySym) (X ()) -> X () +submapDefault def = submapDefaultWithKey (const def) + +submap :: Map (KeyMask, KeySym) (X ()) -> X () +submap = submapDefault (return ()) + {- Grabs the mouse and returns the next button press. -} nextButton :: X (ButtonMask, Button) nextButton = do -- cgit