From 128621bef7d80ea9bab9195eecc22bed8510c95f Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Sat, 23 Feb 2008 14:07:02 +0100 Subject: add sendMessageWithNoRefresh and have broadcastMessage use it This patch: - moves broadcastMessage and restart from Core to Operations (to avoid circular imports); - in Operations introduces sendMessageWithNoRefresh and move updateLayout outside windows. - broadcastMessage now uses sendMessageWithNoRefresh to obey to this rules: 1. if handleMessage returns Nothing no action is taken; 2. if handleMessage returns a Just ml *only* the layout field of the workspace record will be updated. darcs-hash:20080223130702-32816-60d71cd8ac32cff1d4039947142332023274a725 --- XMonad/Core.hs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'XMonad/Core.hs') diff --git a/XMonad/Core.hs b/XMonad/Core.hs index 1603034..ecbca29 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -25,8 +25,8 @@ module XMonad.Core ( Layout(..), readsLayout, Typeable, Message, SomeMessage(..), fromMessage, LayoutMessages(..), runX, catchX, userCode, io, catchIO, doubleFork, - withDisplay, withWindowSet, isRoot, runOnWorkspaces, broadcastMessage, - getAtom, spawn, restart, getXMonadDir, recompile, trace, whenJust, whenX, + withDisplay, withWindowSet, isRoot, runOnWorkspaces, + getAtom, spawn, getXMonadDir, recompile, trace, whenJust, whenX, atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, ManageHook, Query(..), runQuery ) where @@ -353,13 +353,6 @@ doubleFork m = io $ do getProcessStatus True False pid return () --- | Send a message to all visible layouts, without necessarily refreshing. --- This is how we implement the hooks, such as UnDoLayout. -broadcastMessage :: Message a => a -> X () -broadcastMessage a = runOnWorkspaces $ \w -> do - ml' <- handleMessage (layout w) (SomeMessage a) `catchX` return Nothing - return $ w { layout = maybe (layout w) id ml' } - -- | This is basically a map function, running a function in the X monad on -- each workspace with the output of that function being the modified workspace. runOnWorkspaces :: (WindowSpace -> X WindowSpace) -> X () @@ -370,18 +363,6 @@ runOnWorkspaces job = do $ current ws : visible ws modify $ \s -> s { windowset = ws { current = c, visible = v, hidden = h } } --- | @restart name resume@. Attempt to restart xmonad by executing the program --- @name@. If @resume@ is 'True', restart with the current window state. --- When executing another window manager, @resume@ should be 'False'. --- -restart :: String -> Bool -> X () -restart prog resume = do - broadcastMessage ReleaseResources - io . flush =<< asks display - args <- if resume then gets (("--resume":) . return . showWs . windowset) else return [] - catchIO (executeFile prog True args Nothing) - where showWs = show . mapLayout show - -- | Return the path to @~\/.xmonad@. getXMonadDir :: MonadIO m => m String getXMonadDir = io $ getAppUserDataDirectory "xmonad" -- cgit v1.2.3