Make focus-follows-mouse configurable

This commit is contained in:
Spencer Janssen
2007-12-29 02:33:01 +00:00
parent aeef36f74c
commit 5e61b137fb
3 changed files with 13 additions and 4 deletions

View File

@@ -26,10 +26,12 @@ module XMonad.Config (defaultConfig) where
--
import XMonad.Core as XMonad hiding
(workspaces,manageHook,numlockMask,keys,logHook,borderWidth,mouseBindings
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor)
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor
,focusFollowsMouse)
import qualified XMonad.Core as XMonad
(workspaces,manageHook,numlockMask,keys,logHook,borderWidth,mouseBindings
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor)
,defaultGaps,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor
,focusFollowsMouse)
import XMonad.Layout
import XMonad.Operations
@@ -165,6 +167,10 @@ layout = tiled ||| Mirror tiled ||| Full
terminal :: String
terminal = "xterm"
-- | Whether focus follows the mouse pointer.
focusFollowsMouse :: Bool
focusFollowsMouse = True
-- | The xmonad key bindings. Add, modify or remove key bindings here.
--
-- (The comment formatting character is used when generating the manpage)
@@ -251,4 +257,5 @@ defaultConfig = XConfig
, XMonad.keys = keys
, XMonad.logHook = logHook
, XMonad.mouseBindings = mouseBindings
, XMonad.manageHook = manageHook }
, XMonad.manageHook = manageHook
, XMonad.focusFollowsMouse = focusFollowsMouse }

View File

@@ -88,6 +88,7 @@ data XConfig l = XConfig
-- ^ The mouse bindings
, borderWidth :: !Dimension -- ^ The border width
, logHook :: !(X ()) -- ^ The action to perform when the windows set is changed
, focusFollowsMouse :: !Bool -- ^ Whether window entry events can change focus
}

View File

@@ -194,7 +194,8 @@ handle e@(ButtonEvent {ev_window = w,ev_event_type = t,ev_button = b })
-- entered a normal window, makes this focused.
handle e@(CrossingEvent {ev_window = w, ev_event_type = t})
| t == enterNotify && ev_mode e == notifyNormal
&& ev_detail e /= notifyInferior = focus w
&& ev_detail e /= notifyInferior
= whenX (asks $ focusFollowsMouse . config) (focus w)
-- left a window, check if we need to focus root
handle e@(CrossingEvent {ev_event_type = t})