Add StackSet.focusMaster (mod-m) to move focus to master

This commit is contained in:
Don Stewart
2007-09-27 21:39:37 +00:00
parent 5e943d512c
commit f1aa00f96f
2 changed files with 16 additions and 7 deletions

View File

@@ -143,6 +143,8 @@ keys = M.fromList $
, ((modMask, xK_Tab ), windows W.focusDown) -- %! Move focus to the next window , ((modMask, xK_Tab ), windows W.focusDown) -- %! Move focus to the next window
, ((modMask, xK_j ), windows W.focusDown) -- %! Move focus to the next window , ((modMask, xK_j ), windows W.focusDown) -- %! Move focus to the next window
, ((modMask, xK_k ), windows W.focusUp ) -- %! Move focus to the previous window , ((modMask, xK_k ), windows W.focusUp ) -- %! Move focus to the previous window
, ((modMask, xK_m ), windows W.focusMaster ) -- %! Move focus to the master window
-- modifying the window order -- modifying the window order
, ((modMask, xK_Return), windows W.swapMaster) -- %! Swap the focused window and the master window , ((modMask, xK_Return), windows W.swapMaster) -- %! Swap the focused window and the master window

View File

@@ -23,14 +23,14 @@ module StackSet (
-- * Operations on the current stack -- * Operations on the current stack
-- $stackOperations -- $stackOperations
peek, index, integrate, integrate', differentiate, peek, index, integrate, integrate', differentiate,
focusUp, focusDown, focusUp, focusDown, focusMaster,
focusWindow, tagMember, member, findIndex, focusWindow, tagMember, member, findIndex,
-- * Modifying the stackset -- * Modifying the stackset
-- $modifyStackset -- $modifyStackset
insertUp, delete, delete', filter, insertUp, delete, delete', filter,
-- * Setting the master window -- * Setting the master window
-- $settingMW -- $settingMW
swapMaster, swapUp, swapDown, modify, modify', float, sink, -- needed by users swapUp, swapDown, swapMaster, modify, modify', float, sink, -- needed by users
-- * Composite operations -- * Composite operations
-- $composite -- $composite
shift, shiftWin shift, shiftWin
@@ -463,11 +463,11 @@ delete w = sink w . delete' w
-- | Only temporarily remove the window from the stack, thereby not destroying special -- | Only temporarily remove the window from the stack, thereby not destroying special
-- information saved in the Stackset -- information saved in the Stackset
delete' :: (Ord a, Eq s) => a -> StackSet i a s sd -> StackSet i a s sd delete' :: (Ord a, Eq s) => a -> StackSet i a s sd -> StackSet i a s sd
delete' w s = s { current = removeFromScreen (current s) delete' w s = s { current = removeFromScreen (current s)
, visible = map removeFromScreen (visible s) , visible = map removeFromScreen (visible s)
, hidden = map removeFromWorkspace (hidden s) } , hidden = map removeFromWorkspace (hidden s) }
where removeFromWorkspace ws = ws { stack = stack ws >>= filter (/=w) } where removeFromWorkspace ws = ws { stack = stack ws >>= filter (/=w) }
removeFromScreen scr = scr { workspace = removeFromWorkspace (workspace scr) } removeFromScreen scr = scr { workspace = removeFromWorkspace (workspace scr) }
------------------------------------------------------------------------ ------------------------------------------------------------------------
@@ -489,9 +489,16 @@ sink w s = s { floating = M.delete w (floating s) }
swapMaster :: StackSet i a s sd -> StackSet i a s sd swapMaster :: StackSet i a s sd -> StackSet i a s sd
swapMaster = modify' $ \c -> case c of swapMaster = modify' $ \c -> case c of
Stack _ [] _ -> c -- already master. Stack _ [] _ -> c -- already master.
Stack t ls rs -> Stack t [] (ys ++ x : rs) where (x:ys) = reverse ls Stack t ls rs -> Stack t [] (xs ++ x : rs) where (x:xs) = reverse ls
-- natural! keep focus, move current to the top, move top to current. -- natural! keep focus, move current to the top, move top to current.
-- | /O(s)/. Set focus to the master window.
focusMaster :: StackSet i a s sd -> StackSet i a s sd
focusMaster = modify' $ \c -> case c of
Stack _ [] _ -> c
Stack t ls rs -> Stack x [] (xs ++ t : rs) where (x:xs) = reverse ls
-- --
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- $composite -- $composite