diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2022-04-17 23:15:55 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | 3a26f3eb4f02052fdb97dcdd884f408d52b383a9 (patch) | |
| tree | 592287a0d97ac6e6fef9c24846f7575873bf9a0c /src/Rahm/Desktop/Hooks | |
| parent | 1ad36bd0e332bfe4354c9966191603f116196ecd (diff) | |
| download | rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.tar.gz rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.tar.bz2 rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.zip | |
Starting to implement window management language
Diffstat (limited to 'src/Rahm/Desktop/Hooks')
| -rw-r--r-- | src/Rahm/Desktop/Hooks/WindowChange.hs | 16 |
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 () |