summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-08-15 04:55:04 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-08-15 04:55:04 +0200
commit215b5fabba19875f9032d7ce7bf33c0291149b47 (patch)
tree7cc5a80ee012da44d0277a82283047fcaec9b73b /StackSet.hs
parent649dfb57a92e579859fb2d85f85ba961333fdd17 (diff)
downloadmetatile-215b5fabba19875f9032d7ce7bf33c0291149b47.tar
metatile-215b5fabba19875f9032d7ce7bf33c0291149b47.zip
Add greedyView, make it the default action for mod-wer
darcs-hash:20070815025504-a5988-00ff316a056c48cc07c5e90925702d2ac09ae666
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 40d1c0b..5f69448 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -15,7 +15,7 @@ module StackSet (
StackSet(..), Workspace(..), Screen(..), StackOrNot, Stack(..), RationalRect(..),
-- * Construction
-- $construction
- new, view,
+ new, view, greedyView,
-- * Xinerama operations
-- $xinerama
lookupWorkspace,
@@ -244,6 +244,25 @@ view i s
-- 'Catch'ing this might be hard. Relies on monotonically increasing
-- workspace tags defined in 'new'
+-- |
+-- Set focus to the given workspace. If that workspace does not exist
+-- in the stackset, the original workspace is returned. If that workspace is
+-- 'hidden', then display that workspace on the current screen, and move the
+-- current workspace to 'hidden'. If that workspace is 'visible' on another
+-- screen, the workspaces of the current screen and the other screen are
+-- swapped.
+
+greedyView :: (Eq a, Eq s, Eq i) => i -> StackSet i a s sd -> StackSet i a s sd
+greedyView w ws
+ | any wTag (hidden ws) = view w ws
+ | (Just s) <- L.find (wTag . workspace) (visible ws)
+ = ws { current = (current ws) { workspace = workspace s }
+ , visible = s { workspace = workspace (current ws) }
+ : L.filter (not . wTag . workspace) (visible ws) }
+ | otherwise = ws
+ where
+ wTag = (w == ) . tag
+
-- ---------------------------------------------------------------------
-- $xinerama