diff options
| author | Josh Rahm <rahm@google.com> | 2025-03-05 12:53:40 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2025-03-05 12:53:40 -0700 |
| commit | 215182bbb8f3cf8e92b56371e24e1bc45ab22f88 (patch) | |
| tree | 766799f8bf8f74d9410e646eecf212fa26a17198 /src/Rahm/Desktop/Layout | |
| parent | 47a0e6e471074b3816b6542c9421abbe33e1d468 (diff) | |
| download | rde-215182bbb8f3cf8e92b56371e24e1bc45ab22f88.tar.gz rde-215182bbb8f3cf8e92b56371e24e1bc45ab22f88.tar.bz2 rde-215182bbb8f3cf8e92b56371e24e1bc45ab22f88.zip | |
Ability to move multiple windows at once.
Diffstat (limited to 'src/Rahm/Desktop/Layout')
| -rw-r--r-- | src/Rahm/Desktop/Layout/Hole.hs | 49 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Layout/PinWindow.hs | 1 |
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) |