From 215182bbb8f3cf8e92b56371e24e1bc45ab22f88 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 5 Mar 2025 12:53:40 -0700 Subject: Ability to move multiple windows at once. --- src/Rahm/Desktop/Keys.hs | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'src/Rahm/Desktop/Keys.hs') diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index b8647d6..61e483a 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -6,6 +6,7 @@ import Control.Monad unless, when, ) +import Control.Monad.Identity (Identity (Identity, runIdentity)) import Control.Monad.Trans.Maybe ( MaybeT (..), runMaybeT, @@ -142,7 +143,7 @@ import XMonad.Layout.Spacing ( Border (..), SpacingModifier (..), ) -import XMonad.Util.Run (safeSpawn, hPutStrLn, spawnPipe) +import XMonad.Util.Run (hPutStrLn, safeSpawn, spawnPipe) import XMonad.Util.WindowProperties import Prelude hiding ((!!)) @@ -1009,10 +1010,14 @@ bindings = do -- This allows me to make some pretty complex and powerful mappings with just -- the mouse by using button press sequences to mean different things. bind button1 $ do - justMod $ - doc + justMod + $ doc "Float and move a window" - myMouseMoveWindow + $ \win -> do + winSels <- getAndResetWindowSelection + if null winSels + then myMouseMoveWindow win + else myMouseMoveWindows winSels shiftMod $ doc @@ -1216,14 +1221,15 @@ bindings = do doc "Move all the windows to the workspace the pointer is on" $ noWindow $ do wins <- getAndResetWindowSelection - runMaybeT_ $ do - ws <- MaybeT pointerWorkspace - lift $ - let f = - appEndo - ( mconcat (map (Endo . W.shiftWin ws) wins) - ) - in windows f >> escape + D.mouseMoveWindowsAndThen + (mapM_ X.focus) + ( mconcat + [ D.ifReleased button1 D.sinkOnRelease, + D.ifReleased' button2 $ \w _ -> pinWindow w + ] + ) + wins + escape forM_ [(button7, ",.", "right"), (button6, ";.", "left")] $ \(b, mot, d) -> do @@ -1282,12 +1288,17 @@ bindings = do -- -- permuteMods = map (foldl' (.|.) 0) . filterM (const [True, False]) -myMouseMoveWindow = - D.mouseMoveWindowAndThen X.focus $ - mconcat - [ D.ifReleased button3 D.sinkOnRelease, - D.ifReleased' button2 $ \w _ -> X.killWindow w - ] +myMouseMoveWindow = myMouseMoveWindows . Identity + +myMouseMoveWindows :: (Foldable f) => f Window -> X () +myMouseMoveWindows = + D.mouseMoveWindowsAndThen + (mapM_ X.focus) + ( mconcat + [ D.ifReleased button3 D.sinkOnRelease, + D.ifReleased' button2 $ \w _ -> pinWindow w + ] + ) myMouseResizeAction = D.mouseResizeWindowAndThen X.focus $ -- cgit