From 3bd3fd1d4bd1af1ffe306307a80387c82d304664 Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Sat, 29 Aug 2009 23:29:16 +0200 Subject: 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 --- XMonad/Layout/MagicFocus.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'XMonad/Layout/MagicFocus.hs') 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) -- cgit v1.2.3