diff options
author | Andrea Rossato <andrea.rossato@unibz.it> | 2008-02-25 00:08:54 +0100 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@unibz.it> | 2008-02-25 00:08:54 +0100 |
commit | ca704d83afeee8b0c58da5b6b2739f26e0efda22 (patch) | |
tree | 3b79c495159d2aea234d3fc4118e237c299cabed /XMonad | |
parent | fd7a7cd8d88ef7ba1a5905b927094afcaf2a9c1b (diff) | |
download | XMonadContrib-ca704d83afeee8b0c58da5b6b2739f26e0efda22.tar.gz XMonadContrib-ca704d83afeee8b0c58da5b6b2739f26e0efda22.tar.xz XMonadContrib-ca704d83afeee8b0c58da5b6b2739f26e0efda22.zip |
EventHook: handle events after the underlying layout and more
- check the first time the Bool is True
- coding and naming style
darcs-hash:20080224230854-32816-9ae0e111f33f6ea3d4ac1dae76ed4e4fab496742.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Hooks/EventHook.hs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/XMonad/Hooks/EventHook.hs b/XMonad/Hooks/EventHook.hs index a45e39f..0700a24 100644 --- a/XMonad/Hooks/EventHook.hs +++ b/XMonad/Hooks/EventHook.hs @@ -19,7 +19,7 @@ ----------------------------------------------------------------------------- module XMonad.Hooks.EventHook - ( -- * Usage: + ( -- * Usage -- $usage -- * Writing a hook @@ -82,26 +82,26 @@ class (Read eh, Show eh) => EventHook eh where data HandleEvent eh l a = HandleEvent (Maybe WorkspaceId) Bool eh (l a) deriving ( Show, Read ) -data EventHandleMsg = ReceiverOff deriving ( Typeable ) +data EventHandleMsg = HandlerOff deriving ( Typeable ) instance Message EventHandleMsg instance (EventHook eh, LayoutClass l a) => LayoutClass (HandleEvent eh l) a where - runLayout (Workspace i (HandleEvent Nothing _ eh l) ms) r = do - broadcastMessage ReceiverOff - iws <- (tag . workspace . current) <$> gets windowset + runLayout (Workspace i (HandleEvent Nothing True eh l) ms) r = do + broadcastMessage HandlerOff + iws <- (tag . workspace . current) <$> gets windowset (wrs, ml) <- runLayout (Workspace i l ms) r return (wrs, Just $ HandleEvent (Just iws) True eh (fromMaybe l ml)) - runLayout (Workspace i (HandleEvent j b eh l) ms) r = do + runLayout (Workspace i (HandleEvent mi b eh l) ms) r = do (wrs, ml) <- runLayout (Workspace i l ms) r - return (wrs, Just $ HandleEvent j b eh (fromMaybe l ml)) + return (wrs, Just $ HandleEvent mi b eh (fromMaybe l ml)) - handleMessage (HandleEvent mi True eh l) m - | Just ReceiverOff <- fromMessage m = return . Just $ HandleEvent mi False eh l - | Just e <- fromMessage m = handleEvent eh e >> - handleMessage l (SomeMessage e) >>= - maybe (return Nothing) (\l' -> return . Just $ HandleEvent mi True eh l') - handleMessage (HandleEvent mi b eh l) m = handleMessage l m >>= - maybe (return Nothing) (\l' -> return . Just $ HandleEvent mi b eh l') + handleMessage (HandleEvent i True eh l) m + | Just HandlerOff <- fromMessage m = return . Just $ HandleEvent i False eh l + | Just e <- fromMessage m = handleMessage l (SomeMessage e) >>= \ml -> + handleEvent eh e >> + maybe (return Nothing) (\l' -> return . Just $ HandleEvent i True eh l') ml + handleMessage (HandleEvent i b eh l) m = handleMessage l m >>= + maybe (return Nothing) (\l' -> return . Just $ HandleEvent i b eh l') description (HandleEvent _ _ _ l) = description l |