aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Hooks')
-rw-r--r--src/Rahm/Desktop/Hooks/WindowChange.hs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/Rahm/Desktop/Hooks/WindowChange.hs b/src/Rahm/Desktop/Hooks/WindowChange.hs
index 0038f47..ec8e445 100644
--- a/src/Rahm/Desktop/Hooks/WindowChange.hs
+++ b/src/Rahm/Desktop/Hooks/WindowChange.hs
@@ -4,13 +4,10 @@ import XMonad
import Control.Monad
import qualified XMonad.Util.ExtensibleState as XS
import Data.Default
-import Rahm.Desktop.Workspaces
+import Rahm.Desktop.Common
import qualified XMonad.StackSet as W
-data Location = Location WorkspaceId (Maybe Window)
- deriving (Read, Show, Eq)
-
newtype LastLocation = LastLocation (Maybe Location)
deriving (Read, Show)
@@ -20,12 +17,14 @@ instance Default LastLocation where
instance ExtensionClass LastLocation where
initialValue = def
extensionType = PersistentExtension
-
+
-- Creates a log hook from the function provided.
--
-- The first argument to the function is the old window, the second argument in
-- the new window.
-withLocationChangeHook :: (Location -> Location -> X ()) -> XConfig l -> XConfig l
+--
+-- If the first window is Nothing, this is the first time XMonad started.
+withLocationChangeHook :: (Maybe Location -> Location -> X ()) -> XConfig l -> XConfig l
withLocationChangeHook fn config =
config {
logHook = do
@@ -36,9 +35,8 @@ withLocationChangeHook fn config =
LastLocation last <- XS.get
- whenJust last $ \lastLocation ->
- when (lastLocation /= currentLocation) $
- fn lastLocation currentLocation
+ when (last /= Just currentLocation) $
+ fn last currentLocation
XS.put $ LastLocation $ Just currentLocation
return ()