summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-03-08 01:21:34 +0100
committerDon Stewart <dons@cse.unsw.edu.au>2007-03-08 01:21:34 +0100
commit21723d9668cfd287286ed830b52af74de6829e6f (patch)
tree2c57556e9713e28c44ba6a79be15f747f1480bec
parentbe28e4844a0fc1dd2325602550181a6d4824c223 (diff)
downloadmetatile-21723d9668cfd287286ed830b52af74de6829e6f.tar
metatile-21723d9668cfd287286ed830b52af74de6829e6f.zip
cleaner implementation of 'view'. Only hide the current list. And shortcut if we try to move to the same screen. No flicker
darcs-hash:20070308002134-9c5c1-72c6530acc071d641c55bf699c5e7aca32194e3b
-rw-r--r--Main.hs32
1 files changed, 17 insertions, 15 deletions
diff --git a/Main.hs b/Main.hs
index d386d0e..65bf851 100644
--- a/Main.hs
+++ b/Main.hs
@@ -189,24 +189,26 @@ kill = do
return ()
-- | Change the current workspace to workspce at offset 'n-1'.
--- Todo: refactor
view :: Int -> W ()
view n = do
- let m = n-1
- modifyWorkspaces $ \old@(_,wks) ->
- if m < S.length wks && m >= 0 then (m,wks) else old
-
+ let new = n-1
+ (old,wks) <- gets workspace
+ when (new /= old && new >= 0 && new < S.length wks) $ do
+ modifyWorkspaces $ \_ -> (new,wks)
+ hideWindows (wks `S.index` old)
+ showWindows (wks `S.index` new)
+ refresh
+
+-- | Hide a list of windows by moving them offscreen.
+hideWindows :: Windows -> W ()
+hideWindows ws = do
dpy <- gets display
sw <- liftM fromIntegral (gets screenWidth)
sh <- liftM fromIntegral (gets screenHeight)
- (i,wks) <- gets workspace
-
- -- clear the screen: remove all window stacks
- forM_ (concat $ F.toList wks) $ \win -> do
- io $ moveWindow dpy win (2*sw) (2*sh)
-
- -- expose just the visible stack
- forM_ (wks `S.index` i) $ \win -> do
- io $ moveWindow dpy win 0 0
+ forM_ ws $ \w -> io $ moveWindow dpy w (2*sw) (2*sh)
- refresh
+-- | Expose a list of windows, moving them on screen
+showWindows :: Windows -> W ()
+showWindows ws = do
+ dpy <- gets display
+ forM_ ws $ \w -> io $ moveWindow dpy w 0 0