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:
@@ -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
|
||||||
|
Reference in New Issue
Block a user