aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schoepe <daniel.schoepe@gmail.com>2009-08-29 23:29:16 +0200
committerDaniel Schoepe <daniel.schoepe@gmail.com>2009-08-29 23:29:16 +0200
commit3bd3fd1d4bd1af1ffe306307a80387c82d304664 (patch)
treeeddab8145e36b9366bddd8174968cf8d34b9174b
parent71cbab90d14385ea4bf723ca8df06d29065caabe (diff)
downloadXMonadContrib-3bd3fd1d4bd1af1ffe306307a80387c82d304664.tar.gz
XMonadContrib-3bd3fd1d4bd1af1ffe306307a80387c82d304664.tar.xz
XMonadContrib-3bd3fd1d4bd1af1ffe306307a80387c82d304664.zip
Add function to disable focusFollowsMouse conditionally
Ignore-this: de73003672f76d955fe4476ca279cded This patch adds an event hook to have the focus follow the mouse only if a given condition is true. darcs-hash:20090829212916-7f603-6923680ea9eb60841fc43912cba96fa7f300539a.gz
-rw-r--r--XMonad/Layout/MagicFocus.hs18
1 files changed, 17 insertions, 1 deletions
diff --git a/XMonad/Layout/MagicFocus.hs b/XMonad/Layout/MagicFocus.hs
index ce57725..10d075c 100644
--- a/XMonad/Layout/MagicFocus.hs
+++ b/XMonad/Layout/MagicFocus.hs
@@ -18,7 +18,9 @@ module XMonad.Layout.MagicFocus
-- $usage
magicFocus,
promoteWarp,
- promoteWarp'
+ promoteWarp',
+ followOnlyIf,
+ disableFollowOnWS
) where
import XMonad
@@ -89,3 +91,17 @@ promoteWarp' pos e@(CrossingEvent {ev_window = w, ev_event_type = t})
return $ All False
else return $ All True
promoteWarp' _ _ = return $ All True
+
+-- | Another event hook to override the focusFollowsMouse and make the pointer
+-- only follow if a given condition is satisfied. This could be used to disable
+-- focusFollowsMouse only for given workspaces or layouts.
+-- Beware that your focusFollowsMouse setting is ignored if you use this event hook.
+followOnlyIf :: X Bool -> Event -> X All
+followOnlyIf cond e@(CrossingEvent {ev_window = w, ev_event_type = t})
+ | t == enterNotify && ev_mode e == notifyNormal
+ = whenX cond (focus w) >> return (All False)
+followOnlyIf _ _ = return $ All True
+
+-- | Disables focusFollow on the given workspaces:
+disableFollowOnWS :: [WorkspaceId] -> X Bool
+disableFollowOnWS wses = (`notElem` wses) `fmap` gets (W.currentTag . windowset)