[XMonad] Clean up ToggleFade

This commit is contained in:
Ivan Malison 2016-11-25 17:58:48 -08:00
parent 1065ee6937
commit a75fa5f584
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -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