From 85792dc5fe5ee9d02046f059f7a2c58fbd824026 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 29 Dec 2007 03:33:01 +0100 Subject: Make focus-follows-mouse configurable darcs-hash:20071229023301-a5988-7576eb2625061b2dcca3da69d1be4a1e50a76e71.gz --- XMonad/Config.hs | 13 ++++++++++--- XMonad/Core.hs | 1 + XMonad/Main.hs | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Config.hs b/XMonad/Config.hs index 2506be6..677248d 100644 --- a/XMonad/Config.hs +++ b/XMonad/Config.hs @@ -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 } diff --git a/XMonad/Core.hs b/XMonad/Core.hs index 3b97ed3..9252b05 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -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 } diff --git a/XMonad/Main.hs b/XMonad/Main.hs index 31dad6a..94a8a22 100644 --- a/XMonad/Main.hs +++ b/XMonad/Main.hs @@ -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}) -- cgit v1.2.3