summaryrefslogtreecommitdiffstats
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
commit5c38e151b889f65cac11f1cd19629d04d7e0849d (patch)
tree6d8131a58a6e1f7a71e63c8ff36e8c96427516b7 /XMonad/Main.hsc
parent21943d95090614acde26969dc9f5ef8513a06799 (diff)
downloadmetatile-5c38e151b889f65cac11f1cd19629d04d7e0849d.tar
metatile-5c38e151b889f65cac11f1cd19629d04d7e0849d.zip
Support for custom event hooks
Ignore-this: f22f1a7ae2d958ba1b3625aa923b7efd darcs-hash:20090203155536-cb1c6-834084657dbd5699030c7dd6dbb1ab153763b631
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.