From dd74e94f111873c722ff3cbafa1932d310768a08 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Sun, 20 May 2007 09:00:53 +0200 Subject: HEADS UP: Rewrite StackSet as a Zipper In order to give a better account of how focus and master interact, and how each operation affects focus, we reimplement the StackSet type as a two level nested 'Zipper'. To quote Oleg: A Zipper is essentially an `updateable' and yet pure functional cursor into a data structure. Zipper is also a delimited continuation reified as a data structure. That is, we use the Zipper as a cursor which encodes the window which is in focus. Thus our data structure tracks focus correctly by construction! We then get simple, obvious semantics for e.g. insert, in terms of how it affects focus/master. Our transient-messes-with-focus bug evaporates. 'swap' becomes trivial. By moving focus directly into the stackset, we can toss some QC properties about focus handling: it is simply impossible now for focus to go wrong. As a benefit, we get a dozen new QC properties for free, governing how master and focus operate. The encoding of focus in the data type also simplifies the focus handling in Operations: several operations affecting focus are now simply wrappers over StackSet. For the full story, please read the StackSet module, and the QC properties. Finally, we save ~40 lines with the simplified logic in Operations.hs For more info, see the blog post on the implementation, http://cgi.cse.unsw.edu.au/~dons/blog/2007/05/17#xmonad_part1b_zipper darcs-hash:20070520070053-9c5c1-241f7ee7793f5db2b9e33d375965cdc21b26cbd7 --- Config.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Config.hs') diff --git a/Config.hs b/Config.hs index e6a9101..8fa538c 100644 --- a/Config.hs +++ b/Config.hs @@ -86,13 +86,13 @@ module Config where -- -- Useful imports -- +import XMonad +import Operations import Data.Ratio -import Data.Bits +import Data.Bits ((.|.)) import qualified Data.Map as M import System.Exit import Graphics.X11.Xlib -import XMonad -import Operations -- The number of workspaces (virtual screens) workspaces :: Int @@ -156,9 +156,9 @@ keys = M.fromList $ -- 'nudge': resize viewed windows to the correct size. , ((modMask, xK_n ), refresh) - , ((modMask, xK_Tab ), raise GT) - , ((modMask, xK_j ), raise GT) - , ((modMask, xK_k ), raise LT) + , ((modMask, xK_Tab ), focusLeft) + , ((modMask, xK_j ), focusLeft) + , ((modMask, xK_k ), focusRight) , ((modMask, xK_h ), sendMessage Shrink) , ((modMask, xK_l ), sendMessage Expand) @@ -172,18 +172,18 @@ keys = M.fromList $ , ((modMask .|. shiftMask .|. controlMask, xK_q ), io restart) -- Cycle the current tiling order - , ((modMask, xK_Return), promote) + , ((modMask, xK_Return), swap) ] ++ -- Keybindings to get to each workspace: [((m .|. modMask, k), f i) | (i, k) <- zip [0 .. fromIntegral workspaces - 1] [xK_1 ..] - , (f, m) <- [(view, 0), (tag, shiftMask)]] + , (f, m) <- [(view, 0), (shift, shiftMask)]] -- Keybindings to each screen : -- mod-wer (underneath 123) switches to physical/Xinerama screens 1 2 and 3 ++ [((m .|. modMask, key), screenWorkspace sc >>= f) | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] - , (f, m) <- [(view, 0), (tag, shiftMask)]] + , (f, m) <- [(view, 0), (shift, shiftMask)]] -- cgit v1.2.3