diff options
author | Devin Mullins <me@twifkak.com> | 2008-05-12 00:42:58 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2008-05-12 00:42:58 +0200 |
commit | d089d9eeb64c119ebc4d0338371a2a6cb9fb5281 (patch) | |
tree | 40c34f1d5fe221b8c5a179df7684a6e4ce8992e1 | |
parent | 4e43fa7d4d090293de00abdc5ae10cf4a529ea36 (diff) | |
download | xmonad-d089d9eeb64c119ebc4d0338371a2a6cb9fb5281.tar.gz xmonad-d089d9eeb64c119ebc4d0338371a2a6cb9fb5281.tar.xz xmonad-d089d9eeb64c119ebc4d0338371a2a6cb9fb5281.zip |
add currentTag convenience function
darcs-hash:20080511224258-78224-93d0cc4af977965e2e27e96efb67a6f362ebbbc1.gz
-rw-r--r-- | XMonad/StackSet.hs | 13 | ||||
-rw-r--r-- | tests/Properties.hs | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/XMonad/StackSet.hs b/XMonad/StackSet.hs index 20cafe2..4fed2eb 100644 --- a/XMonad/StackSet.hs +++ b/XMonad/StackSet.hs @@ -31,7 +31,7 @@ module XMonad.StackSet ( -- * Xinerama operations -- $xinerama lookupWorkspace, - screens, workspaces, allWindows, + screens, workspaces, allWindows, currentTag, -- * Operations on the current stack -- $stackOperations peek, index, integrate, integrate', differentiate, @@ -210,7 +210,7 @@ new _ _ _ = abort "non-positive argument to StackSet.new" view :: (Eq s, Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd view i s - | i == tag (workspace (current s)) = s -- current + | i == currentTag s = s -- current | Just x <- L.find ((i==).tag.workspace) (visible s) -- if it is visible, it is just raised @@ -380,6 +380,10 @@ workspaces s = workspace (current s) : map workspace (visible s) ++ hidden s allWindows :: Eq a => StackSet i l a s sd -> [a] allWindows = L.nub . concatMap (integrate' . stack) . workspaces +-- | Get the tag of the currently focused workspace. +currentTag :: StackSet i l a s sd -> i +currentTag = tag . workspace . current + -- | Is the given tag present in the StackSet? tagMember :: Eq i => i -> StackSet i l a s sd -> Bool tagMember t = elem t . map tag . workspaces @@ -520,7 +524,7 @@ 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 = tag (workspace (current s)) + curtag = currentTag 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 @@ -536,6 +540,5 @@ shiftWin n w s | from == Nothing = s -- not found where from = findTag w s go = on n (insertUp w) . on (fromJust from) (delete' w) $ s - curtag = tag (workspace (current s)) - on i f = view curtag . f . view i + on i f = view (currentTag s) . f . view i diff --git a/tests/Properties.hs b/tests/Properties.hs index 010a05e..9b0e83c 100644 --- a/tests/Properties.hs +++ b/tests/Properties.hs @@ -378,6 +378,9 @@ prop_findIndex (x :: T) = prop_allWindowsMember w (x :: T) = (w `elem` allWindows x) ==> member w x +prop_currentTag (x :: T) = + currentTag x == tag (workspace (current x)) + -- --------------------------------------------------------------------- -- 'insert' @@ -895,6 +898,7 @@ main = do ,("findTag" , mytest prop_findIndex) ,("allWindows/member" , mytest prop_allWindowsMember) + ,("currentTag" , mytest prop_currentTag) ,("insert: invariant" , mytest prop_insertUp_I) ,("insert/new" , mytest prop_insert_empty) |