[xmonad] Patch: fix focus when user is moving the mouse

Klaus Weidner kweidner at pobox.com
Wed Apr 9 15:13:39 EDT 2008


Hello,

the attached patch fixes an issue that had been bugging me - in
focus-follows-mouse mode, the input focus sometimes lagged behind the
mouse pointer, and as a result I was closing or typing into the wrong
window.

Let me know in case there's a better way to approach this, I'm still new
to haskell and xmonad.

I'll send a related patch to the UpdatePointer contrib module separately.

-Klaus

Remember if focus changes were caused by mouse actions or by key commands.
 
 If the user used the mouse to change window focus (moving into or clicking on a
 window), this should be handled differently than focus changes due to keyboard
 commands. Specifically, it's inappropriate to discard window enter/leave events
 while the mouse is moving. This fixes the bug where a fast mouse motion across
 multiple windows resulted in the wrong window keeping focus.
 
 It's also helpful information for contrib modules such as UpdatePointer - it's
 supposed to move the mouse pointer only in response to keyboard actions, not if
 the user was moving the mouse.
-------------- next part --------------

New patches:

[Remember if focus changes were caused by mouse actions or by key commands.
kweidner at pobox.com**20080409190045
 
 If the user used the mouse to change window focus (moving into or clicking on a
 window), this should be handled differently than focus changes due to keyboard
 commands. Specifically, it's inappropriate to discard window enter/leave events
 while the mouse is moving. This fixes the bug where a fast mouse motion across
 multiple windows resulted in the wrong window keeping focus.
 
 It's also helpful information for contrib modules such as UpdatePointer - it's
 supposed to move the mouse pointer only in response to keyboard actions, not if
 the user was moving the mouse.
] {
hunk ./XMonad/Core.hs 59
-    , dragging     :: !(Maybe (Position -> Position -> X (), X ())) }
+    , dragging     :: !(Maybe (Position -> Position -> X (), X ()))
+    , mouse_focused:: !Bool                -- ^ was the last focus change due to mouse action?
+    }
hunk ./XMonad/Main.hsc 101
-            , dragging      = Nothing }
+            , dragging      = Nothing
+            , mouse_focused = False }
hunk ./XMonad/Main.hsc 157
+        modify (\state -> state { mouse_focused = False })
hunk ./XMonad/Operations.hs 165
-    clearEvents enterWindowMask
+    mouse_is_moving <- gets mouse_focused
+    unless (mouse_is_moving) $ clearEvents enterWindowMask
hunk ./XMonad/Operations.hs 296
+    modify (\state -> state { mouse_focused = True })
}

Context:

[XMonad.ManageHook: add 'appName', another name for 'resource'
Lukas Mai <l.mai at web.de>**20080406012006] 
[XMonad.ManageHook: make 'title' locale-aware; haddock cleanup
Lukas Mai <l.mai at web.de>**20080406011338
 
 The code for 'title' was stolen from getname.patch (bug #44).
] 
[XMonad.Main: call setlocale on startup
Lukas Mai <l.mai at web.de>**20080406011234] 
[floats always use current screen (with less bugs)
robreim at bobturf.org**20080405135009] 
[XMonad.Operations: applySizeHint reshuffle
Lukas Mai <l.mai at web.de>**20080404215615
 
 Make applySizeHints take window borders into account. Move old functionality
 to applySizeHintsContents. Add new mkAdjust function that generates a custom
 autohinter for a window.
] 
[XMonad.Layout: documentation cleanup
Lukas Mai <l.mai at web.de>**20080404215444] 
[Remove gaps from the example config
Spencer Janssen <sjanssen at cse.unl.edu>**20080329232959] 
[Remove gaps
Spencer Janssen <sjanssen at cse.unl.edu>**20080325091526] 
[TAG 0.7
Spencer Janssen <sjanssen at cse.unl.edu>**20080329210249] 
Patch bundle hash:
75fe38bbbd6ef78acfbf791ff4a38b4c9de0c466


More information about the xmonad mailing list