aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks
diff options
context:
space:
mode:
authorDaniel Schoepe <asgaroth_@gmx.de>2009-02-03 17:00:46 +0100
committerDaniel Schoepe <asgaroth_@gmx.de>2009-02-03 17:00:46 +0100
commit43e952a307c22f7098963061f7f6127974158c13 (patch)
treeadeef00961b45644558d6068522e77b36f0b2ff9 /XMonad/Hooks
parenta76661c77c488d648dfdae72b2b8ab98d72c338d (diff)
downloadXMonadContrib-43e952a307c22f7098963061f7f6127974158c13.tar.gz
XMonadContrib-43e952a307c22f7098963061f7f6127974158c13.tar.xz
XMonadContrib-43e952a307c22f7098963061f7f6127974158c13.zip
Adjustments to use the new event hook feature instead of Hooks.EventHook
Ignore-this: f8c239bc8e301cbd6fa509ef748af542 darcs-hash:20090203160046-cb1c6-d66821c5b8a5a60e3b76148654c6e28806b37749.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r--XMonad/Hooks/EwmhDesktops.hs18
-rw-r--r--XMonad/Hooks/ServerMode.hs22
-rw-r--r--XMonad/Hooks/UrgencyHook.hs18
3 files changed, 23 insertions, 35 deletions
diff --git a/XMonad/Hooks/EwmhDesktops.hs b/XMonad/Hooks/EwmhDesktops.hs
index 2340efd..bcf870d 100644
--- a/XMonad/Hooks/EwmhDesktops.hs
+++ b/XMonad/Hooks/EwmhDesktops.hs
@@ -15,14 +15,14 @@
module XMonad.Hooks.EwmhDesktops (
-- * Usage
-- $usage
- EwmhDesktopsHook,
ewmhDesktopsLogHook,
ewmhDesktopsLogHookCustom,
- ewmhDesktopsLayout
+ ewmhDesktopsEventHook
) where
import Data.List
import Data.Maybe
+import Data.Monoid
import XMonad
import Control.Monad
@@ -30,7 +30,6 @@ import qualified XMonad.StackSet as W
import XMonad.Hooks.SetWMName
import XMonad.Util.WorkspaceCompare
-import XMonad.Hooks.EventHook
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@@ -41,9 +40,9 @@ import XMonad.Hooks.EventHook
-- > myLogHook :: X ()
-- > myLogHook = ewmhDesktopsLogHook
-- >
--- > myLayoutHook = ewmhDesktopsLayout $ avoidStruts $ layoutHook defaultConfig
+-- > myHandleEventHook = ewmhDesktopsEventHook
-- >
--- > main = xmonad defaultConfig { layoutHook = myLayouts, logHook = myLogHook }
+-- > main = xmonad defaultConfig { handleEventHook = myHandleEventHook, logHook = myLogHook }
--
-- 'avoidStruts' is used to automatically leave space for dock programs, and
-- can be found in 'XMonad.Hooks.ManageDocks'.
@@ -119,13 +118,8 @@ ewmhDesktopsLogHookCustom f = withWindowSet $ \s -> do
--
-- * _NET_ACTIVE_WINDOW (activate another window, changing workspace if needed)
--
-ewmhDesktopsLayout :: layout a -> HandleEvent EwmhDesktopsHook layout a
-ewmhDesktopsLayout = eventHook EwmhDesktopsHook
-
-data EwmhDesktopsHook = EwmhDesktopsHook deriving ( Show, Read )
-instance EventHook EwmhDesktopsHook where
- handleEvent _ e@ClientMessageEvent {} = do handle e
- handleEvent _ _ = return ()
+ewmhDesktopsEventHook :: Event -> X All
+ewmhDesktopsEventHook e = handle e >> return (All True)
handle :: Event -> X ()
handle ClientMessageEvent {
diff --git a/XMonad/Hooks/ServerMode.hs b/XMonad/Hooks/ServerMode.hs
index 4ff9c95..66e3943 100644
--- a/XMonad/Hooks/ServerMode.hs
+++ b/XMonad/Hooks/ServerMode.hs
@@ -59,16 +59,16 @@ module XMonad.Hooks.ServerMode
( -- * Usage
-- $usage
ServerMode (..)
- , eventHook
+ , serverModeEventHook
) where
import Control.Monad (when)
import Data.List
+import Data.Monoid
import System.IO
import XMonad
import XMonad.Actions.Commands
-import XMonad.Hooks.EventHook
-- $usage
-- You can use this module with the following in your
@@ -76,22 +76,15 @@ import XMonad.Hooks.EventHook
--
-- > import XMonad.Hooks.ServerMode
--
--- Then edit your @layoutHook@ by adding the 'eventHook':
+-- Then edit your @handleEventHook@ by adding the 'serverModeEventHook':
--
--- > layoutHook = eventHook ServerMode $ avoidStruts $ simpleTabbed ||| Full ||| etc..
+-- > main = xmonad defaultConfig { handleEventHook = serverModeEventHook }
--
--- and then:
---
--- > main = xmonad defaultConfig { layoutHook = myLayouts }
---
--- For more detailed instructions on editing the layoutHook see:
---
--- "XMonad.Doc.Extending#Editing_the_layout_hook"
data ServerMode = ServerMode deriving ( Show, Read )
-instance EventHook ServerMode where
- handleEvent _ (ClientMessageEvent {ev_message_type = mt, ev_data = dt}) = do
+serverModeEventHook :: Event -> X All
+serverModeEventHook (ClientMessageEvent {ev_message_type = mt, ev_data = dt}) = do
d <- asks display
a <- io $ internAtom d "XMONAD_COMMAND" False
when (mt == a && dt /= []) $ do
@@ -100,4 +93,5 @@ instance EventHook ServerMode where
case lookup (fromIntegral (head dt) :: Int) (zip [1..] cl) of
Just (c,_) -> runCommand' c
Nothing -> mapM_ (io . hPutStrLn stderr) . listOfCommands $ cl
- handleEvent _ _ = return ()
+ return (All True)
+serverModeEventHook _ = return (All True)
diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs
index b41285e..79b171c 100644
--- a/XMonad/Hooks/UrgencyHook.hs
+++ b/XMonad/Hooks/UrgencyHook.hs
@@ -70,7 +70,6 @@ module XMonad.Hooks.UrgencyHook (
import XMonad
import qualified XMonad.StackSet as W
-import XMonad.Hooks.EventHook
import XMonad.Util.Dzen (dzenWithArgs, seconds)
import XMonad.Util.NamedWindows (getName)
import XMonad.Util.Timer (TimerId, startTimer, handleTimer)
@@ -199,7 +198,7 @@ import Foreign (unsafePerformIO)
-- 'urgencyConfig' to control behavior. To change this, use 'withUrgencyHook'
-- instead.
withUrgencyHook :: (LayoutClass l Window, UrgencyHook h) =>
- h -> XConfig l -> XConfig (HandleEvent (WithUrgencyHook h) l)
+ h -> XConfig l -> XConfig l
withUrgencyHook hook conf = withUrgencyHookC hook urgencyConfig conf
-- | This lets you modify the defaults set in 'urgencyConfig'. An example:
@@ -208,9 +207,9 @@ withUrgencyHook hook conf = withUrgencyHookC hook urgencyConfig conf
--
-- (Don't type the @...@, you dolt.) See 'UrgencyConfig' for details on configuration.
withUrgencyHookC :: (LayoutClass l Window, UrgencyHook h) =>
- h -> UrgencyConfig -> XConfig l -> XConfig (HandleEvent (WithUrgencyHook h) l)
+ h -> UrgencyConfig -> XConfig l -> XConfig l
withUrgencyHookC hook urgConf conf = conf {
- layoutHook = eventHook (WithUrgencyHook hook urgConf) $ layoutHook conf,
+ handleEventHook = \e -> handleEvent (WithUrgencyHook hook urgConf) e >> handleEventHook conf e,
logHook = cleanupUrgents (suppressWhen urgConf) >> logHook conf
}
@@ -322,9 +321,10 @@ data WithUrgencyHook h = WithUrgencyHook h UrgencyConfig
-- ourselves, allowing us to clear urgency when a window is visible, and not to
-- set urgency if a window is visible. If you have a better idea, please, let us
-- know!
-instance UrgencyHook h => EventHook (WithUrgencyHook h) where
- handleEvent wuh event = case event of
- PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w } -> do
+handleEvent :: UrgencyHook h => WithUrgencyHook h -> Event -> X ()
+handleEvent wuh event =
+ case event of
+ PropertyEvent { ev_event_type = t, ev_atom = a, ev_window = w } -> do
when (t == propertyNotify && a == wM_HINTS) $ withDisplay $ \dpy -> do
WMHints { wmh_flags = flags } <- io $ getWMHints dpy w
if (testBit flags urgencyHintBit) then do
@@ -333,9 +333,9 @@ instance UrgencyHook h => EventHook (WithUrgencyHook h) where
else
clearUrgency w
userCodeDef () =<< asks (logHook . config) -- call *after* IORef has been modified
- DestroyWindowEvent {ev_window = w} ->
+ DestroyWindowEvent {ev_window = w} ->
clearUrgency w
- _ ->
+ _ ->
mapM_ handleReminder =<< readReminders
where handleReminder reminder = handleTimer (timer reminder) event $ reminderHook wuh reminder