aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions/Promote.hs
blob: fef21d5c496b1e912a47dd446af477d641970aa5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Actions.Promote
-- Copyright   :  (c) Miikka Koskinen 2007
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  xmonad@s001.ethrael.com
-- Stability   :  unstable
-- Portability :  unportable
--
-- Alternate promote function for xmonad.
--
-- Moves the focused window to the master pane. All other windows
-- retain their order. If focus is in the master, swap it with the
-- next window in the stack. Focus stays in the master.
--
-----------------------------------------------------------------------------

module XMonad.Actions.Promote (
                                 -- * Usage
                                 -- $usage
                                 promote
                                ) where

import XMonad
import XMonad.StackSet

-- $usage
--
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
--
-- >    import XMonad.Actions.Promote
--
-- then add a keybinding or substitute 'promote' in place of swapMaster:
--
-- >   , ((modm,               xK_Return), promote)
--
-- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings".

-- | Move the focused window to the master pane. All other windows
--   retain their order. If focus is in the master, swap it with the
--   next windo in the stack. Focus stays in the master.
promote :: X ()
promote = windows $ modify' $
          \c -> case c of
                Stack _ [] []     -> c
                Stack t [] (x:rs) -> Stack x [] (t:rs)
                Stack t ls rs     -> Stack t [] (reverse ls ++ rs)