aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Main.hsc
diff options
context:
space:
mode:
authorDaniel Schoepe <asgaroth_@gmx.de>2009-02-03 16:55:36 +0100
committerDaniel Schoepe <asgaroth_@gmx.de>2009-02-03 16:55:36 +0100
commit8d9ce607012c847449873a60e458d87716ba924f (patch)
tree6d8131a58a6e1f7a71e63c8ff36e8c96427516b7 /XMonad/Main.hsc
parenteb878b5bf235ca70b192c8b5174de53b830a4885 (diff)
downloadxmonad-8d9ce607012c847449873a60e458d87716ba924f.tar.gz
xmonad-8d9ce607012c847449873a60e458d87716ba924f.tar.xz
xmonad-8d9ce607012c847449873a60e458d87716ba924f.zip
Support for custom event hooks
Ignore-this: f22f1a7ae2d958ba1b3625aa923b7efd darcs-hash:20090203155536-cb1c6-834084657dbd5699030c7dd6dbb1ab153763b631.gz
Diffstat (limited to 'XMonad/Main.hsc')
-rw-r--r--XMonad/Main.hsc10
1 files changed, 9 insertions, 1 deletions
diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc
index 27295ba..499be54 100644
--- a/XMonad/Main.hsc
+++ b/XMonad/Main.hsc
@@ -22,6 +22,7 @@ import qualified Data.Set as S
import Control.Monad.Reader
import Control.Monad.State
import Data.Maybe (fromMaybe)
+import Data.Monoid (getAll)
import Foreign.C
import Foreign.Ptr
@@ -152,11 +153,18 @@ xmonad initxmc = do
prehandle e = let mouse = do guard (ev_event_type e `elem` evs)
return (fromIntegral (ev_x_root e)
,fromIntegral (ev_y_root e))
- in local (\c -> c { mousePosition = mouse }) (handle e)
+ in local (\c -> c { mousePosition = mouse }) (handleWithHook e)
evs = [ keyPress, keyRelease, enterNotify, leaveNotify
, buttonPress, buttonRelease]
+-- | Runs handleEventHook from the configuration and runs the default handler
+-- function if it returned True.
+handleWithHook :: Event -> X ()
+handleWithHook e = do
+ evHook <- asks (handleEventHook . config)
+ whenX (userCodeDef True $ getAll `fmap` evHook e) (handle e)
+
-- ---------------------------------------------------------------------
-- | Event handler. Map X events onto calls into Operations.hs, which
-- modify our internal model of the window manager state.