mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
add SwapFocus.
This commit is contained in:
parent
40f8d611f2
commit
2202665f70
30
SwapFocus.hs
Normal file
30
SwapFocus.hs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
module XMonadContrib.SwapFocus ( swapFocus ) where
|
||||||
|
|
||||||
|
-- swaps focus with last-focussed window.
|
||||||
|
|
||||||
|
-- To use:
|
||||||
|
-- import XMonadContrib.SwapFocus ( swapFocus )
|
||||||
|
|
||||||
|
-- , ((modMask .|. shiftMask, xK_Tab), swapFocus)
|
||||||
|
|
||||||
|
import Control.Monad.State
|
||||||
|
|
||||||
|
import Operations ( refresh )
|
||||||
|
import XMonad ( X, WindowSet, workspace )
|
||||||
|
import StackSet ( StackSet, peekStack, popFocus, pushFocus, current )
|
||||||
|
|
||||||
|
sf :: (Integral i, Integral j, Ord a) => StackSet i j a -> Maybe (StackSet i j a)
|
||||||
|
sf w = do let i = current w
|
||||||
|
f1 <- peekStack i w
|
||||||
|
f2 <- peekStack i $ popFocus i f1 w
|
||||||
|
return $ pushFocus i f2 $ pushFocus i f1 w
|
||||||
|
|
||||||
|
swapFocus :: X ()
|
||||||
|
swapFocus = smartwindows sf
|
||||||
|
|
||||||
|
-- | smartwindows. Modify the current window list with a pure function, and only refresh if necesary
|
||||||
|
smartwindows :: (WindowSet -> Maybe WindowSet) -> X ()
|
||||||
|
smartwindows f = do w <- gets workspace
|
||||||
|
case (f w) of Just f' -> do modify $ \s -> s { workspace = f' }
|
||||||
|
refresh
|
||||||
|
Nothing -> return ()
|
Loading…
x
Reference in New Issue
Block a user