From a75fa5f584ce81c04bbe9134d09064d23d4a6287 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 25 Nov 2016 17:58:48 -0800 Subject: [PATCH] [XMonad] Clean up ToggleFade --- dotfiles/xmonad/xmonad.hs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/dotfiles/xmonad/xmonad.hs b/dotfiles/xmonad/xmonad.hs index b23db20a..56a4c5ad 100644 --- a/dotfiles/xmonad/xmonad.hs +++ b/dotfiles/xmonad/xmonad.hs @@ -288,28 +288,27 @@ getWorkspaceNameFromTag getWSName tag = -- Toggleable fade -newtype ToggleFade = ToggleFade (M.Map Window Bool) - deriving (Typeable, Read, Show) +newtype ToggleFade = + ToggleFade { + fadesMap :: (M.Map Window Bool) + } + deriving (Typeable, Read, Show) instance ExtensionClass ToggleFade where - initialValue = ToggleFade M.empty - extensionType = PersistentExtension + initialValue = ToggleFade M.empty + extensionType = PersistentExtension -fadeEnabledForWindow = ask >>= \w -> liftX (do - ToggleFade toggleMap <- XS.get - return $ M.findWithDefault True w toggleMap) +fadeEnabledForWindow = ask >>= \w -> + liftX $ (M.findWithDefault True w) . fadesMap <$> XS.get -toggleFadeInactiveLogHook = fadeOutLogHook . fadeIf (isUnfocused <&&> fadeEnabledForWindow) +toggleFadeInactiveLogHook = + fadeOutLogHook . fadeIf (isUnfocused <&&> fadeEnabledForWindow) -toggleFadingForActiveWindow = withWindowSet $ \windowSet -> do - ToggleFade toggleMap <- XS.get - let maybeWindow = W.peek windowSet - case maybeWindow of - Nothing -> return () - Just window -> do - let existingValue = M.findWithDefault True window toggleMap - XS.put $ ToggleFade (M.insert window (not existingValue) toggleMap) - return () +toggleFadingForActiveWindow = withWindowSet $ + maybe (return()) toggleFadingForWindow . W.peek + +toggleFadingForWindow w = + fmap (ToggleFade . toggleInMap w . fadesMap) XS.get >>= XS.put -- Minimize not in class