blob: 3fae26dd2c0a59260de0f598d65fa60637c02796 (
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
74
75
|
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
module Internal.Layout where
import XMonad.Layout.Circle
import XMonad.Layout.Accordion
import Control.Applicative
import XMonad.Layout.Spacing
import Data.List
import XMonad.Layout.Spiral
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Grid
import XMonad.Layout
import XMonad.Layout.LayoutModifier
import XMonad
import XMonad.Core
import qualified XMonad.StackSet as W
myLayout =
ModifiedLayout (Zoomable False 0.05 0.05) $
spacingRaw True (Border 5 5 5 5) True (Border 5 5 5 5) True $
spiral (6/7) |||
Tall 1 (3/100) (1/2) |||
ThreeCol 1 (3/100) (1/2) |||
Full |||
Grid
data ResizeZoom = ShrinkZoom | ExpandZoom deriving (Typeable)
instance Message ResizeZoom where
data Zoomable a = Zoomable Bool Float Float -- True if zooming in on the focused window.
deriving (Show, Read)
data ToggleZoom = ToggleZoom
deriving (Typeable)
instance Message ToggleZoom where
instance (Eq a) => LayoutModifier Zoomable a where
redoLayout (Zoomable doit ws hs) (Rectangle x y w h) stack returned =
if doit
then
let focused = W.focus <$> stack
(zoomed, rest) = partition ((==focused) . Just . fst) returned
in case zoomed of
[] -> return (rest, Nothing)
((fwin, _):_) -> return $ ((fwin, Rectangle (x + wp) (y + hp) (w - fromIntegral (wp * 2)) (h - fromIntegral (hp * 2))) : rest, Nothing)
else return (returned, Nothing)
where
wp = floor $ (fromIntegral w) * ws
hp = floor $ (fromIntegral h) * hs
handleMessOrMaybeModifyIt self@(Zoomable showing sw sh) mess =
return $
(handleResize <$> fromMessage mess)
<|> ((Left . handleZoom) <$> fromMessage mess)
where
handleResize r =
if showing
then Left $ Zoomable showing (guard $ sw + d) (guard $ sh + d)
else Right $ case r of
ShrinkZoom -> SomeMessage Shrink
ExpandZoom -> SomeMessage Expand
where d = (case r of
ShrinkZoom -> -1
ExpandZoom -> 1) * 0.02
handleZoom ToggleZoom = Zoomable (not showing) sw sh
guard f | f > 1 = 1
| f < 0 = 0
| otherwise = f
|