mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Add function to disable focusFollowsMouse conditionally
This patch adds an event hook to have the focus follow the mouse only if a given condition is true.
This commit is contained in:
parent
e8e6cfcc3a
commit
33046439d6
@ -18,7 +18,9 @@ module XMonad.Layout.MagicFocus
|
|||||||
-- $usage
|
-- $usage
|
||||||
magicFocus,
|
magicFocus,
|
||||||
promoteWarp,
|
promoteWarp,
|
||||||
promoteWarp'
|
promoteWarp',
|
||||||
|
followOnlyIf,
|
||||||
|
disableFollowOnWS
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@ -89,3 +91,17 @@ promoteWarp' pos e@(CrossingEvent {ev_window = w, ev_event_type = t})
|
|||||||
return $ All False
|
return $ All False
|
||||||
else return $ All True
|
else return $ All True
|
||||||
promoteWarp' _ _ = 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user