|
17 | 17 | -- A layout which tiles the windows in columns. The windows can be moved and |
18 | 18 | -- resized in every directions. |
19 | 19 | -- |
20 | | --- The first window appears: |
| 20 | +-- The first window appears in a single column in the center of the screen. Its |
| 21 | +-- width is configurable (See 'coOneWindowWidth'). |
21 | 22 | -- |
22 | | --- * in the center on wide screens |
23 | | --- * fullscreen otherwise |
24 | | --- |
25 | | --- The second window appears on a second column. |
| 23 | +-- The second window appears in a second column. Starting with two columns, they |
| 24 | +-- fill up the screen. |
26 | 25 | -- |
27 | 26 | -- Subsequent windows appear on the bottom of the last columns. |
28 | 27 | module XMonad.Layout.Columns |
@@ -78,7 +77,7 @@ import qualified XMonad.StackSet as StackSet |
78 | 77 | -- $usage |
79 | 78 | -- Add 'Columns' to your @layoutHook@ with an initial empty state: |
80 | 79 | -- |
81 | | --- > myLayout = Full ||| Columns [] |
| 80 | +-- > myLayout = Full ||| Columns 1 [] |
82 | 81 | -- |
83 | 82 | -- Here is an example of keybindings: |
84 | 83 | -- |
@@ -156,37 +155,40 @@ type Column = [(Rational, Window)] |
156 | 155 | -- | The layout is a list of 'Column' with their relative horizontal dimensions. |
157 | 156 | type Columns = [(Rational, Column)] |
158 | 157 |
|
159 | | -newtype ColumnsLayout a = Columns Columns |
| 158 | +data ColumnsLayout a = Columns |
| 159 | + { -- | With of the first column when there is only one window. Usefull on wide |
| 160 | + -- screens. |
| 161 | + coOneWindowWidth :: Rational, |
| 162 | + -- | The current state |
| 163 | + coColumns :: Columns |
| 164 | + } |
160 | 165 | deriving (Show, Read) |
161 | 166 |
|
162 | 167 | instance LayoutClass ColumnsLayout Window where |
163 | 168 | description _ = layoutDescription |
164 | 169 |
|
165 | | - emptyLayout _ _ = pure ([], Just $ Columns []) |
166 | | - |
167 | | - doLayout (Columns columns) rectangle stack = |
168 | | - pure (rectangles, Just (Columns columns')) |
| 170 | + doLayout (Columns oneWindowWidth columns) rectangle stack = |
| 171 | + pure (rectangles, Just (Columns oneWindowWidth columns')) |
169 | 172 | where |
170 | 173 | hackedColumns = hackForTabs columns stack |
171 | 174 | columns' = updateWindowList hackedColumns stack |
172 | 175 | rectangles = toRectangles rectangle' columns' |
173 | | - -- If there is only one window and the screen is big, we reduce the |
174 | | - -- destination rectangle to put the window on the center of the screen. |
| 176 | + -- If there is only one window, we set the destination rectangle according |
| 177 | + -- to the width in the layout setting. |
175 | 178 | rectangle' |
176 | | - | rect_width rectangle > 2000 && (length . toList $ stack) == 1 = |
| 179 | + | (length . toList $ stack) == 1 = |
177 | 180 | scaleRationalRect rectangle singleColumnRR |
178 | 181 | | otherwise = rectangle |
179 | | - singleColumnWidth = 1 % 2 |
180 | | - singleColumnOffset = (1 - singleColumnWidth) / 2 |
181 | | - singleColumnRR = RationalRect singleColumnOffset 0 singleColumnWidth 1 |
| 182 | + singleColumnOffset = (1 - oneWindowWidth) / 2 |
| 183 | + singleColumnRR = RationalRect singleColumnOffset 0 oneWindowWidth 1 |
182 | 184 |
|
183 | | - handleMessage layout@(Columns columns) message = do |
| 185 | + handleMessage layout@(Columns oneWindowWidth columns) message = do |
184 | 186 | mbStack <- runMaybeT $ handleFocus' =<< getStack |
185 | 187 | changedFocus <- traverse updateStack' mbStack |
186 | 188 |
|
187 | 189 | movedOrResized <- |
188 | 190 | runMaybeT $ |
189 | | - Columns |
| 191 | + Columns oneWindowWidth |
190 | 192 | <$> (handleMoveOrResize' =<< peekFocus) |
191 | 193 |
|
192 | 194 | pure $ movedOrResized <|> changedFocus |
@@ -358,7 +360,7 @@ mapWindow :: (Window -> Window) -> Columns -> Columns |
358 | 360 | mapWindow = fmap . fmap . fmap . fmap |
359 | 361 |
|
360 | 362 | columnsToWindows :: Columns -> [Window] |
361 | | -columnsToWindows = foldMap ((:[]) . snd) . foldMap snd |
| 363 | +columnsToWindows = foldMap ((: []) . snd) . foldMap snd |
362 | 364 |
|
363 | 365 | swapWindowBetween :: |
364 | 366 | Window -> |
|
0 commit comments