mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-26 09:41:52 -07:00
Move modifyXS
to X.U.ExtensibleState
This commit is contained in:
@@ -103,20 +103,13 @@ refreshDocks = sendMessage UpdateDocks
|
||||
instance ExtensionClass StrutCache where
|
||||
initialValue = StrutCache M.empty
|
||||
|
||||
modifyXS :: (ExtensionClass a, Eq a) => (a -> a) -> X Bool
|
||||
modifyXS f = do
|
||||
v <- XS.get
|
||||
case f v of
|
||||
v' | v' == v -> return False
|
||||
| otherwise -> XS.put v' >> return True
|
||||
|
||||
updateStrutCache :: Window -> [Strut] -> X Bool
|
||||
updateStrutCache w strut = do
|
||||
modifyXS $ StrutCache . M.insert w strut . fromStrutCache
|
||||
XS.modified $ StrutCache . M.insert w strut . fromStrutCache
|
||||
|
||||
deleteFromStructCache :: Window -> X Bool
|
||||
deleteFromStructCache w = do
|
||||
modifyXS $ StrutCache . M.delete w . fromStrutCache
|
||||
XS.modified $ StrutCache . M.delete w . fromStrutCache
|
||||
|
||||
-- | Detects if the given window is of type DOCK and if so, reveals
|
||||
-- it, but does not manage it.
|
||||
|
@@ -21,6 +21,7 @@ module XMonad.Util.ExtensibleState (
|
||||
, remove
|
||||
, get
|
||||
, gets
|
||||
, modified
|
||||
) where
|
||||
|
||||
import Data.Typeable (typeOf,cast)
|
||||
@@ -115,3 +116,10 @@ gets = flip fmap get
|
||||
-- | Remove the value from the extensible state field that has the same type as the supplied argument
|
||||
remove :: ExtensionClass a => a -> X ()
|
||||
remove wit = modifyStateExts $ M.delete (show . typeOf $ wit)
|
||||
|
||||
modified :: (ExtensionClass a, Eq a) => (a -> a) -> X Bool
|
||||
modified f = do
|
||||
v <- get
|
||||
case f v of
|
||||
v' | v' == v -> return False
|
||||
| otherwise -> put v' >> return True
|
||||
|
Reference in New Issue
Block a user