aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks
diff options
context:
space:
mode:
authorDaniel Schoepe <daniel.schoepe@gmail.com>2009-11-16 18:10:13 +0100
committerDaniel Schoepe <daniel.schoepe@gmail.com>2009-11-16 18:10:13 +0100
commite8c2239f6fe58b4a9bacd3bfed984841bb860a27 (patch)
tree8647006ee46087129f1ef4249f8f0265a9bca602 /XMonad/Hooks
parenta64225bbe26df7d9873ac1d4c8143e3146045b7a (diff)
downloadXMonadContrib-e8c2239f6fe58b4a9bacd3bfed984841bb860a27.tar.gz
XMonadContrib-e8c2239f6fe58b4a9bacd3bfed984841bb860a27.tar.xz
XMonadContrib-e8c2239f6fe58b4a9bacd3bfed984841bb860a27.zip
Changed interface of X.U.ExtensibleState
Ignore-this: 9a830f9341e461628974890bab0bd65b Changed the interface of X.U.ExtensibleState to resemble that of Control.Monad.State and modified the modules that use it accordingly. darcs-hash:20091116171013-7f603-0631dc163d78785b123bc10164ee3295add28b60.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r--XMonad/Hooks/DynamicHooks.hs10
-rw-r--r--XMonad/Hooks/FloatNext.hs16
-rw-r--r--XMonad/Hooks/PositionStoreHooks.hs2
-rw-r--r--XMonad/Hooks/UrgencyHook.hs10
4 files changed, 18 insertions, 20 deletions
diff --git a/XMonad/Hooks/DynamicHooks.hs b/XMonad/Hooks/DynamicHooks.hs
index 9d4d776..a2a0b7e 100644
--- a/XMonad/Hooks/DynamicHooks.hs
+++ b/XMonad/Hooks/DynamicHooks.hs
@@ -23,7 +23,7 @@ module XMonad.Hooks.DynamicHooks (
) where
import XMonad
-import XMonad.Util.ExtensibleState
+import qualified XMonad.Util.ExtensibleState as XS
import Data.List
import Data.Maybe (listToMaybe)
@@ -63,13 +63,13 @@ instance ExtensionClass DynamicHooks where
-- | Master 'ManageHook' that must be in your @xmonad.hs@ 'ManageHook'.
dynamicMasterHook :: ManageHook
dynamicMasterHook = (ask >>= \w -> liftX (do
- dh <- getState
+ dh <- XS.get
(Endo f) <- runQuery (permanent dh) w
ts <- mapM (\(q,a) -> runQuery q w >>= \x -> return (x,(q, a))) (transients dh)
let (ts',nts) = partition fst ts
gs <- mapM (flip runQuery w . snd . snd) ts'
let (Endo g) = maybe (Endo id) id $ listToMaybe gs
- putState $ dh { transients = map snd nts }
+ XS.put $ dh { transients = map snd nts }
return $ Endo $ f . g
))
-- | Appends the given 'ManageHook' to the permanent dynamic 'ManageHook'.
@@ -78,7 +78,7 @@ addDynamicHook m = updateDynamicHook (<+> m)
-- | Modifies the permanent 'ManageHook' with an arbitrary function.
updateDynamicHook :: (ManageHook -> ManageHook) -> X ()
-updateDynamicHook f = modifyState $ \dh -> dh { permanent = f (permanent dh) }
+updateDynamicHook f = XS.modify $ \dh -> dh { permanent = f (permanent dh) }
-- | Creates a one-shot 'ManageHook'. Note that you have to specify the two
-- parts of the 'ManageHook' separately. Where you would usually write:
@@ -90,4 +90,4 @@ updateDynamicHook f = modifyState $ \dh -> dh { permanent = f (permanent dh) }
-- > oneShotHook dynHooksRef (className =? "example) doFloat
--
oneShotHook :: Query Bool -> ManageHook -> X ()
-oneShotHook q a = modifyState $ \dh -> dh { transients = (q,a):(transients dh) }
+oneShotHook q a = XS.modify $ \dh -> dh { transients = (q,a):(transients dh) }
diff --git a/XMonad/Hooks/FloatNext.hs b/XMonad/Hooks/FloatNext.hs
index 1d7fa86..7a555ea 100644
--- a/XMonad/Hooks/FloatNext.hs
+++ b/XMonad/Hooks/FloatNext.hs
@@ -39,7 +39,7 @@ module XMonad.Hooks.FloatNext ( -- * Usage
import Prelude hiding (all)
import XMonad
-import XMonad.Util.ExtensibleState
+import qualified XMonad.Util.ExtensibleState as XS
import Control.Monad (join,guard)
import Control.Applicative ((<$>))
@@ -48,13 +48,13 @@ import Control.Arrow (first, second)
{- Helper functions -}
_set :: ((a -> a) -> (Bool, Bool) -> (Bool, Bool)) -> a -> X ()
-_set f b = modifyState' (f $ const b)
+_set f b = modify' (f $ const b)
_toggle :: ((Bool -> Bool) -> (Bool, Bool) -> (Bool, Bool)) -> X ()
-_toggle f = modifyState' (f not)
+_toggle f = modify' (f not)
_get :: ((Bool, Bool) -> a) -> X a
-_get f = f . getFloatMode <$> getState
+_get f = XS.gets (f . getFloatMode)
_pp :: ((Bool, Bool) -> Bool) -> String -> (String -> String) -> X (Maybe String)
_pp f s st = (\b -> guard b >> Just (st s)) <$> _get f
@@ -66,8 +66,8 @@ data FloatMode = FloatMode { getFloatMode :: (Bool,Bool) } deriving (Typeable)
instance ExtensionClass FloatMode where
initialValue = FloatMode (False,False)
-modifyState' :: ((Bool,Bool) -> (Bool,Bool)) -> X ()
-modifyState' f = modifyState (FloatMode . f . getFloatMode)
+modify' :: ((Bool,Bool) -> (Bool,Bool)) -> X ()
+modify' f = XS.modify (FloatMode . f . getFloatMode)
-- $usage
-- This module provides actions (that can be set as keybindings)
@@ -95,8 +95,8 @@ modifyState' f = modifyState (FloatMode . f . getFloatMode)
-- | This 'ManageHook' will selectively float windows as set
-- by 'floatNext' and 'floatAllNew'.
floatNextHook :: ManageHook
-floatNextHook = do (next, all) <- liftX $ getFloatMode <$> getState
- liftX $ putState $ FloatMode (False, all)
+floatNextHook = do (next, all) <- liftX $ XS.gets getFloatMode
+ liftX $ XS.put $ FloatMode (False, all)
if next || all then doFloat else idHook
-- | @floatNext True@ arranges for the next spawned window to be
diff --git a/XMonad/Hooks/PositionStoreHooks.hs b/XMonad/Hooks/PositionStoreHooks.hs
index 92ad0ae..60fb448 100644
--- a/XMonad/Hooks/PositionStoreHooks.hs
+++ b/XMonad/Hooks/PositionStoreHooks.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE PatternSignatures #-}
-
----------------------------------------------------------------------------
-- |
-- Module : XMonad.Hooks.PositionStoreHooks
diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs
index 6a150c8..7dcdf18 100644
--- a/XMonad/Hooks/UrgencyHook.hs
+++ b/XMonad/Hooks/UrgencyHook.hs
@@ -72,7 +72,7 @@ import XMonad
import qualified XMonad.StackSet as W
import XMonad.Util.Dzen (dzenWithArgs, seconds)
-import XMonad.Util.ExtensibleState
+import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.NamedWindows (getName)
import XMonad.Util.Timer (TimerId, startTimer, handleTimer)
@@ -275,14 +275,14 @@ clearUrgents = adjustUrgents (const []) >> adjustReminders (const [])
-- it, or 'withUrgents', in your custom logHook, to display the workspaces that
-- contain urgent windows.
readUrgents :: X [Window]
-readUrgents = fromUrgents <$> getState
+readUrgents = XS.gets fromUrgents
-- | An HOF version of 'readUrgents', for those who prefer that sort of thing.
withUrgents :: ([Window] -> X a) -> X a
withUrgents f = readUrgents >>= f
adjustUrgents :: ([Window] -> [Window]) -> X ()
-adjustUrgents f = modifyState $ onUrgents f
+adjustUrgents = XS.modify . onUrgents
type Interval = Rational
@@ -301,10 +301,10 @@ instance ExtensionClass [Reminder] where
-- | Stores the list of urgency reminders.
readReminders :: X [Reminder]
-readReminders = getState
+readReminders = XS.get
adjustReminders :: ([Reminder] -> [Reminder]) -> X ()
-adjustReminders f = modifyState f
+adjustReminders = XS.modify
clearUrgency :: Window -> X ()
clearUrgency w = adjustUrgents (delete w) >> adjustReminders (filter $ (w /=) . window)