1
0
mirror of https://github.com/xmonad/xmonad-contrib.git synced 2025-07-29 11:11:52 -07:00

Remove code duplication in X.A.CopyWindow

This commit is contained in:
Daniel Schoepe
2009-07-02 10:49:33 +00:00
parent 7aafd381d3
commit 02671904e1

@@ -22,9 +22,10 @@ module XMonad.Actions.CopyWindow (
) where ) where
import Prelude hiding (filter) import Prelude hiding (filter)
import Control.Monad (filterM) import Control.Monad
import qualified Data.List as L import qualified Data.List as L
import XMonad hiding (modify, workspaces) import XMonad hiding (modify, workspaces)
import XMonad.Actions.WindowGo
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
-- $usage -- $usage
@@ -98,15 +99,10 @@ copyWindow w n = copy'
runOrCopy :: String -> Query Bool -> X () runOrCopy :: String -> Query Bool -> X ()
runOrCopy = copyMaybe . spawn runOrCopy = copyMaybe . spawn
-- | copyMaybe. Copies "XMonad.Actions.WindowGo" ('raiseMaybe') -- | Copy a window if it exists, run the first argument otherwise
-- TODO: Factor out and improve with regard to WindowGo.
copyMaybe :: X () -> Query Bool -> X () copyMaybe :: X () -> Query Bool -> X ()
copyMaybe f thatUserQuery = withWindowSet $ \s -> do copyMaybe f qry = ifWindow qry copyWin f
maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s) where copyWin = ask >>= \w -> doF (\ws -> copyWindow w (W.currentTag ws) ws)
case maybeResult of
[] -> f
(x:_) -> windows $ copyWindow x (W.currentTag s)
-- | Remove the focused window from this workspace. If it's present in no -- | 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 -- other workspace, then kill it instead. If we do kill it, we'll get a