aboutsummaryrefslogtreecommitdiffstats
path: root/GreedyView.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-05-22 00:00:48 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-05-22 00:00:48 +0200
commit5cbe8e9ae3bac65ef607942350c70af6a4226272 (patch)
tree0f037509191c1a9f4636cf95237afed2b482408e /GreedyView.hs
parent8867b7568e4ee2e4b960b089a74c3dd4344491a4 (diff)
downloadXMonadContrib-5cbe8e9ae3bac65ef607942350c70af6a4226272.tar.gz
XMonadContrib-5cbe8e9ae3bac65ef607942350c70af6a4226272.tar.xz
XMonadContrib-5cbe8e9ae3bac65ef607942350c70af6a4226272.zip
Add GreedyView
darcs-hash:20070521220048-a5988-59d83b4c6eaae48574264b4320db9a07d3df3208.gz
Diffstat (limited to 'GreedyView.hs')
-rw-r--r--GreedyView.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/GreedyView.hs b/GreedyView.hs
new file mode 100644
index 0000000..275f44c
--- /dev/null
+++ b/GreedyView.hs
@@ -0,0 +1,25 @@
+-- greedyView is an alternative to standard workspace switching. When a
+-- workspace is already visible on another screen, greedyView swaps the
+-- contents of that other screen with the current screen.
+
+module XMonadContrib.GreedyView (greedyView) where
+
+import StackSet as W
+import XMonad
+import Operations
+import Data.List (find)
+
+greedyView :: WorkspaceId -> X ()
+greedyView = windows . greedyView'
+
+greedyView' :: WorkspaceId -> WindowSet -> WindowSet
+greedyView' w ws
+ | any wTag (hidden ws) = W.view w ws
+ | (Just s) <- find (wTag . workspace) (visible ws) = ws { current = setScreen s (screen $ current ws)
+ , visible = setScreen (current ws) (screen s)
+ : filter (not . wTag . workspace) (visible ws)
+ }
+ | otherwise = ws
+ where
+ setScreen s i = s { screen = i }
+ wTag = (w == ) . tag