diff options
| author | Josh Rahm <rahm@google.com> | 2023-12-04 18:32:13 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2023-12-04 18:32:13 -0700 |
| commit | 3c6488cc3d976fe47dda946b1a5c09828a86f4ec (patch) | |
| tree | ceaf4d924aadca942a63a9048cdb99788569216e /src/Rahm/Desktop/Common.hs | |
| parent | 1132a1b6468feb46dd5033d77855d9b4f2ae9d46 (diff) | |
| download | rde-3c6488cc3d976fe47dda946b1a5c09828a86f4ec.tar.gz rde-3c6488cc3d976fe47dda946b1a5c09828a86f4ec.tar.bz2 rde-3c6488cc3d976fe47dda946b1a5c09828a86f4ec.zip | |
Added a couple of draggable bindings.
These new bindings allow the user to click on a window and "drag" it to
a different window. This will swap the two windows once the drag button
is released. The other binding is similar, but for whole workspaces.
Diffstat (limited to 'src/Rahm/Desktop/Common.hs')
| -rw-r--r-- | src/Rahm/Desktop/Common.hs | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs index 4787598..005eeca 100644 --- a/src/Rahm/Desktop/Common.hs +++ b/src/Rahm/Desktop/Common.hs @@ -15,6 +15,7 @@ module Rahm.Desktop.Common getCurrentWorkspace, getCurrentLocation, runMaybeT_, + setBorderColor, Location (..), ) where @@ -133,29 +134,34 @@ myFinallyE m closer = catchE (m <* closer) (\e -> closer >> throwE e) -- Temporarily set the border color of the given windows. withBorderColorE :: String -> [Window] -> ExceptT e X a -> ExceptT e X a withBorderColorE color wins fn = do - d <- lift $ asks display + cleanup <- lift (setBorderColor color wins) + myFinallyE fn (lift cleanup) + +-- Set the border color for the given windows. This function returns another +-- function that should be used to clean up the border changes. +setBorderColor :: String -> [Window] -> X (X ()) +setBorderColor color wins = do + d <- asks display (px, oPx, fPx) <- - lift $ - (,,) - <$> stringToPixel d color - <*> (stringToPixel d =<< asks (normalBorderColor . config)) - <*> (stringToPixel d =<< asks (focusedBorderColor . config)) + (,,) + <$> stringToPixel d color + <*> (stringToPixel d =<< asks (normalBorderColor . config)) + <*> (stringToPixel d =<< asks (focusedBorderColor . config)) (colorName, oColorName, fColorName) <- - lift $ - (,,) - <$> io (pixelToString d px) - <*> io (pixelToString d oPx) - <*> io (pixelToString d fPx) + (,,) + <$> io (pixelToString d px) + <*> io (pixelToString d oPx) + <*> io (pixelToString d fPx) forM_ wins $ \w -> - lift $ setWindowBorderWithFallback d w colorName px + setWindowBorderWithFallback d w colorName px - myFinallyE fn $ - lift $ do - forM_ wins $ \w -> - setWindowBorderWithFallback d w oColorName oPx - withFocused $ \fw -> + return $ do + forM_ wins $ \w -> + setWindowBorderWithFallback d w oColorName oPx + withFocused $ \fw -> + when (fw `elem` wins) $ setWindowBorderWithFallback d fw fColorName fPx withBorderColorM :: String -> [Window] -> MaybeT X a -> MaybeT X a @@ -186,8 +192,8 @@ withBorderWidth width ws fn = do gotoWorkspace :: WorkspaceId -> X () gotoWorkspace wid = do - logs Debug "GotoWorkspace %s" wid - windows $ S.greedyView wid + logs Debug "GotoWorkspace %s" wid + windows $ S.greedyView wid moveLocationToWorkspace :: Location -> WorkspaceId -> X () moveLocationToWorkspace (Location _ (Just win)) wid = |