summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-10-01 18:39:59 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-10-01 18:39:59 +0200
commit596be5ddf371dae9d5e07da35b3773cda5423eef (patch)
tree270552da5d086363267efb54e9b4c58873774d43
parenta46949eab008a218fb94a8deae83cc74f6154638 (diff)
downloadmetatile-596be5ddf371dae9d5e07da35b3773cda5423eef.tar
metatile-596be5ddf371dae9d5e07da35b3773cda5423eef.zip
Add StackSet.allWindows
darcs-hash:20071001163959-a5988-243d115545b70eafcaaedd9440ddf525ea15aa32
-rw-r--r--StackSet.hs8
-rw-r--r--tests/Properties.hs3
2 files changed, 9 insertions, 2 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 1dd4579..f77edd1 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -21,7 +21,7 @@ module StackSet (
-- * Xinerama operations
-- $xinerama
lookupWorkspace,
- screens, workspaces,
+ screens, workspaces, allWindows,
-- * Operations on the current stack
-- $stackOperations
peek, index, integrate, integrate', differentiate,
@@ -43,7 +43,7 @@ module StackSet (
import Prelude hiding (filter)
import Data.Maybe (listToMaybe,fromJust)
-import qualified Data.List as L (deleteBy,find,splitAt,filter)
+import qualified Data.List as L (deleteBy,find,splitAt,filter,nub)
import Data.List ( (\\) )
import qualified Data.Map as M (Map,insert,delete,empty)
@@ -400,6 +400,10 @@ screens s = current s : visible s
workspaces :: StackSet i l a s sd -> [Workspace i l a]
workspaces s = workspace (current s) : map workspace (visible s) ++ hidden s
+-- | Get a list of all windows in the StackSet in no particular order
+allWindows :: Eq a => StackSet i l a s sd -> [a]
+allWindows = L.nub . concatMap (integrate' . stack) . workspaces
+
-- | 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
diff --git a/tests/Properties.hs b/tests/Properties.hs
index 2bc5443..9818f30 100644
--- a/tests/Properties.hs
+++ b/tests/Properties.hs
@@ -363,6 +363,8 @@ prop_findIndex (x :: T) =
, i <- focus t : up t ++ down t
]
+prop_allWindowsMember w (x :: T) = (w `elem` allWindows x) ==> member w x
+
-- ---------------------------------------------------------------------
-- 'insert'
@@ -687,6 +689,7 @@ main = do
,("focusWindow works" , mytest prop_focusWindow_works)
,("findIndex" , mytest prop_findIndex)
+ ,("allWindows/member" , mytest prop_allWindowsMember)
,("insert: invariant" , mytest prop_insertUp_I)
,("insert/new" , mytest prop_insert_empty)