From 04d0ab42a39df36acfc84846cc122f0bb9786446 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 12 Nov 2021 11:06:37 -0700 Subject: Use XMonad's EtensibleState Change the Marking to use XMonad's extensible state rather than hand-rolling it myself. Allowed me to delete the XPlus monad. --- src/Internal/Keys.hs | 55 ++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'src/Internal/Keys.hs') diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs index 64a7506..591861f 100644 --- a/src/Internal/Keys.hs +++ b/src/Internal/Keys.hs @@ -7,7 +7,6 @@ import Graphics.X11.ExtraTypes.XorgDefault import System.Process import XMonad.Util.Ungrab import XMonad.Layout.Spacing -import Internal.XPlus import Data.Maybe (isJust) import Debug.Trace import Control.Applicative @@ -40,14 +39,13 @@ import Internal.PassMenu type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ()) applyKeys :: XConfig l -> IO (XConfig l) -applyKeys config@(XConfig {modMask = modm}) = - withNewMarkContext $ \markContext -> do - ks <- newKeys markContext - ms <- newMouse markContext +applyKeys config@(XConfig {modMask = modm}) = do + ks <- newKeys + ms <- newMouse return $ config { keys = ks, mouseBindings = ms } -newMouse :: MarkContext -> IO (XConfig l -> Map (KeyMask, Button) (Window -> X ())) -newMouse markContext = +newMouse :: IO (XConfig l -> Map (KeyMask, Button) (Window -> X ())) +newMouse = return $ \config@(XConfig {modMask = modm}) -> Map.fromList [ ((modm, button1), \w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster) @@ -71,8 +69,8 @@ modifyWindowBorder :: Integer -> SpacingModifier modifyWindowBorder i = ModifyWindowBorder $ \(Border a b c d) -> (Border (a + i) (b + i) (c + i) (d + i)) -newKeys :: MarkContext -> IO (KeyMap l) -newKeys markContext = +newKeys :: IO (KeyMap l) +newKeys = return $ \config@(XConfig {modMask = modm}) -> Map.fromList [ ((modm, xK_F12), (void $ spawn "spotify-control next")) @@ -100,33 +98,30 @@ newKeys markContext = , ((mod4Mask, xK_BackSpace), (void $ spawn "xterm")) , ((modm, xK_BackSpace), (void $ spawn "pkill -SIGUSR1 xmobar")) , ((modm, xK_t), (void $ spawn (terminal config))) - , ((modm, xK_m), (submap $ mapAlpha modm (markCurrentWindow markContext))) - , ((modm, xK_w), runXPlus markContext config windowJump) + , ((modm, xK_m), (submap $ mapAlpha modm markCurrentWindow)) + , ((modm, xK_w), windowJump) , ((modm, xK_space), sendMessage NextLayout) , ((modm .|. shiftMask, xK_space), sendMessage FirstLayout) , ((modm, xK_apostrophe), (submap $ Map.insert (modm, xK_apostrophe) - (jumpToLast markContext) - (mapAlpha modm (jumpToMark markContext)))) + jumpToLast + (mapAlpha modm jumpToMark))) , ((modm .|. shiftMask, xK_apostrophe), (submap $ Map.insert (modm .|. shiftMask, xK_apostrophe) - (swapWithLastMark markContext) - (mapAlpha (modm .|. shiftMask) (swapWithMark markContext)))) + swapWithLastMark + (mapAlpha (modm .|. shiftMask) swapWithMark))) , ((modm, xK_g), (submap $ - mapNumbersAndAlpha 0 ( - runXPlus markContext config . gotoWorkspace))) + mapNumbersAndAlpha 0 gotoWorkspace)) , ((modm .|. shiftMask, xK_g), (submap $ - mapNumbersAndAlpha 0 ( - runXPlus markContext config . shiftToWorkspace))) + mapNumbersAndAlpha 0 shiftToWorkspace)) , ((modm .|. shiftMask .|. mod1Mask, xK_g), (submap $ - mapNumbersAndAlpha 0 ( - runXPlus markContext config . swapWorkspace))) + mapNumbersAndAlpha 0 swapWorkspace)) , ((modm, xK_minus), sendMessage (IncMasterN (-1))) , ((modm, xK_plus), sendMessage (IncMasterN 1)) @@ -149,17 +144,17 @@ newKeys markContext = , ((modm, xK_Tab), windows W.focusDown) , ((modm .|. shiftMask, xK_Tab), windows W.focusUp) - , ((modm, xK_a), runXPlus markContext config (withScreen W.view 0)) - , ((modm, xK_o), runXPlus markContext config (withScreen W.view 1)) - , ((modm, xK_e), runXPlus markContext config (withScreen W.view 2)) + , ((modm, xK_a), withScreen W.view 0) + , ((modm, xK_o), withScreen W.view 1) + , ((modm, xK_e), withScreen W.view 2) - , ((modm .|. shiftMask, xK_a), runXPlus markContext config (withScreen W.shift 0)) - , ((modm .|. shiftMask, xK_o), runXPlus markContext config (withScreen W.shift 1)) - , ((modm .|. shiftMask, xK_e), runXPlus markContext config (withScreen W.shift 2)) + , ((modm .|. shiftMask, xK_a), withScreen W.shift 0) + , ((modm .|. shiftMask, xK_o), withScreen W.shift 1) + , ((modm .|. shiftMask, xK_e), withScreen W.shift 2) - , ((modm .|. mod1Mask, xK_a), runXPlus markContext config (withScreen W.greedyView 0)) - , ((modm .|. mod1Mask, xK_o), runXPlus markContext config (withScreen W.greedyView 1)) - , ((modm .|. mod1Mask, xK_e), runXPlus markContext config (withScreen W.greedyView 2)) + , ((modm .|. mod1Mask, xK_a), withScreen W.greedyView 0) + , ((modm .|. mod1Mask, xK_o), withScreen W.greedyView 1) + , ((modm .|. mod1Mask, xK_e), withScreen W.greedyView 2) , ((modm, xK_b), sendMessage ToggleStruts) -- Buttons programmed on my mouse. -- cgit