[xmonad] darcs patch: Correctly implement section 4.1.7 of ICCCM

Roman Cheplyaka roma at ro-che.info
Tue Nov 25 16:29:02 EST 2008


* Spencer Janssen <spencerjanssen at gmail.com> [2008-11-25 04:57:47-0600]
> WMHints has a bitmask that indicates which WM_HINTS are actually present.  I
> believe the correct solution is to simply check whether inputHintBit is set on
> wmh_flags.

Here's amended patch.

2 all: feel free to test/use it, but be aware that it will leak
memory  until getWMHints is fixed in X11.

-- 
Roman I. Cheplyaka (aka Feuerbach @ IRC)
-------------- next part --------------
Tue Nov 25 23:19:44 EET 2008  Roman Cheplyaka <roma at ro-che.info>
  * Correctly implement section 4.1.7 of ICCCM
  Based on patch and investigation by Ivan Tarasov. Fixes #177.
  - do setInputFocus unless application explicitly asks not to do so
  - send WM_TAKE_FOCUS if needed

New patches:

[Correctly implement section 4.1.7 of ICCCM
Roman Cheplyaka <roma at ro-che.info>**20081125211944
 Based on patch and investigation by Ivan Tarasov. Fixes #177.
 - do setInputFocus unless application explicitly asks not to do so
 - send WM_TAKE_FOCUS if needed
] {
hunk ./XMonad/Core.hs 30
-    atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, ManageHook, Query(..), runQuery
+    atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_TAKE_FOCUS, ManageHook, Query(..), runQuery
hunk ./XMonad/Core.hs 189
-atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_STATE :: X Atom
+atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_STATE, atom_WM_TAKE_FOCUS :: X Atom
hunk ./XMonad/Core.hs 193
+atom_WM_TAKE_FOCUS      = getAtom "WM_TAKE_FOCUS"
hunk ./XMonad/Operations.hs 28
-import Data.Bits            ((.|.), (.&.), complement)
+import Data.Bits            ((.|.), (.&.), complement, testBit)
hunk ./XMonad/Operations.hs 325
-    io $ do setInputFocus dpy w revertToPointerRoot 0
+    -- do setInputFocus unless application explicitly asks not to do so
+    wmhints <- io $ getWMHints dpy w
+    when (not (testBit (wmh_flags wmhints) inputHintBit) || wmh_input wmhints) $
+        io $ setInputFocus dpy w revertToPointerRoot 0
hunk ./XMonad/Operations.hs 330
+    
+    -- send WM_TAKE_FOCUS if needed
+    wmtakef <- atom_WM_TAKE_FOCUS
+    wmprot <- atom_WM_PROTOCOLS
+
+    protocols <- io $ getWMProtocols dpy w
+    when (wmtakef `elem` protocols) $ do
+        io $ allocaXEvent $ \ev -> do
+            setEventType ev clientMessage
+            setClientMessageEvent ev w wmprot 32 wmtakef currentTime
+            sendEvent dpy w False noEventMask ev
}

Context:

[Fix #192.
Spencer Janssen <spencerjanssen at gmail.com>**20081021220059] 
[select base < 4 for building on ghc 6.10
Adam Vogt <vogt.adam at gmail.com>**20081013214509] 
[add killWindow function
Joachim Breitner <mail at joachim-breitner.de>**20081005001804
 This is required to kill anything that is not focused, without
 having to focus it first.
] 
[add'l documentation
Devin Mullins <me at twifkak.com>**20080927234639] 
[Regression: ungrab buttons on *non* root windows
Spencer Janssen <spencerjanssen at gmail.com>**20081007214351] 
[Partial fix for #40
Spencer Janssen <spencerjanssen at gmail.com>**20081007212053
 Improvements:
  - clicking on the root will change focus to that screen
  - moving the mouse from a window on a screen to an empty screen changes focus
    to that screen
 The only remaining issue is that moving the mouse between two empty screens
 does not change focus.  In order to solve this, we'd have to select motion events
 on the root window, which is potentially expensive.
] 
[Track mouse position via events received
Spencer Janssen <spencerjanssen at gmail.com>**20081007203953] 
[Fix haddock
Spencer Janssen <spencerjanssen at gmail.com>**20081007094641] 
[Move screen locating code into pointScreen
Spencer Janssen <spencerjanssen at gmail.com>**20081007094207] 
[Make pointWithin a top-level binding
Spencer Janssen <spencerjanssen at gmail.com>**20081007090229] 
[sp README, CONFIG, STYLE, TODO
gwern0 at gmail.com**20080913024457] 
[Use the same X11 dependency as xmonad-contrib
Spencer Janssen <spencerjanssen at gmail.com>**20080921061508] 
[Export focusUp' and focusDown' -- work entirely on stacks
Spencer Janssen <spencerjanssen at gmail.com>**20080911214803] 
[add W.shiftMaster, fix float/tile-reordering bug
Devin Mullins <me at twifkak.com>**20080911053909] 
[TAG 0.8
Spencer Janssen <spencerjanssen at gmail.com>**20080905195412] 
[Spelling.  Any bets on how long this has been there?
Spencer Janssen <spencerjanssen at gmail.com>**20080905195211] 
[Bump version to 0.8
Spencer Janssen <spencerjanssen at gmail.com>**20080905194225] 
[Remove obsolete comments about darcs X11
Spencer Janssen <spencerjanssen at gmail.com>**20080905194915] 
[Recommend latest packages rather than specific versions
Spencer Janssen <spencerjanssen at gmail.com>**20080905194837] 
[Also remove -optl from the executable section
Spencer Janssen <spencerjanssen at gmail.com>**20080820210023] 
[-optl-Wl,-s is not needed with recent Cabal versions
Spencer Janssen <spencerjanssen at gmail.com>**20080820204102] 
[Haddock links
Malebria <malebria at riseup.net>**20080601212515] 
[Haddock syntax for enumeration
Malebria <malebria at riseup.net>**20080601204951] 
[I prefer the spencerjanssen at gmail.com address now
Spencer Janssen <spencerjanssen at gmail.com>**20080714202650] 
[Raise windows in the floating layer when moving or resizing
Trevor Elliott <trevor at galois.com>**20080521215057] 
[add currentTag convenience function
Devin Mullins <me at twifkak.com>**20080511224258] 
[Make Mirror a newtype
Spencer Janssen <sjanssen at cse.unl.edu>**20080508104640] 
[Comments
Spencer Janssen <sjanssen at cse.unl.edu>**20080507013122] 
[Break long line
Spencer Janssen <sjanssen at cse.unl.edu>**20080507012608] 
[Style
Spencer Janssen <sjanssen at cse.unl.edu>**20080507012519] 
[Simplify
Spencer Janssen <sjanssen at cse.unl.edu>**20080507011309] 
[Overhaul Choose, fixes issue 183
Spencer Janssen <sjanssen at cse.unl.edu>**20080506220809] 
[Remember if focus changes were caused by mouse actions or by key commands
Klaus Weidner <kweidner at pobox.com>**20080502175603
 
 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.
] 
[Wibble
Spencer Janssen <sjanssen at cse.unl.edu>**20080506203840] 
[Added doShift function for more user-friendly hooks
Ivan N. Veselov <veselov at gmail.com>**20080506185757] 
[use named colours. fixes startup failure on the XO
Don Stewart <dons at galois.com>**20080502210149] 
[Set focus *after* revealing windows
Spencer Janssen <sjanssen at cse.unl.edu>**20080407222559] 
[Reveal windows after moving/resizing them.
Spencer Janssen <sjanssen at cse.unl.edu>**20080407220756
 This should reduce the number of repaints for newly visible windows.
] 
[Hide newly created but non-visible windows (fixes bug #172)
Spencer Janssen <sjanssen at cse.unl.edu>**20080430014012] 
[formatting, eta expansion
Don Stewart <dons at galois.com>**20080418184337] 
[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:
895e2b0a4240849ced9aaf3bdb9165b6943d610e


More information about the xmonad mailing list