diff options
author | hughes <hughes@rpi.edu> | 2007-04-01 04:18:46 +0200 |
---|---|---|
committer | hughes <hughes@rpi.edu> | 2007-04-01 04:18:46 +0200 |
commit | 03e337c024dd7e6f6fd7dd40917ec4bf720d8eef (patch) | |
tree | 7b76ffe8c446e89c1bf0ddba1dc2e8bfa91428cf | |
parent | 446f5262e5b4960bad30952458c8199bb784df0b (diff) | |
download | xmonad-03e337c024dd7e6f6fd7dd40917ec4bf720d8eef.tar.gz xmonad-03e337c024dd7e6f6fd7dd40917ec4bf720d8eef.tar.xz xmonad-03e337c024dd7e6f6fd7dd40917ec4bf720d8eef.zip |
Merged things together with dons changes.
darcs-hash:20070401021846-3a569-083f7d441afc41bdeef843113c1de1d3a5e40ee3.gz
-rw-r--r-- | Config.hs | 7 | ||||
-rw-r--r-- | Operations.hs | 83 | ||||
-rw-r--r-- | XMonad.hs | 13 |
3 files changed, 61 insertions, 42 deletions
@@ -61,13 +61,6 @@ sizeDelta = 3%100 numlockMask :: KeySym numlockMask = lockMask --- What layout to start in, and what the default proportion for the --- left pane should be in the tiled layout. See LayoutDesc and --- friends in XMonad.hs for options. -startingLayoutDesc :: LayoutDesc -startingLayoutDesc = LayoutDesc { layoutType = Full - , tileFraction = 1%2 - } -- The keys list. keys :: M.Map (KeyMask, KeySym) (X ()) diff --git a/Operations.hs b/Operations.hs index f828a49..e404b7d 100644 --- a/Operations.hs +++ b/Operations.hs @@ -56,9 +56,9 @@ refresh = do ns = map (/ sum ds) ds -- normalized ratios for rhs. -- Normalize dispositions while we have the opportunity. - -- This is BAD. Rational numbers will SPACE LEAK each + -- This is bad. Rational numbers might space leak each -- time we make an adjustment. Floating point numbers are - -- better here. (Change it when somebody complains.) + -- better here. I am being paranoid. zipWithM_ (\ratio a -> disposeW a (dfix ratio)) ns s -- do some more math. @@ -78,40 +78,65 @@ refresh = do -- And raise this one, for good measure. whenJust (W.peek ws) (io . raiseWindow d) case l of - Full -> whenJust (W.peekStack n ws) $ \w -> do - move w sx sy sw sh - io $ raiseWindow d w - Tile -> case W.index n ws of - [] -> return () - [w] -> do move w sx sy sw sh; io $ raiseWindow d w - (w:s) -> do - let lw = floor $ fromIntegral sw * ratio - rw = sw - fromIntegral lw - rh = fromIntegral sh `div` fromIntegral (length s) - move w sx sy (fromIntegral lw) sh - zipWithM_ (\i a -> move a (sx + lw) (sy + i * rh) rw (fromIntegral rh)) [0..] s - whenJust (W.peek ws) (io . raiseWindow d) -- this is always Just + Full -> whenJust (W.peekStack n ws) fullWindow + _ -> case W.index n ws of + [] -> return () + [w] -> fullWindow w + s -> case l of + Horz -> runRects sc id (\r dp -> dp {horzFrac = r}) horzFrac (horzTileFrac fl) s + Vert -> runRects (flipRect sc) flipRect (\r dp -> dp {vertFrac = r}) vertFrac (vertTileFrac fl) s + _ -> error "Operations.refresh: the absurdly impossible happened. Please complain about this." whenJust (W.peek ws) setFocus -- | switchLayout. Switch to another layout scheme. Switches the current workspace. switchLayout :: X () -switchLayout = layout $ \fl -> fl { layoutType = case layoutType fl of - Full -> Tile - Tile -> Full } - --- | changeWidth. Change the width of the main window in tiling mode. -changeWidth :: Rational -> X () -changeWidth delta = do - layout $ \fl -> fl { tileFraction = min 1 $ max 0 $ tileFraction fl + delta } +switchLayout = layout $ \fl -> fl { layoutType = rot (layoutType fl) } + +-- | changeVert. Changes the vertical split, if it's visible. +changeVert :: Rational -> X () +changeVert delta = do + l <- gets (layoutType . currentDesc) + case l of + Vert -> layout $ \d -> d {vertTileFrac = min 1 $ max 0 $ vertTileFrac d + delta} + _ -> return () + +-- | changeHorz. Changes the horizontal split, if it's visible. +changeHorz :: Rational -> X () +changeHorz delta = do + l <- gets (layoutType . currentDesc) + case l of + Horz -> layout $ \d -> d {horzTileFrac = min 1 $ max 0 $ horzTileFrac d + delta} + _ -> return () + +-- | changeSize. Changes the size of the window, except in Full mode, with the +-- size remaining above the given mini-mum. +changeSize :: Rational -> Rational -> X () +changeSize delta mini = do + l <- gets (layoutType . currentDesc) + mw <- gets (W.peek . workspace) + whenJust mw $ \w -> do + case l of -- This is always Just. + Full -> return () + Horz -> disposeW w $ \d -> d {horzFrac = max mini $ horzFrac d + delta} + Vert -> disposeW w $ \d -> d {vertFrac = max mini $ vertFrac d + delta} -- hrm... + refresh -- | layout. Modify the current workspace's layout with a pure function and refresh. layout :: (LayoutDesc -> LayoutDesc) -> X () -layout f = do modify $ \s -> let fls = layoutDescs s - n = W.current . workspace $ s - fl = M.findWithDefault (defaultLayoutDesc s) n fls - in s { layoutDescs = M.insert n (f fl) fls } - refresh - +layout f = do + modify $ \s -> + let n = W.current . workspace $ s + fl = currentDesc s + in s { layoutDescs = M.insert n (f fl) (layoutDescs s) } + refresh + +-- | disposeW. Changes the disposition of a particular window. +disposeW :: Window -> (Disposition -> Disposition) -> X () +disposeW w f = modify $ \s -> let d = f (disposition w s) + in s {dispositions = M.insert w d (dispositions s)} + -- NO refresh. Do not put refresh here. + -- refresh calls this function. + -- | windows. Modify the current window list with a pure function, and refresh windows :: (WorkSpace -> WorkSpace) -> X () @@ -18,7 +18,7 @@ module XMonad ( X, WorkSpace, XState(..), Layout(..), LayoutDesc(..), Disposition(..), basicLayoutDesc, currentDesc, disposition, runX, io, withDisplay, isRoot, - spawn, trace, whenJust, swap + spawn, trace, whenJust, rot ) where import StackSet (StackSet) @@ -55,7 +55,7 @@ type WorkSpace = StackSet Window -- --------------------------------------------------------------------- --- Dispositions and Layout +-- Display Positions and Layout -- | Disposition. Short for 'Display Position,' it describes how much -- of the screen a window would like to occupy, when tiled with others. @@ -68,10 +68,11 @@ basicDisposition = Disposition (1%3) (1%3) -- | The different layout modes data Layout = Full | Horz | Vert --- | 'not' for Layout. -swap :: Layout -> Layout -swap Full = Tile -swap _ = Full +-- | 'rot' for Layout. +rot :: Layout -> Layout +rot Full = Horz +rot Horz = Vert +rot Vert = Full -- | A full description of a particular workspace's layout parameters. data LayoutDesc = LayoutDesc { layoutType :: !Layout, |