aboutsummaryrefslogtreecommitdiffstats
path: root/CopyWindow.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-08-23 17:59:12 +0200
committerDavid Roundy <droundy@darcs.net>2007-08-23 17:59:12 +0200
commita052f1e28ac2bd0e3751501889693f66521f5749 (patch)
tree9906aed4fa9b9f0223de8f0b1655d05131e52263 /CopyWindow.hs
parentf1a09d027388be35ac30ac4f89194b25d19be87c (diff)
downloadXMonadContrib-a052f1e28ac2bd0e3751501889693f66521f5749.tar.gz
XMonadContrib-a052f1e28ac2bd0e3751501889693f66521f5749.tar.xz
XMonadContrib-a052f1e28ac2bd0e3751501889693f66521f5749.zip
clean up CopyWindow.
darcs-hash:20070823155912-72aca-4f0b28c68135a1f62d2aeacb074222996859a087.gz
Diffstat (limited to 'CopyWindow.hs')
-rw-r--r--CopyWindow.hs35
1 files changed, 7 insertions, 28 deletions
diff --git a/CopyWindow.hs b/CopyWindow.hs
index 947b488..86bbe1d 100644
--- a/CopyWindow.hs
+++ b/CopyWindow.hs
@@ -57,34 +57,12 @@ import StackSet
-- | copy. Copy a window to a new workspace.
copy :: WorkspaceId -> X ()
copy n = windows (copy' n)
-
-copy' :: (Ord a, Eq s, Eq i) => i -> StackSet i a s sd -> StackSet i a s sd
-copy' n s = if n `tagMember` s && n /= tag (workspace (current s))
- then maybe s go (peek s)
- else s
- where go w = view (tag (workspace (current s))) $ insertUp' w $ view n s
-
-
--- |
--- /O(n)/. (Complexity due to check if element is in current stack.) Insert
--- a new element into the stack, above the currently focused element.
---
--- The new element is given focus, and is set as the master window.
--- The previously focused element is moved down. The previously
--- 'master' element is forgotten. (Thus, 'insert' will cause a retiling).
---
--- If the element is already in the current stack, it is shifted to the
--- focus position, as if it had been removed and then added.
---
--- Semantics in Huet's paper is that insert doesn't move the cursor.
--- However, we choose to insert above, and move the focus.
-
-insertUp' :: Eq a => a -> StackSet i a s sd -> StackSet i a s sd
-insertUp' a s = modify (Just $ Stack a [] [])
- (\(Stack t l r) -> Just $ Stack a (L.delete a l) (L.delete a (t:r))) s
-
-delete' :: Ord a => a -> StackSet i a s sd -> StackSet i a s sd
-delete' w = sink w . modify Nothing (filter (/= w))
+ where copy' n s = if n `tagMember` s && n /= tag (workspace (current s))
+ then maybe s (go s) (peek s)
+ else s
+ go s w = view (tag (workspace (current s))) $ insertUp' w $ view n s
+ insertUp' a s = modify (Just $ Stack a [] [])
+ (\(Stack t l r) -> Just $ Stack a (L.delete a l) (L.delete a (t:r))) s
-- | Remove the focussed 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
@@ -98,3 +76,4 @@ kill1 = do ss <- gets windowset
whenJust (peek ss) $ \w -> if member w $ delete' w ss
then windows $ delete' w
else kill
+ where delete' w = sink w . modify Nothing (filter (/= w))