aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Layout')
-rw-r--r--src/Rahm/Desktop/Layout/Hole.hs49
-rw-r--r--src/Rahm/Desktop/Layout/PinWindow.hs1
2 files changed, 24 insertions, 26 deletions
diff --git a/src/Rahm/Desktop/Layout/Hole.hs b/src/Rahm/Desktop/Layout/Hole.hs
index 4b7eefc..95cf4f4 100644
--- a/src/Rahm/Desktop/Layout/Hole.hs
+++ b/src/Rahm/Desktop/Layout/Hole.hs
@@ -32,9 +32,9 @@ import XMonad
data Hole (l :: * -> *) (a :: *)
= Hole (Map WorkspaceId [(W.TilePosition WorkspaceId, Maybe Window)]) (l a)
-deriving instance Show (l a) => Show (Hole l a)
+deriving instance (Show (l a)) => Show (Hole l a)
-deriving instance Read (l a) => Read (Hole l a)
+deriving instance (Read (l a)) => Read (Hole l a)
hole :: l a -> Hole l a
hole = Hole mempty
@@ -77,16 +77,16 @@ removeHoleForWindow win = ManageHole $ \(Hole m l) ->
dbgHole :: Hole l a -> X ()
dbgHole (Hole mp _) = do
- logs Trace "Hole:"
+ logs Debug "Hole:"
forM_ (Map.toList mp) $ \(wid, poses) ->
- logs Trace " wid[%s] - [%s]" wid $
+ logs Debug " wid[%s] - [%s]" wid $
intercalate
","
( map (\(TilePosition _ n, w) -> show w ++ "@" ++ show n) poses
)
--- toggleHole :: ManageHole
--- toggleHole = ManageHole $ \(Hole e l) -> Hole (not e) l
+maxWindow :: Window
+maxWindow = maxBound
data ManageHole where
ManageHole :: (forall l a. Hole l a -> Hole l a) -> ManageHole
@@ -105,29 +105,26 @@ instance (LayoutClass l a, a ~ Window) => LayoutClass (Hole l) a where
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
- in W.Workspace t l $
- W.differentiateWithFocus (W.focus s) $
- reverse $
- addr integrated $
- foldl
- ( \((idx, pos, fakeid), ret) w ->
- case pos of
- ((TilePosition _ n, win) : tpos)
- | n == idx && maybe True (`notElem` integrated) win ->
- ((idx + 1, tpos, fakeid - 1), w : fakeid : ret)
- _ -> ((idx + 1, pos, fakeid), w : ret)
- )
- ((0, positions, 10000000), [])
- integrated
+ let positionToFakes =
+ zipWith
+ (\(TilePosition _ n, _) fid -> (n, fid))
+ positions
+ [maxWindow, maxWindow - 1 ..]
+ integrated = W.integrate s
+ in W.Workspace t l $
+ W.differentiateWithFocus (W.focus s) $
+ inflateWithFakes 0 integrated positionToFakes
app _ w = w
- sortIt = sortOn (\(TilePosition _ p, _) -> p)
+ inflateWithFakes :: Int -> [Window] -> [(Int, Window)] -> [Window]
+ inflateWithFakes idx wins ((n,fake):fakes) | idx == n =
+ fake : inflateWithFakes (idx + 1) wins fakes
+ inflateWithFakes idx (w:wins) fakes =
+ w : inflateWithFakes (idx + 1) wins fakes
+ inflateWithFakes _ wins [] = wins
+ inflateWithFakes _ [] fakes = map snd fakes
- addr integrated ((idx, pos, fakeid), ret) =
- case pos of
- ((TilePosition _ n, win) : _) | n == idx && maybe True (`notElem` integrated) win -> fakeid : ret
- _ -> ret
+ sortIt = sortOn (\(TilePosition _ p, _) -> p)
handleMessage h (fromMessage -> Just (ManageHole f)) =
return $ Just $ f h
diff --git a/src/Rahm/Desktop/Layout/PinWindow.hs b/src/Rahm/Desktop/Layout/PinWindow.hs
index 6ccf35a..36dbf27 100644
--- a/src/Rahm/Desktop/Layout/PinWindow.hs
+++ b/src/Rahm/Desktop/Layout/PinWindow.hs
@@ -87,6 +87,7 @@ instance (LayoutClass l a, sid ~ ScreenId, a ~ Window) => LayoutClass (PinWindow
pinWindow :: Window -> X ()
pinWindow win = runMaybeT_ $ do
lift $ logs Debug "Pinning window %d" win
+ lift $ float win
ws@(W.StackSet cur vis _ flt) <- gets windowset
t <- hoist (W.findTag win ws)