aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Layout/Hole.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Layout/Hole.hs')
-rw-r--r--src/Rahm/Desktop/Layout/Hole.hs30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/Rahm/Desktop/Layout/Hole.hs b/src/Rahm/Desktop/Layout/Hole.hs
index 8bebb36..4b7eefc 100644
--- a/src/Rahm/Desktop/Layout/Hole.hs
+++ b/src/Rahm/Desktop/Layout/Hole.hs
@@ -8,6 +8,7 @@ module Rahm.Desktop.Layout.Hole
addHoleForWindow,
removeHoleForWindow,
resetHole,
+ addHole,
)
where
@@ -29,7 +30,7 @@ import XMonad
)
data Hole (l :: * -> *) (a :: *)
- = Hole (Map WorkspaceId [(W.TilePosition WorkspaceId, Window)]) (l a)
+ = Hole (Map WorkspaceId [(W.TilePosition WorkspaceId, Maybe Window)]) (l a)
deriving instance Show (l a) => Show (Hole l a)
@@ -46,7 +47,19 @@ addHoleForWindow p@(W.TilePosition wid _) win = ManageHole $ \(Hole m l) ->
Hole
( Map.alter
( \(fromMaybe [] -> existing) ->
- Just $ (p, win) : existing
+ Just $ (p, Just win) : existing
+ )
+ wid
+ m
+ )
+ l
+
+addHole :: W.TilePosition WorkspaceId -> ManageHole
+addHole p@(W.TilePosition wid _) = ManageHole $ \(Hole m l) ->
+ Hole
+ ( Map.alter
+ ( \(fromMaybe [] -> existing) ->
+ Just $ (p, Nothing) : existing
)
wid
m
@@ -57,7 +70,7 @@ removeHoleForWindow :: Window -> ManageHole
removeHoleForWindow win = ManageHole $ \(Hole m l) ->
Hole
( Map.mapMaybe
- (Just . filter ((/= win) . snd))
+ (Just . filter ((/= Just win) . snd))
m
)
l
@@ -85,6 +98,11 @@ instance (LayoutClass l a, a ~ Window) => LayoutClass (Hole l) a where
(rects, maybeNewLayout) <- runLayout (app holes $ W.Workspace t l a) rect
return (filter ((> 0) . fst) rects, fmap (Hole holes) maybeNewLayout)
where
+ app ::
+ (Ord i1) =>
+ Map i1 [(TilePosition i, Maybe Window)] ->
+ W.Workspace i1 l1 Window ->
+ W.Workspace i1 l1 Window
app mp (W.Workspace t l (Just s))
| Just positions <- sortIt <$> Map.lookup t mp =
let integrated = W.integrate s
@@ -96,11 +114,11 @@ instance (LayoutClass l a, a ~ Window) => LayoutClass (Hole l) a where
( \((idx, pos, fakeid), ret) w ->
case pos of
((TilePosition _ n, win) : tpos)
- | n == idx && win `notElem` integrated ->
+ | n == idx && maybe True (`notElem` integrated) win ->
((idx + 1, tpos, fakeid - 1), w : fakeid : ret)
_ -> ((idx + 1, pos, fakeid), w : ret)
)
- ((0, positions, -1), [])
+ ((0, positions, 10000000), [])
integrated
app _ w = w
@@ -108,7 +126,7 @@ instance (LayoutClass l a, a ~ Window) => LayoutClass (Hole l) a where
addr integrated ((idx, pos, fakeid), ret) =
case pos of
- ((TilePosition _ n, win) : _) | n == idx && win `notElem` integrated -> fakeid : ret
+ ((TilePosition _ n, win) : _) | n == idx && maybe True (`notElem` integrated) win -> fakeid : ret
_ -> ret
handleMessage h (fromMessage -> Just (ManageHole f)) =