diff options
| author | Josh Rahm <rahm@google.com> | 2022-04-18 20:47:07 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | d41def38570056f97c841c82d053f2c2d87cb32b (patch) | |
| tree | c653e7aaf2c4572e69439053132128ff9eee2270 /src/Rahm/Desktop/Keys | |
| parent | 92e36c9262e7cc2f9ffdb7e45ef9aed43fa1e18c (diff) | |
| download | rde-d41def38570056f97c841c82d053f2c2d87cb32b.tar.gz rde-d41def38570056f97c841c82d053f2c2d87cb32b.tar.bz2 rde-d41def38570056f97c841c82d053f2c2d87cb32b.zip | |
Change window border when selecting windows
Diffstat (limited to 'src/Rahm/Desktop/Keys')
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index 47be2e7..21b8c4c 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -18,9 +18,11 @@ import Control.Monad.Trans.Maybe import Control.Monad.Trans.State as S import Control.Monad.Trans.Class import Control.Monad (join, forM_) +import Data.List (sortOn, intercalate) +import Data.Ord (Down(..)) import Data.Char (isAlphaNum, isAlpha, isDigit, ord) -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe, catMaybes) import XMonad.Actions.CopyWindow as CopyWindow import XMonad.Util.Run (safeSpawn) import Prelude hiding (head, last) @@ -191,8 +193,19 @@ readNextWorkspace = justWorkspace <$> (MaybeT $ return $ head $ tail $ rest) + (_, _, ";") -> do + ws <- readNextWorkspace + screens <- + mt $ + map (W.tag . W.workspace . snd) + <$> withWindowSet (return . getHorizontallyOrderedScreens) + + let (front, _) = break (==workspaceName ws) (screens ++ screens) + + justWorkspace <$> (MaybeT $ return $ last $ front) + (_, _, "/") -> fromMaybeTX $ do - justWorkspace <$> ((MaybeT . workspaceWithWindow) =<< MaybeT askWindowId) + justWorkspace <$> ((MaybeT . workspaceWithWindow) =<< MaybeT ((head=<<) <$> askWindowId)) (_, _, "@") -> do loc <- readNextLocationSet @@ -220,13 +233,20 @@ readNextLocationSet = (_, _, "$") -> (:[]) <$> fromMaybeTX farRightWindow (_, _, "\"") -> (:[]) <$> MaybeT (fromX nextLocation) (_, _, "'") -> (:[]) <$> MaybeT (fromX lastLocation) - (_, _, "*") -> fromMaybeTX $ (:[]) <$> (windowLocation =<< masterWindow) + (_, _, "*") -> mt $ do -- All visible windows. + wins <- withWindowSet $ + return . concatMap (W.integrate' . W.stack . W.workspace) . W.screens + + catMaybes <$> mapM (runMaybeT . windowLocation) wins + (_, _, "-") -> fromMaybeTX $ mapM windowLocation =<< lift getAlternateWindows (_, _, "/") -> fromMaybeTX $ - (:[]) <$> (windowLocation =<< MaybeT askWindowId) - (_, _, "%") -> fromMaybeTX $ - mapM windowLocation =<< lift (withWindowSet (return . W.allWindows)) + (mapM windowLocation =<< MaybeT askWindowId) + (_, _, "%") -> fromMaybeTX $ do + ret <- mapM windowLocation =<< lift (withWindowSet (return . sortOn Down . W.allWindows)) + lift $ logs $ "allWindows " ++ intercalate "\n" (map show ret) + return ret (_, _, "@") -> (mt . windowsInWorkspace . workspaceName) =<< readNextWorkspace (_, _, "!") -> (:[]) <$> (joinMaybe $ head <$> readNextLocationSet) @@ -236,15 +256,19 @@ readNextLocationSet = l1 <- readNextLocationSet l2 <- readNextLocationSet return $ if null l1 then l2 else l1 - - (_, _, "&") -> do + (_, _, "|") -> do l1 <- readNextLocationSet l2 <- readNextLocationSet return (l1 ++ l2) + (_, _, "_") -> return [] (_, _, "\\") -> do l1 <- readNextLocationSet l2 <- readNextLocationSet return $ filter (not . flip elem l2) l1 + (_, _, "&") -> do -- intersection + l1 <- readNextLocationSet + l2 <- readNextLocationSet + return $ filter (flip elem l2) l1 _ -> MaybeT (return Nothing) where |