diff --git a/XMonad/Util/Grab.hs b/XMonad/Util/Grab.hs index b1ec2074c..17073a0d0 100644 --- a/XMonad/Util/Grab.hs +++ b/XMonad/Util/Grab.hs @@ -29,15 +29,12 @@ module XMonad.Util.Grab ) where -- core -import XMonad hiding (mkGrabs) +import XMonad import Control.Monad ( when ) -import Data.Bits ( setBit ) import Data.Foldable ( traverse_ ) -- base -import qualified Data.Map.Strict as M import Data.Semigroup ( All(..) ) -import Data.Traversable ( for ) -- }}} @@ -70,9 +67,8 @@ grabUngrab -> [(KeyMask, KeySym)] -- ^ Keys to ungrab -> X () grabUngrab gr ugr = do - f <- mkGrabs - traverse_ (uncurry ungrabKP) (f ugr) - traverse_ (uncurry grabKP) (f gr) + traverse_ (uncurry ungrabKP) =<< mkGrabs ugr + traverse_ (uncurry grabKP) =<< mkGrabs gr -- | A convenience function to grab keys. This also ungrabs all -- previously grabbed keys. @@ -88,49 +84,9 @@ customRegrabEvHook regr = \case e@MappingNotifyEvent{} -> do io (refreshKeyboardMapping e) when (ev_request e `elem` [mappingKeyboard, mappingModifier]) - $ setNumlockMask + $ cacheNumlockMask >> regr pure (All False) _ -> pure (All True) -- }}} - --- --< Private Utils >-- {{{ - --- | Private action shamelessly copied and restyled from XMonad.Main source. -setNumlockMask :: X () -setNumlockMask = withDisplay $ \dpy -> do - ms <- io (getModifierMapping dpy) - xs <- sequence - [ do - ks <- io (keycodeToKeysym dpy kc 0) - pure $ if ks == xK_Num_Lock - then setBit 0 (fromIntegral m) - else 0 :: KeyMask - | (m, kcs) <- ms - , kc <- kcs - , kc /= 0 - ] - modify $ \s -> s { numberlockMask = foldr (.|.) 0 xs } - --- | Private function shamelessly copied and refactored from XMonad.Main source. -mkGrabs :: X ([(KeyMask, KeySym)] -> [(KeyMask, KeyCode)]) -mkGrabs = withDisplay $ \dpy -> do - let (minCode, maxCode) = displayKeycodes dpy - allCodes = [fromIntegral minCode .. fromIntegral maxCode] - syms <- io . for allCodes $ \code -> keycodeToKeysym dpy code 0 - let keysymMap = M.fromListWith (++) (zip syms $ pure <$> allCodes) - keysymToKeycodes sym = M.findWithDefault [] sym keysymMap - extraMods <- extraModifiers - pure $ \ks -> do - (mask, sym) <- ks - keycode <- keysymToKeycodes sym - extraMod <- extraMods - pure (mask .|. extraMod, keycode) - --- }}} - - --- NOTE: there is some duplication between this module and core. The --- latter probably will never change, but this needs to be kept in sync --- with any potential bugs that might arise. diff --git a/xmonad-contrib.cabal b/xmonad-contrib.cabal index 881f8759b..edc564474 100644 --- a/xmonad-contrib.cabal +++ b/xmonad-contrib.cabal @@ -76,7 +76,7 @@ library ghc-options: -Wall -Wno-unused-do-bind if flag(pedantic) - ghc-options: -Werror -Wwarn=deprecations -Wwarn=dodgy-imports + ghc-options: -Werror -Wwarn=deprecations -- Keep this in sync with the oldest version in 'tested-with' if impl(ghc > 8.6.5) @@ -496,7 +496,7 @@ test-suite tests default-language: Haskell2010 if flag(pedantic) - ghc-options: -Werror -Wwarn=deprecations -Wwarn=dodgy-imports + ghc-options: -Werror -Wwarn=deprecations -- Keep this in sync with the oldest version in 'tested-with' if impl(ghc > 8.6.5)