From 04d0ab42a39df36acfc84846cc122f0bb9786446 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 12 Nov 2021 11:06:37 -0700 Subject: Use XMonad's EtensibleState Change the Marking to use XMonad's extensible state rather than hand-rolling it myself. Allowed me to delete the XPlus monad. --- src/Internal/Lib.hs | 67 ++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 44 deletions(-) (limited to 'src/Internal/Lib.hs') diff --git a/src/Internal/Lib.hs b/src/Internal/Lib.hs index 08ba2b7..1a1d602 100644 --- a/src/Internal/Lib.hs +++ b/src/Internal/Lib.hs @@ -15,7 +15,6 @@ import Data.List hiding ((!!)) import Data.List.Safe ((!!)) import Data.Maybe import Internal.Marking -import Internal.XPlus import Text.Printf import XMonad hiding (workspaces, Screen) import XMonad.StackSet hiding (filter, focus) @@ -65,18 +64,16 @@ getHorizontallyOrderedScreens windowSet = screens = current windowSet : visible windowSet -gotoWorkspace :: WorkspaceName -> XPlus l () +gotoWorkspace :: WorkspaceName -> X () gotoWorkspace ch = do - mc <- getMarkContext - liftXPlus $ do - saveLastMark mc - windows $ greedyView $ return ch + saveLastMark + windows $ greedyView $ return ch -shiftToWorkspace :: WorkspaceName -> XPlus l () -shiftToWorkspace = liftXPlus . windows . shift . return +shiftToWorkspace :: WorkspaceName -> X () +shiftToWorkspace = windows . shift . return -swapWorkspace :: WorkspaceName -> XPlus l () -swapWorkspace toWorkspaceName = liftXPlus $ do +swapWorkspace :: WorkspaceName -> X () +swapWorkspace toWorkspaceName = do windows $ \ss -> do let fromWorkspace = tag $ workspace $ current ss toWorkspace = [toWorkspaceName] in @@ -128,40 +125,22 @@ prev :: Selector prev = Selector $ \a l -> let (Selector fn) = next in fn a (reverse l) -withScreen :: (WorkspaceId -> WindowSet -> WindowSet) -> Int -> XPlus l () +withScreen :: (WorkspaceId -> WindowSet -> WindowSet) -> Int -> X () withScreen fn n = do - markContext <- getMarkContext + windows $ \windowSet -> + case (getHorizontallyOrderedScreens windowSet !! n) of + Nothing -> windowSet + Just screen -> fn (tag $ workspace screen) windowSet - liftXPlus $ - windows $ \windowSet -> - case (getHorizontallyOrderedScreens windowSet !! n) of - Nothing -> windowSet - Just screen -> fn (tag $ workspace screen) windowSet - -windowJump :: XPlus l () +windowJump :: X () windowJump = do - markContext <- getMarkContext - - liftXPlus $ do - windowTitlesToWinId <- withWindowSet $ \ss -> - Map.fromList <$> mapM (\wid -> (,) <$> getString wid <*> return wid) (allWindows ss) - - windowId <- runDMenuPromptWithMap "Window" (Just "#f542f5") windowTitlesToWinId - - case windowId of - Nothing -> return () - Just wid -> do - saveLastMark markContext - focus wid - -- mkXPrompt - -- WinPrompt - -- xpConfig - -- (\input -> return $ filter (fuzzyCompletion input) (Map.keys windowTitlesToWinId)) $ - -- \str -> do - -- saveLastMark markContext - -- case Map.lookup str windowTitlesToWinId of - -- Just w -> focus w - -- Nothing -> - -- case filter (fuzzyCompletion str) (Map.keys windowTitlesToWinId) of - -- [s] -> mapM_ focus (Map.lookup s windowTitlesToWinId) - -- _ -> return () + windowTitlesToWinId <- withWindowSet $ \ss -> + Map.fromList <$> mapM (\wid -> (,) <$> getString wid <*> return wid) (allWindows ss) + + windowId <- runDMenuPromptWithMap "Window" (Just "#f542f5") windowTitlesToWinId + + case windowId of + Nothing -> return () + Just wid -> do + saveLastMark + focus wid -- cgit