aboutsummaryrefslogtreecommitdiffstats
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
commitdeb5e4962590060bb798f79f58cd820aa632fb1f (patch)
tree7cc5a80ee012da44d0277a82283047fcaec9b73b /StackSet.hs
parent3ce2c398857f570f8ae3732f3d3486550d999ab9 (diff)
downloadxmonad-deb5e4962590060bb798f79f58cd820aa632fb1f.tar.gz
xmonad-deb5e4962590060bb798f79f58cd820aa632fb1f.tar.xz
xmonad-deb5e4962590060bb798f79f58cd820aa632fb1f.zip
Add greedyView, make it the default action for mod-wer
darcs-hash:20070815025504-a5988-00ff316a056c48cc07c5e90925702d2ac09ae666.gz
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