diff options
author | Spencer Janssen <spencerjanssen@gmail.com> | 2009-02-18 00:53:43 +0100 |
---|---|---|
committer | Spencer Janssen <spencerjanssen@gmail.com> | 2009-02-18 00:53:43 +0100 |
commit | de73299f92714cc3607ed8126b0636fc8b5304c5 (patch) | |
tree | 43cd9b47eed6df07bff04daf0345fa05f321653b | |
parent | 427775af8470c4a71bcc6f1373988b47965bda43 (diff) | |
download | metatile-de73299f92714cc3607ed8126b0636fc8b5304c5.tar metatile-de73299f92714cc3607ed8126b0636fc8b5304c5.zip |
Express shift in terms of shiftWin
Ignore-this: 8f213bca20065a39e7c16027f7b398cf
darcs-hash:20090217235343-25a6b-5d87036961fc0346dddfc54b73e43424256a55e7
-rw-r--r-- | XMonad/StackSet.hs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/XMonad/StackSet.hs b/XMonad/StackSet.hs index eb5feb7..6cf43a5 100644 --- a/XMonad/StackSet.hs +++ b/XMonad/StackSet.hs @@ -52,7 +52,7 @@ module XMonad.StackSet ( ) where import Prelude hiding (filter) -import Data.Maybe (listToMaybe,fromJust,isJust) +import Data.Maybe (listToMaybe,isJust) import qualified Data.List as L (deleteBy,find,splitAt,filter,nub) import Data.List ( (\\) ) import qualified Data.Map as M (Map,insert,delete,empty) @@ -538,10 +538,7 @@ focusMaster = modify' $ \c -> case c of -- element on the current stack, the original stackSet is returned. -- shift :: (Ord a, Eq s, Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd -shift n s | n `tagMember` s && n /= curtag = maybe s go (peek s) - | otherwise = s - where go w = view curtag . insertUp w . view n . delete' w $ s - curtag = currentTag s +shift n s = maybe s (\w -> shiftWin n w s) (peek s) -- | /O(n)/. shiftWin. Searches for the specified window 'w' on all workspaces -- of the stackSet and moves it to stack 'n', leaving it as the focused @@ -549,13 +546,12 @@ shift n s | n `tagMember` s && n /= curtag = maybe s go (peek s) -- focused element on that workspace. -- The actual focused workspace doesn't change. If the window is not -- found in the stackSet, the original stackSet is returned. --- TODO how does this duplicate 'shift's behaviour? shiftWin :: (Ord a, Eq a, Eq s, Eq i) => i -> a -> StackSet i l a s sd -> StackSet i l a s sd -shiftWin n w s | from == Nothing = s -- not found - | n `tagMember` s && (Just n) /= from = go - | otherwise = s - where from = findTag w s - - go = on n (insertUp w) . on (fromJust from) (delete' w) $ s - on i f = view (currentTag s) . f . view i - +shiftWin n w s = case findTag w s of + Just from | n `tagMember` s && n /= from -> go from s + _ -> s + where go from = onWorkspace n (insertUp w) . onWorkspace from (delete' w) + +onWorkspace :: (Eq i, Eq s) => i -> (StackSet i l a s sd -> StackSet i l a s sd) + -> (StackSet i l a s sd -> StackSet i l a s sd) +onWorkspace n f s = view (currentTag s) . f . view n $ s |