Skip to content

Commit

Permalink
X.Prelude: Adapt cleanKeyMask to stripModMask addition to core
Browse files Browse the repository at this point in the history
(Unfortunately MIN_VERSION_xmonad has only 3 parameters and adding a
cabal flag seems too heavyweight.)

Relates: xmonad/xmonad#374
Relates: xmonad/xmonad#172
Relates: xmonad#290
  • Loading branch information
liskin committed Feb 10, 2022
1 parent 1b728ff commit bd637ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions XMonad/Prelude.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
--------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -127,8 +128,12 @@ keyToString = uncurry (++) . bimap (keymaskToString 0) keysymToString
-- the X server already for compatibility reasons. For more info, see:
-- <https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Delivering_a_Key_or_Button_Event_to_a_Client>
cleanKeyMask :: X (KeyMask -> KeyMask)
cleanKeyMask = cleanKeyMask' <$> gets numberlockMask
#if MIN_VERSION_xmonad(0, 17, 1)
cleanKeyMask = cleanKeyMask' <$> join (asks (stripModMask . config))
#else
cleanKeyMask = cleanKeyMask' . (lockMask .|.) <$> gets numberlockMask
#endif

cleanKeyMask' :: KeyMask -> KeyMask -> KeyMask
cleanKeyMask' numLockMask mask =
mask .&. complement (numLockMask .|. lockMask) .&. (button1Mask - 1)
cleanKeyMask' stripMask mask =
mask .&. complement stripMask .&. (button1Mask - 1)

0 comments on commit bd637ba

Please sign in to comment.