blob: 2b35dbc2388825933ccc42a9de0828d9bede1810 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
module Internal.Layout where
import XMonad.Layout.Spiral
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Grid
import XMonad.Layout
import XMonad
import qualified XMonad.StackSet as W
myLayout =
spiral (6/7) |||
Center 0.7 |||
Tall 1 (3/100) (1/2) |||
ThreeCol 1 (3/100) (1/2) |||
Grid
data Center a =
Center {
proportion :: Float -- between 0 and 1
}
deriving (Show, Read)
instance LayoutClass Center a where
doLayout l (Rectangle x y w h) stack =
let wf = fromIntegral w
hf = fromIntegral h
x' = (wf - wf * proportion l) / 2
y' = (hf - hf * proportion l) / 2
w' = wf * proportion l
h' = hf * proportion l
middleRect = Rectangle (floor x') (floor y') (floor w') (floor h')
topRect = Rectangle 0 0 (floor wf) (floor y')
rightRect = Rectangle (floor (x' + w')) (floor y') (floor x') (floor h')
bottomRect = Rectangle 0 (floor $ y' + h') (floor wf) (floor y')
leftRect = Rectangle 0 (floor y') (floor x') (floor h')
nWin = length (W.integrate stack)
winsTop = nWin `div` 8
portion = fromIntegral $ nWin `div` 6
winRem = fromIntegral $ nWin `mod` 6
in
return $
(zip (W.integrate stack) (
(:) middleRect $
(divRect topRect (portion * 2))
++ (divRect rightRect portion)
++ (divRect bottomRect (portion * 2))
++ (divRect leftRect (portion + winRem))), Just l)
where
divRect (Rectangle x y w h) n =
if h > w
then
let h' = h `div` n
in flip map [0..(n - 1)] $ \mul ->
Rectangle x (y + fromIntegral (h' * mul)) w h'
else
let w' = w `div` n
in flip map [0..(n - 1)] $ \mul ->
Rectangle (x + fromIntegral (w' * mul)) y w' h
handleMessage (Center prop) m =
return $ fmap resize (fromMessage m)
where
resize Shrink = (Center (prop - 0.05))
resize Expand = (Center (prop + 0.05))
emptyLayout c root = return ([], Just c)
|