aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Rahm/Desktop/Keys.hs44
-rw-r--r--src/Rahm/Desktop/StackSet.hs11
-rw-r--r--src/Rahm/Desktop/SwapMaster.hs4
3 files changed, 35 insertions, 24 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs
index 8cb2b76..50b7104 100644
--- a/src/Rahm/Desktop/Keys.hs
+++ b/src/Rahm/Desktop/Keys.hs
@@ -404,22 +404,34 @@ keymap = runKeys $ do
sendMessage rotateLayout
bind xK_s $ do
- justMod $ do
- locations <- fromMaybe [] <$> runMaybeT readNextLocationSet
- let locationWindows = mapMaybe locationWindow locations
-
- withBorderWidth 4 locationWindows $
- withBorderColor "#00ffff" locationWindows $ do
- runMaybeT_ $ do
- workspace <- readNextWorkspace
- mapM_ (lift . moveLocationToWorkspaceFn workspace) locations
-
- lift $ setAlternateWindows locationWindows
- forM_ locations $ \loc ->
- case locationWindow loc of
- Nothing -> return ()
- Just win -> do
- lift $ setAlternateWorkspace win (locationWorkspace loc)
+ forM_ [(False, justMod), (True, shiftMod)] $ \(doSwap, f) ->
+ f $
+ doc (if doSwap
+ then "Swap a windowset with another windowset."
+ else "Shift a windowset to a workspace") $ do
+ locations <- fromMaybe [] <$> runMaybeT readNextLocationSet
+ let locationWindows = mapMaybe locationWindow locations
+
+ withBorderWidth 4 locationWindows $
+ withBorderColor "#00ffff" locationWindows $ do
+ runMaybeT_ $ do
+ if doSwap
+ then do
+ otherWindows <-
+ lift $ mapMaybe locationWindow . fromMaybe [] <$>
+ runMaybeT readNextLocationSet
+ lift $ windows $
+ W.swapWindows (zip locationWindows otherWindows)
+ else do
+ workspace <- readNextWorkspace
+ mapM_ (lift . moveLocationToWorkspaceFn workspace) locations
+
+ lift $ setAlternateWindows locationWindows
+ forM_ locations $ \loc ->
+ case locationWindow loc of
+ Nothing -> return ()
+ Just win -> do
+ lift $ setAlternateWorkspace win (locationWorkspace loc)
altMod $ spawnX "sudo -A systemctl suspend && xsecurelock"
diff --git a/src/Rahm/Desktop/StackSet.hs b/src/Rahm/Desktop/StackSet.hs
index 652dafe..6b90fab 100644
--- a/src/Rahm/Desktop/StackSet.hs
+++ b/src/Rahm/Desktop/StackSet.hs
@@ -46,12 +46,11 @@ mapWindows fn (StackSet cur vis hid float) =
mapWindowsWorkspace (Workspace t l stack) =
Workspace t l (fmap (fmap fn) stack)
-swapWindows :: (Ord a) => a -> a -> StackSet i l a s d -> StackSet i l a s d
-swapWindows wa wb = mapWindows $ \w ->
- case w of
- _ | w == wa -> wb
- _ | w == wb -> wa
- _ -> w
+swapWindows :: (Ord a) => [(a, a)] -> StackSet i l a s d -> StackSet i l a s d
+swapWindows toSwap = mapWindows $ \w ->
+ fromMaybe w (Map.lookup w toSwapM)
+ where
+ toSwapM = Map.fromList (toSwap ++ map (\(a, b) -> (b, a)) toSwap)
masterWindow :: StackSet i l a s sd -> Maybe a
masterWindow = head . integrate' . stack . workspace . current
diff --git a/src/Rahm/Desktop/SwapMaster.hs b/src/Rahm/Desktop/SwapMaster.hs
index 96417ed..cd47c01 100644
--- a/src/Rahm/Desktop/SwapMaster.hs
+++ b/src/Rahm/Desktop/SwapMaster.hs
@@ -32,8 +32,8 @@ swapMaster = void $ runMaybeT $ do
if focused == master
then do
lw <- MaybeT $ lastWindow <$> XS.get
- lift $ windows (W.swapWindows focused lw)
- else lift $ windows (W.swapWindows focused master)
+ lift $ windows (W.swapWindows [(focused, lw)])
+ else lift $ windows (W.swapWindows [(focused, master)])
lift $ do
XS.put (LastWindow $ Just master)