xmonad-contrib-0.18.0: Community-maintained extensions for xmonad

Copyright | (c) 2019 Ningji Wei
License | BSD3-style (see LICENSE)
Maintainer | Ningji Wei <tidues@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Layout.TallMastersCombo

Contents

- Usage
- Messages
- Utilities

Description

A layout combinator that support Shrink, Expand, and IncMasterN just as the `Tall` layout, and also support operations of two master windows: a main master, which is the original master window; a sub master, the first window of the second pane. This combinator can be nested, and has a good support for using XMonad.Layout.Tabbed as a sublayout.

Synopsis

- tmsCombineTwoDefault :: (LayoutClass l1 Window, LayoutClass l2 Window) => l1 Window -> l2 Window -> TMSCombineTwo l1 l2 Window
- tmsCombineTwo :: (LayoutClass l1 Window, LayoutClass l2 Window) => Bool -> Int -> Rational -> Rational -> l1 Window -> l2 Window -> TMSCombineTwo l1 l2 Window
- data TMSCombineTwo l1 l2 a = TMSCombineTwo {
  - focusLst :: [a]
  - ws1 :: [a]
  - ws2 :: [a]
  - rowMod :: Bool
  - nMaster :: !Int
  - rationInc :: !Rational
  - tallComboRatio :: !Rational
  - layoutFst :: l1 a
  - layoutSnd :: l2 a
  }
- newtype RowsOrColumns a = RowsOrColumns {
  - rowMode :: Bool
  }
- (|||) :: l a -> r a -> ChooseWrapper l r a
- data SwitchOrientation = SwitchOrientation
- data SwapSubMaster = SwapSubMaster
- data FocusSubMaster = FocusSubMaster
- data FocusedNextLayout = FocusedNextLayout
- data ChangeFocus
  - = NextFocus
  - | PrevFocus
- data ChooseWrapper l r a = ChooseWrapper LR (l a) (r a) (Choose l r a)
- swapWindow :: Eq a => a -> Stack a -> Stack a
- focusWindow :: Eq a => a -> Stack a -> Stack a
- handleMessages :: LayoutClass l a => l a -> [SomeMessage] -> X (Maybe (l a))

# Usage

You can use this module with the following in your `xmonad.hs`:

    import XMonad.Layout.TallMastersCombo

and make sure the Choose layout operator (|||) is hidden by adding the followings:

    import XMonad hiding ((|||))
    import XMonad.Layout hiding ((|||))

then, add something like

    tmsCombineTwoDefault (Tall 0 (3/100) 0) simpleTabbed

This will make the `Tall` layout as the master pane, and `simpleTabbed` layout as the second pane. You can shrink, expand, and increase more windows to the master pane just like using the `Tall` layout.

To swap and/or focus the sub master window (the first window in the second pane), you can add the following key bindings

         , ((modm .|. shiftMask, m),         sendMessage $ FocusSubMaster)
         , ((modm .|. shiftMask, xK_Return), sendMessage $ SwapSubMaster)

In each pane, you can use multiple layouts with the `(|||)` combinator provided by this module, and switch between them with the `FocusedNextLayout` message. Below is one example

    layout1 = Simplest ||| Tabbed
    layout2 = Full ||| Tabbed ||| (RowsOrColumns True)
    myLayout = tmsCombineTwoDefault layout1 layout2

then add the following key binding,

         , ((modm, w), sendMessage $ FocusedNextLayout)

Now, pressing this key will toggle the multiple layouts in the currently focused pane.

You can mirror this layout with the default `Mirror` key binding. But to have a more natural behaviors, you can use the `SwitchOrientation` message:

         , ((modm, xK_space), sendMessage $ SwitchOrientation)

This will not mirror the tabbed decoration, and will keep sub-layouts that made by TallMastersCombo and RowsOrColumns display in natural orientations.

To merge layouts more flexibly, you can use `tmsCombineTwo` instead.

    tmsCombineTwo False 1 (3/100) (1/3) Simplest simpleTabbed

This creates a vertical merged layout with 1 window in the master pane, and the master pane shrinks and expands with a step of (3/100), and occupies (1/3) of the screen.

Each sub-layout have a focused window. To rotate between the focused windows across all the sub-layouts, using the following messages:

         , ((modm .|. mod1, j), sendMessage $ NextFocus)
         , ((modm .|. mod1, k), sendMessage $ PrevFocus)

this let you jump to the focused window in the next/previous sub-layout.

Finally, this combinator can be nested. Here is one example,

    subLayout  = tmsCombineTwo False 1 (3/100) (1/2) Simplest simpleTabbed
    layout1    = simpleTabbed ||| subLayout
    layout2    = subLayout ||| simpleTabbed ||| (RowsOrColumns True)
    baseLayout = tmsCombineTwoDefault layout1 layout2

    mylayouts = smartBorders $
                avoidStruts $
                mkToggle (FULL ?? EOT) $
                baseLayout

this is a realization of the cool idea from

https://www.reddit.com/r/xmonad/comments/3vkrc3/does_this_layout_exist_if_not_can_anyone_suggest/

and is more flexible.

tmsCombineTwoDefault :: (LayoutClass l1 Window, LayoutClass l2 Window) => l1 Window -> l2 Window -> TMSCombineTwo l1 l2 Window Source #

Combine two layouts l1 l2 with default behaviors.

tmsCombineTwo :: (LayoutClass l1 Window, LayoutClass l2 Window) => Bool -> Int -> Rational -> Rational -> l1 Window -> l2 Window -> TMSCombineTwo l1 l2 Window Source #

A more flexible way of merging two layouts. User can specify if merge them vertical or horizontal, the number of windows in the first pane (master pane), the shink and expand increment, and the proportion occupied by the master pane.

data TMSCombineTwo l1 l2 a Source #

Constructors

TMSCombineTwo |

Fields

- focusLst :: [a]
- ws1 :: [a]
- ws2 :: [a]
- rowMod :: Bool

  merge two layouts in a column or a row

- nMaster :: !Int

  number of windows in the master pane

- rationInc :: !Rational

  percent of screen to increment by when resizing panes

- tallComboRatio :: !Rational

  default proportion of screen occupied by master pane

- layoutFst :: l1 a

  layout for the master pane

- layoutSnd :: l2 a

  layout for the second pane

#### Instances

Instances details

(GetFocused l1 Window, GetFocused l2 Window) => LayoutClass (TMSCombineTwo l1 l2) Window Source # |

Instance details

Defined in XMonad.Layout.TallMastersCombo

Methods

runLayout :: Workspace WorkspaceId (TMSCombineTwo l1 l2 Window) Window -> Rectangle -> X ([(Window, Rectangle)], Maybe (TMSCombineTwo l1 l2 Window)) Source #

doLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> Stack Window -> X ([(Window, Rectangle)], Maybe (TMSCombineTwo l1 l2 Window)) Source #

pureLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> Stack Window -> [(Window, Rectangle)] Source #

emptyLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> X ([(Window, Rectangle)], Maybe (TMSCombineTwo l1 l2 Window)) Source #

handleMessage :: TMSCombineTwo l1 l2 Window -> SomeMessage -> X (Maybe (TMSCombineTwo l1 l2 Window)) Source #

pureMessage :: TMSCombineTwo l1 l2 Window -> SomeMessage -> Maybe (TMSCombineTwo l1 l2 Window) Source #

description :: TMSCombineTwo l1 l2 Window -> String Source #

(Read a, Read (l1 a), Read (l2 a)) => Read (TMSCombineTwo l1 l2 a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (TMSCombineTwo l1 l2 a) Source # readList :: ReadS [TMSCombineTwo l1 l2 a] Source # readPrec :: ReadPrec (TMSCombineTwo l1 l2 a) Source # readListPrec :: ReadPrec [TMSCombineTwo l1 l2 a] Source #
(Show a, Show (l1 a), Show (l2 a)) => Show (TMSCombineTwo l1 l2 a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> TMSCombineTwo l1 l2 a -> ShowS Source # show :: TMSCombineTwo l1 l2 a -> String Source # showList :: [TMSCombineTwo l1 l2 a] -> ShowS Source #

newtype RowsOrColumns a Source #

A simple layout that arranges windows in a row or a column with equal sizes. It can switch between row mode and column mode by listening to the message `SwitchOrientation`.

Constructors

RowsOrColumns |

Fields

- rowMode :: Bool

  arrange windows in rows or columns

#### Instances

Instances details

LayoutClass RowsOrColumns a Source # |

Instance details

Defined in XMonad.Layout.TallMastersCombo

Methods

runLayout :: Workspace WorkspaceId (RowsOrColumns a) a -> Rectangle -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) Source #

doLayout :: RowsOrColumns a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) Source #

pureLayout :: RowsOrColumns a -> Rectangle -> Stack a -> [(a, Rectangle)] Source #

emptyLayout :: RowsOrColumns a -> Rectangle -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) Source #

handleMessage :: RowsOrColumns a -> SomeMessage -> X (Maybe (RowsOrColumns a)) Source #

pureMessage :: RowsOrColumns a -> SomeMessage -> Maybe (RowsOrColumns a) Source #

description :: RowsOrColumns a -> String Source #

Read (RowsOrColumns a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (RowsOrColumns a) Source # readList :: ReadS [RowsOrColumns a] Source # readPrec :: ReadPrec (RowsOrColumns a) Source # readListPrec :: ReadPrec [RowsOrColumns a] Source #
Show (RowsOrColumns a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> RowsOrColumns a -> ShowS Source # show :: RowsOrColumns a -> String Source # showList :: [RowsOrColumns a] -> ShowS Source #

(|||) :: l a -> r a -> ChooseWrapper l r a Source #

This is same as the Choose combination operator.

# Messages

data SwitchOrientation Source #

A message that switches the orientation of TallMasterCombo layout and the RowsOrColumns layout. This is similar to the `Mirror` message, but `Mirror` cannot apply to hidden layouts, and when `Mirror` applies to the `Tabbed` decoration, it will also mirror the tabs, which may lead to unintended visualizations. The `SwitchOrientation` message refreshes layouts according to the orientation of the parent layout, and will not affect the `Tabbed` decoration.

Constructors

SwitchOrientation |

#### Instances

Instances details

Read SwitchOrientation Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS SwitchOrientation Source # readList :: ReadS [SwitchOrientation] Source # readPrec :: ReadPrec SwitchOrientation Source # readListPrec :: ReadPrec [SwitchOrientation] Source #
Show SwitchOrientation Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> SwitchOrientation -> ShowS Source # show :: SwitchOrientation -> String Source # showList :: [SwitchOrientation] -> ShowS Source #
Message SwitchOrientation Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo

data SwapSubMaster Source #

This message swaps the current focused window with the sub master window (first window in the second pane).

Constructors

SwapSubMaster |

#### Instances

Instances details

Read SwapSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS SwapSubMaster Source # readList :: ReadS [SwapSubMaster] Source # readPrec :: ReadPrec SwapSubMaster Source # readListPrec :: ReadPrec [SwapSubMaster] Source #
Show SwapSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> SwapSubMaster -> ShowS Source # show :: SwapSubMaster -> String Source # showList :: [SwapSubMaster] -> ShowS Source #
Message SwapSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo

data FocusSubMaster Source #

This message changes the focus to the sub master window (first window in the second pane).

Constructors

FocusSubMaster |

#### Instances

Instances details

Read FocusSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS FocusSubMaster Source # readList :: ReadS [FocusSubMaster] Source # readPrec :: ReadPrec FocusSubMaster Source # readListPrec :: ReadPrec [FocusSubMaster] Source #
Show FocusSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> FocusSubMaster -> ShowS Source # show :: FocusSubMaster -> String Source # showList :: [FocusSubMaster] -> ShowS Source #
Message FocusSubMaster Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo

data FocusedNextLayout Source #

This message triggers the `NextLayout` message in the pane that contains the focused window.

Constructors

FocusedNextLayout |

#### Instances

Instances details

Read FocusedNextLayout Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS FocusedNextLayout Source # readList :: ReadS [FocusedNextLayout] Source # readPrec :: ReadPrec FocusedNextLayout Source # readListPrec :: ReadPrec [FocusedNextLayout] Source #
Show FocusedNextLayout Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> FocusedNextLayout -> ShowS Source # show :: FocusedNextLayout -> String Source # showList :: [FocusedNextLayout] -> ShowS Source #
Message FocusedNextLayout Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo

data ChangeFocus Source #

This is a message for changing to the previous or next focused window across all the sub-layouts.

Constructors

NextFocus |
PrevFocus |

#### Instances

Instances details

Read ChangeFocus Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS ChangeFocus Source # readList :: ReadS [ChangeFocus] Source # readPrec :: ReadPrec ChangeFocus Source # readListPrec :: ReadPrec [ChangeFocus] Source #
Show ChangeFocus Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> ChangeFocus -> ShowS Source # show :: ChangeFocus -> String Source # showList :: [ChangeFocus] -> ShowS Source #
Message ChangeFocus Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo

# Utilities

data ChooseWrapper l r a Source #

Constructors

ChooseWrapper LR (l a) (r a) (Choose l r a) |

#### Instances

Instances details

(GetFocused l a, GetFocused r a) => LayoutClass (ChooseWrapper l r) a Source # |

Instance details

Defined in XMonad.Layout.TallMastersCombo

Methods

runLayout :: Workspace WorkspaceId (ChooseWrapper l r a) a -> Rectangle -> X ([(a, Rectangle)], Maybe (ChooseWrapper l r a)) Source #

doLayout :: ChooseWrapper l r a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (ChooseWrapper l r a)) Source #

pureLayout :: ChooseWrapper l r a -> Rectangle -> Stack a -> [(a, Rectangle)] Source #

emptyLayout :: ChooseWrapper l r a -> Rectangle -> X ([(a, Rectangle)], Maybe (ChooseWrapper l r a)) Source #

handleMessage :: ChooseWrapper l r a -> SomeMessage -> X (Maybe (ChooseWrapper l r a)) Source #

pureMessage :: ChooseWrapper l r a -> SomeMessage -> Maybe (ChooseWrapper l r a) Source #

description :: ChooseWrapper l r a -> String Source #

(Read (l a), Read (r a)) => Read (ChooseWrapper l r a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (ChooseWrapper l r a) Source # readList :: ReadS [ChooseWrapper l r a] Source # readPrec :: ReadPrec (ChooseWrapper l r a) Source # readListPrec :: ReadPrec [ChooseWrapper l r a] Source #
(Show (l a), Show (r a)) => Show (ChooseWrapper l r a) Source # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> ChooseWrapper l r a -> ShowS Source # show :: ChooseWrapper l r a -> String Source # showList :: [ChooseWrapper l r a] -> ShowS Source #

swapWindow :: Eq a => a -> Stack a -> Stack a Source #

Swap a given window with the focused window.

focusWindow :: Eq a => a -> Stack a -> Stack a Source #

Focus a given window.

handleMessages :: LayoutClass l a => l a -> [SomeMessage] -> X (Maybe (l a)) Source #

Handle a list of messages one by one, then return the last refreshed layout.