aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Lib.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-11-12 11:06:37 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit04d0ab42a39df36acfc84846cc122f0bb9786446 (patch)
tree295aaf03057aa56a98148c9c7cdb6ae14404a490 /src/Internal/Lib.hs
parentf4d1c466823c8a377b9bc8214bf7d586b6c03c6f (diff)
downloadrde-04d0ab42a39df36acfc84846cc122f0bb9786446.tar.gz
rde-04d0ab42a39df36acfc84846cc122f0bb9786446.tar.bz2
rde-04d0ab42a39df36acfc84846cc122f0bb9786446.zip
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.
Diffstat (limited to 'src/Internal/Lib.hs')
-rw-r--r--src/Internal/Lib.hs67
1 files changed, 23 insertions, 44 deletions
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