cleanup xmonad code

This commit is contained in:
Leon Kowarschick 2020-07-06 20:05:46 +02:00
parent 20a68552c1
commit 259eeec59e

View file

@ -44,14 +44,11 @@ where
import XMonad import XMonad
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import qualified XMonad.Util.ExtensibleState as XS import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.Run ( runProcessWithInput
, safeSpawn
)
import XMonad.Util.WindowProperties import XMonad.Util.WindowProperties
import XMonad.Util.Run ( runProcessWithInput )
import Data.Semigroup ( All(..) ) import Data.Semigroup ( All(..) )
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.List ( isInfixOf ) import Data.List ( isInfixOf )
import Data.Maybe ( fromMaybe )
import Control.Monad ( when ) import Control.Monad ( when )
-- $usage -- $usage
@ -154,13 +151,7 @@ swallowEventHook parentQueries childQueries event = do
$ moveFloatingState childWindow parent $ moveFloatingState childWindow parent
$ ws { W.floating = oldFloating } $ ws { W.floating = oldFloating }
) )
else windows else windows (insertIntoStack parent)
(W.modify
(Just $ W.Stack parent [] [])
(\s -> Just
$ s { W.focus = parent, W.down = W.focus s : W.down s }
)
)
-- after restoring, we remove the information about the swallowing from the state. -- after restoring, we remove the information about the swallowing from the state.
XS.modify $ removeSwallowed childWindow XS.modify $ removeSwallowed childWindow
XS.modify $ setStackBeforeWindowClosing Nothing XS.modify $ setStackBeforeWindowClosing Nothing
@ -169,6 +160,14 @@ swallowEventHook parentQueries childQueries event = do
_ -> return () _ -> return ()
return $ All True return $ All True
-- | insert a window as focused into the current stack, moving the previously focused window down the stack
insertIntoStack :: a -> W.StackSet i l a sid sd -> W.StackSet i l a sid sd
insertIntoStack win = W.modify
(Just $ W.Stack win [] [])
(\s -> Just $ s { W.focus = win, W.down = W.focus s : W.down s })
-- | run a pure transformation on the Stack of the currently focused workspace. -- | run a pure transformation on the Stack of the currently focused workspace.
updateCurrentStack updateCurrentStack
:: (Maybe (W.Stack a) -> Maybe (W.Stack a)) :: (Maybe (W.Stack a) -> Maybe (W.Stack a))