Skip to content

Commit

Permalink
(wip) Revert "X.U.Grab: Hide mkGrabs from XMonad"
Browse files Browse the repository at this point in the history
Now that we require xmonad 0.18.0, this is no longer needed.

This reverts commit 0934fe5.
  • Loading branch information
liskin committed May 13, 2024
1 parent 02f124c commit 036f68f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 44 deletions.
44 changes: 2 additions & 42 deletions XMonad/Util/Grab.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module XMonad.Util.Grab
) where

-- core
import XMonad hiding (mkGrabs)
import XMonad

import Control.Monad ( when )
import Data.Bits ( setBit )
Expand Down Expand Up @@ -88,49 +88,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.
4 changes: 2 additions & 2 deletions xmonad-contrib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 036f68f

Please sign in to comment.