
New patches:

[Add --replace flag with documentation (issue 99).
Adam Vogt <vogt.adam@gmail.com>**20091220183529
 Ignore-this: c56000295b75c66309913e29e1671d88
] {
hunk ./Main.hs 69
         "  --help                       Print this message" :
         "  --version                    Print the version number" :
         "  --recompile                  Recompile your ~/.xmonad/xmonad.hs" :
+        "  --replace                    Request the running window manage to exit" :
         "  --restart                    Request a running xmonad process to restart" :
 #ifdef TESTING
         "  --run-tests                  Run the test suite" :
hunk ./XMonad/Main.hsc 21
 import Control.Arrow (second)
 import Data.Bits
 import Data.List ((\\))
+import Data.Function
 import qualified Data.Map as M
 import qualified Data.Set as S
 import Control.Monad.Reader
hunk ./XMonad/Main.hsc 71
 
     rootw  <- rootWindow dpy dflt
 
+    args <- getArgs
+
+    when ("--replace" `elem` args) $ replace dpy dflt rootw
+
     -- If another WM is running, a BadAccess error will be returned.  The
     -- default error handler will write the exception to stderr and exit with
     -- an error.
hunk ./XMonad/Main.hsc 97
                  return (fromMaybe fbc_ v)
 
     hSetBuffering stdout NoBuffering
-    args <- getArgs
 
     let layout = layoutHook xmc
         lreads = readsLayout layout
hunk ./XMonad/Main.hsc 370
     ems <- extraModifiers
     ba <- asks buttonActions
     mapM_ (\(m,b) -> mapM_ (grab b . (m .|.)) ems) (M.keys $ ba)
+
+-- | @replace@ to signals compliant window managers to exit.
+replace :: Display -> ScreenNumber -> Window -> IO ()
+replace dpy dflt rootw = do
+    -- check for other WM
+    wmSnAtom <- internAtom dpy ("WM_S" ++ show dflt) False
+    currentWmSnOwner <- xGetSelectionOwner dpy wmSnAtom
+    when (currentWmSnOwner /= 0) $ do
+        -- prepare to receive destroyNotify for old WM
+        selectInput dpy currentWmSnOwner structureNotifyMask
+
+        -- create off-screen window
+        netWmSnOwner <- allocaSetWindowAttributes $ \attributes -> do
+            set_override_redirect attributes True
+            set_event_mask attributes propertyChangeMask
+            let screen = defaultScreenOfDisplay dpy
+                visual = defaultVisualOfScreen screen
+                attrmask = cWOverrideRedirect .|. cWEventMask
+            createWindow dpy rootw (-100) (-100) 1 1 0 copyFromParent copyFromParent visual attrmask attributes
+
+        -- try to acquire wmSnAtom, this should signal the old WM to terminate
+        xSetSelectionOwner dpy wmSnAtom netWmSnOwner currentTime
+
+        -- SKIPPED: check if we acquired the selection
+        -- SKIPPED: send client message indicating that we are now the WM
+
+        -- wait for old WM to go away
+        fix $ \again -> do
+            evt <- allocaXEvent $ \event -> do
+                windowEvent dpy currentWmSnOwner structureNotifyMask event
+                get_EventType event
+
+            when (evt /= destroyNotify) again
hunk ./man/xmonad.1.markdown 60
 --restart
 :   Causes the currently running _xmonad_ process to restart
 
+--replace
+:   Replace an existing window manager
+
 --version
 :   Display version of _xmonad_
 
}

Context:

[TAG 0.9.1
Spencer Janssen <spencerjanssen@gmail.com>**20091216233643
 Ignore-this: 856abdca8283155bbb8bdf003797ba34
] 
[extra-source-files for the new manpage
Spencer Janssen <spencerjanssen@gmail.com>**20091216232005
 Ignore-this: 919d964238198dd56d96a5052c2419c7
] 
[Bump to 0.9.1
Spencer Janssen <spencerjanssen@gmail.com>**20091216231110
 Ignore-this: 8a03850d758e1e4030d930cd8bf08ba9
] 
[Determine numlockMask automatically, fixes #120
Spencer Janssen <spencerjanssen@gmail.com>**20091216012140
 Ignore-this: d80c82dd0a23dc7a77fdc32fd2792130
] 
[Update for X11 1.5.0.0
Spencer Janssen <spencerjanssen@gmail.com>**20091216011700
 Ignore-this: 669c764c4c0ca516c8bdc1dfa35cd66
] 
[Safer X11 version dependency
Spencer Janssen <spencerjanssen@gmail.com>**20091216010330
 Ignore-this: 8297f7a6a65c5c97f83f860f642fc25
] 
[man/xmonad.hs: remove reference to deprecated 'dynamicLogDzen' function
Brent Yorgey <byorgey@cis.upenn.edu>**20091126053908
 Ignore-this: 7aeeac9791ffd3e6ac22bf158ea86536
] 
[A few tweaks to --verbose-version
Spencer Janssen <spencerjanssen@gmail.com>**20091208040729
 Ignore-this: cf3d6a904d23891829c10f4966974673
] 
[Main.hs +--verbose-version flag
gwern0@gmail.com**20091128144840
 Ignore-this: 61a081f33adb460ea459950a750dd93f
 This resolves http://code.google.com/p/xmonad/issues/detail?id=320 by adding a
 --verbose-version option yielding output like "xmonad 0.9 compiled by ghc 6.10 for linux/i386"
] 
[Generalize the type of (<+>). It can be used for keybindings too.
Adam Vogt <vogt.adam@gmail.com>**20091205233611
 Ignore-this: af15248be5e483d1a6e924f786fcc1c4
] 
[Swap the order that windows are mapped/unmapped.  Addresses #322
Spencer Janssen <spencerjanssen@gmail.com>**20091119025440
 Ignore-this: 22087204f1b84dae98a3cf2b7f116d3f
] 
[Add GPL warning to GenerateManpage
Spencer Janssen <spencerjanssen@gmail.com>**20091111000106
 Ignore-this: ea24691b8198976a4088a2708e0b4c94
] 
[Add a basic header to the html manpage output
Adam Vogt <vogt.adam@gmail.com>**20091028033042
 Ignore-this: 2641e0fb3179616075fa7549b57740f3
] 
[Use pandoc to convert a markdown manpage tranlation to html and man.
Adam Vogt <vogt.adam@gmail.com>**20091028030639
 Ignore-this: cdf7cdc8e44b21de8fc7725bde299792
] 
[Support for extensible state in contrib modules.
Daniel Schoepe <daniel.schoepe@gmail.com>**20091106115050
 Ignore-this: d04ee1989313ed5710c94f9d7fda3f2a
] 
[Set SIGPIPE to default in forked processes
Spencer Janssen <spencerjanssen@gmail.com>**20091106223743
 Ignore-this: f73943e4fe6c5f08967ddb82afad3eaa
] 
[TAG 0.9
Spencer Janssen <spencerjanssen@gmail.com>**20091026004641
 Ignore-this: 80347d432f3b606c8d722536d0d729aa
] 
Patch bundle hash:
dc4056302a12ff01c66de2d1e4229443ef6f8ea8
