From ca4bf413568335bd4adadce25a1122a31fdcab9e Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Mon, 11 Jun 2007 21:18:09 +0200 Subject: Hide windows that are not supposed to be visible darcs-hash:20070611191809-a5988-f8a49e4c6c6ec628a85c2204302a43d63547b042 --- Operations.hs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'Operations.hs') diff --git a/Operations.hs b/Operations.hs index d24f7b8..e39fdac 100644 --- a/Operations.hs +++ b/Operations.hs @@ -21,7 +21,7 @@ import qualified StackSet as W import {-# SOURCE #-} Config (borderWidth,logHook,numlockMask) import Data.Maybe -import Data.List (genericIndex, intersectBy) +import Data.List (genericIndex, intersectBy, nub, (\\)) import Data.Bits ((.|.), (.&.), complement) import Data.Ratio import qualified Data.Map as M @@ -84,9 +84,7 @@ swapMaster = windows W.swapMaster -- | shift. Move a window to a new workspace, 0 indexed. shift :: WorkspaceId -> X () -shift n = withFocused hide >> windows (W.shift n) --- TODO: get rid of the above hide. 'windows' should handle all hiding and --- revealing of windows +shift n = windows (W.shift n) -- | view. Change the current workspace to workspace at offset n (0 indexed). view :: WorkspaceId -> X () @@ -131,12 +129,13 @@ windows :: (WindowSet -> WindowSet) -> X () windows f = do sendMessage ModifyWindows XState { windowset = old, layouts = fls, xineScreens = xinesc, statusGaps = gaps } <- get - let ws = f old + let oldvisible = concatMap (W.integrate . W.stack . W.workspace) $ W.current old : W.visible old + ws = f old modify (\s -> s { windowset = ws }) d <- asks display -- for each workspace, layout the currently visible workspaces - forM_ (W.current ws : W.visible ws) $ \w -> do + visible <- fmap concat $ forM (W.current ws : W.visible ws) $ \w -> do let n = W.tag (W.workspace w) this = W.view n ws Just l = fmap fst $ M.lookup n fls @@ -185,17 +184,16 @@ windows f = do -- pass to the last tiled window that had focus. -- urgh : not our delete policy, but close. + -- return the visible windows for this workspace: + return (map fst rs ++ flt) + setTopFocus logHook -- io performGC -- really helps, but seems to trigger GC bugs? - -- We now go to some effort to compute the minimal set of windows to hide. - -- The minimal set being only those windows which weren't previously hidden, - -- which is the intersection of previously visible windows with those now hidden - mapM_ hide . concatMap (W.integrate . W.stack) $ - intersectBy (\w x -> W.tag w == W.tag x) - (map W.workspace $ W.current old : W.visible old) - (W.hidden ws) + -- hide every window that was potentially visible before, but is not + -- given a position by a layout now. + mapM_ hide (nub oldvisible \\ visible) clearEnterEvents -- cgit v1.2.3