XMonad.Layout.TallMastersCombo

xmonad-contrib-0.18.1: 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 | None
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 :: Type -> Type) (l2 :: Type -> Type) 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 :: Type -> Type) (r :: Type -> Type) 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 #

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 #

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 :: Type -> Type) (l2 :: Type -> Type) a #

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 # |
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)) # doLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> Stack Window -> X ([(Window, Rectangle)], Maybe (TMSCombineTwo l1 l2 Window)) # pureLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> Stack Window -> [(Window, Rectangle)] # emptyLayout :: TMSCombineTwo l1 l2 Window -> Rectangle -> X ([(Window, Rectangle)], Maybe (TMSCombineTwo l1 l2 Window)) # handleMessage :: TMSCombineTwo l1 l2 Window -> SomeMessage -> X (Maybe (TMSCombineTwo l1 l2 Window)) # pureMessage :: TMSCombineTwo l1 l2 Window -> SomeMessage -> Maybe (TMSCombineTwo l1 l2 Window) # description :: TMSCombineTwo l1 l2 Window -> String #
(Read a, Read (l1 a), Read (l2 a)) => Read (TMSCombineTwo l1 l2 a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (TMSCombineTwo l1 l2 a) # readList :: ReadS [TMSCombineTwo l1 l2 a] # readPrec :: ReadPrec (TMSCombineTwo l1 l2 a) # readListPrec :: ReadPrec [TMSCombineTwo l1 l2 a] #
(Show a, Show (l1 a), Show (l2 a)) => Show (TMSCombineTwo l1 l2 a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> TMSCombineTwo l1 l2 a -> ShowS # show :: TMSCombineTwo l1 l2 a -> String # showList :: [TMSCombineTwo l1 l2 a] -> ShowS #

newtype RowsOrColumns a #

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 # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods runLayout :: Workspace WorkspaceId (RowsOrColumns a) a -> Rectangle -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) # doLayout :: RowsOrColumns a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) # pureLayout :: RowsOrColumns a -> Rectangle -> Stack a -> [(a, Rectangle)] # emptyLayout :: RowsOrColumns a -> Rectangle -> X ([(a, Rectangle)], Maybe (RowsOrColumns a)) # handleMessage :: RowsOrColumns a -> SomeMessage -> X (Maybe (RowsOrColumns a)) # pureMessage :: RowsOrColumns a -> SomeMessage -> Maybe (RowsOrColumns a) # description :: RowsOrColumns a -> String #
Read (RowsOrColumns a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (RowsOrColumns a) # readList :: ReadS [RowsOrColumns a] # readPrec :: ReadPrec (RowsOrColumns a) # readListPrec :: ReadPrec [RowsOrColumns a] #
Show (RowsOrColumns a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> RowsOrColumns a -> ShowS # show :: RowsOrColumns a -> String # showList :: [RowsOrColumns a] -> ShowS #

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

This is same as the Choose combination operator.

# Messages

data SwitchOrientation #

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

data SwapSubMaster #

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

data FocusSubMaster #

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

Constructors

FocusSubMaster |

#### Instances

Instances details

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

data FocusedNextLayout #

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

Constructors

FocusedNextLayout |

#### Instances

Instances details

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

data ChangeFocus #

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

# Utilities

data ChooseWrapper (l :: Type -> Type) (r :: Type -> Type) a #

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 # |
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)) # doLayout :: ChooseWrapper l r a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (ChooseWrapper l r a)) # pureLayout :: ChooseWrapper l r a -> Rectangle -> Stack a -> [(a, Rectangle)] # emptyLayout :: ChooseWrapper l r a -> Rectangle -> X ([(a, Rectangle)], Maybe (ChooseWrapper l r a)) # handleMessage :: ChooseWrapper l r a -> SomeMessage -> X (Maybe (ChooseWrapper l r a)) # pureMessage :: ChooseWrapper l r a -> SomeMessage -> Maybe (ChooseWrapper l r a) # description :: ChooseWrapper l r a -> String #
(Read (l a), Read (r a)) => Read (ChooseWrapper l r a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods readsPrec :: Int -> ReadS (ChooseWrapper l r a) # readList :: ReadS [ChooseWrapper l r a] # readPrec :: ReadPrec (ChooseWrapper l r a) # readListPrec :: ReadPrec [ChooseWrapper l r a] #
(Show (l a), Show (r a)) => Show (ChooseWrapper l r a) # |
Instance details Defined in XMonad.Layout.TallMastersCombo Methods showsPrec :: Int -> ChooseWrapper l r a -> ShowS # show :: ChooseWrapper l r a -> String # showList :: [ChooseWrapper l r a] -> ShowS #

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

Swap a given window with the focused window.

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

Focus a given window.

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

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