diff options
author | Daniel Schoepe <daniel.schoepe@gmail.com> | 2009-07-02 12:49:33 +0200 |
---|---|---|
committer | Daniel Schoepe <daniel.schoepe@gmail.com> | 2009-07-02 12:49:33 +0200 |
commit | 7d0ac5c6129d3ec0765597bd9494347dda377888 (patch) | |
tree | 475b20330dfb26d928dee7b8fd3bea17619aec8e | |
parent | 734348d4e011048c98975fbdedc810349b985871 (diff) | |
download | XMonadContrib-7d0ac5c6129d3ec0765597bd9494347dda377888.tar.gz XMonadContrib-7d0ac5c6129d3ec0765597bd9494347dda377888.tar.xz XMonadContrib-7d0ac5c6129d3ec0765597bd9494347dda377888.zip |
Remove code duplication in X.A.CopyWindow
Ignore-this: cbbbe68690dbb4b814cd48fa32d4720
darcs-hash:20090702104933-7f603-8f51c30a91e31fa6b7b6cd7ef7197abb1999e487.gz
-rw-r--r-- | XMonad/Actions/CopyWindow.hs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/XMonad/Actions/CopyWindow.hs b/XMonad/Actions/CopyWindow.hs index d49b5dc..1f425bf 100644 --- a/XMonad/Actions/CopyWindow.hs +++ b/XMonad/Actions/CopyWindow.hs @@ -22,9 +22,10 @@ module XMonad.Actions.CopyWindow ( ) where import Prelude hiding (filter) -import Control.Monad (filterM) +import Control.Monad import qualified Data.List as L import XMonad hiding (modify, workspaces) +import XMonad.Actions.WindowGo import qualified XMonad.StackSet as W -- $usage @@ -98,15 +99,10 @@ copyWindow w n = copy' runOrCopy :: String -> Query Bool -> X () runOrCopy = copyMaybe . spawn --- | copyMaybe. Copies "XMonad.Actions.WindowGo" ('raiseMaybe') --- TODO: Factor out and improve with regard to WindowGo. +-- | Copy a window if it exists, run the first argument otherwise copyMaybe :: X () -> Query Bool -> X () -copyMaybe f thatUserQuery = withWindowSet $ \s -> do - maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s) - case maybeResult of - [] -> f - (x:_) -> windows $ copyWindow x (W.currentTag s) - +copyMaybe f qry = ifWindow qry copyWin f + where copyWin = ask >>= \w -> doF (\ws -> copyWindow w (W.currentTag ws) ws) -- | Remove the focused window from this workspace. If it's present in no -- other workspace, then kill it instead. If we do kill it, we'll get a |