From 21723d9668cfd287286ed830b52af74de6829e6f Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Thu, 8 Mar 2007 01:21:34 +0100 Subject: 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 --- Main.hs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'Main.hs') 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 -- cgit v1.2.3