[xmonad] Patch: Use threadWaitRead to avoid blocking in nextEvent in the main loop

Adam Sampson ats at offog.org
Sun Jun 22 11:22:05 EDT 2008


On Sun, Jun 22, 2008 at 10:37:10AM -0400, Brandon S. Allbery KF8NH wrote:
> It is possible, and there are several ways to check

OK -- here's a version that uses XPending.

Thanks,

-- 
Adam Sampson <ats at offog.org>                         <http://offog.org/>
-------------- next part --------------

New patches:

[Use threadWaitRead to avoid blocking in nextEvent in the main loop
Adam Sampson <ats at offog.org>**20080622151804
 
 This makes it possible to use lightweight threads (spawned using forkIO)
 in xmonad extensions; previously they wouldn't get a chance to run
 except when xmonad received an event.
] {
hunk ./XMonad/Main.hsc 25
+import Control.Concurrent
hunk ./XMonad/Main.hsc 140
-            forever_ $ handle =<< io (nextEvent dpy e >> getEvent e)
+            forever_ $ handle =<< io (waitNextEvent dpy e >> getEvent e)
hunk ./XMonad/Main.hsc 145
+            waitNextEvent dpy e = do
+                -- if there are no events in the queue, give other threads a
+                -- chance to run
+                n <- pending dpy
+                when (n == 0) $
+                    threadWaitRead (fromIntegral $ connectionNumber dpy)
+                nextEvent dpy e
+
}

Context:

[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:
320592bdcbe2cb2d4e03e7dc7346e20d6d3a951c


More information about the xmonad mailing list