aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-11-23 13:09:28 -0700
committerJosh Rahm <rahm@google.com>2022-11-23 13:09:28 -0700
commitd7f537a82d468b81034c102757755226e3afd07f (patch)
tree4bf586f4116d05dda239fdc32d040b37bc466377 /src/Rahm
parent2082efba780dee3d58bd291c3b8a969f67f3eec2 (diff)
downloadrde-d7f537a82d468b81034c102757755226e3afd07f.tar.gz
rde-d7f537a82d468b81034c102757755226e3afd07f.tar.bz2
rde-d7f537a82d468b81034c102757755226e3afd07f.zip
Macros should take precedence for windowsets
Diffstat (limited to 'src/Rahm')
-rw-r--r--src/Rahm/Desktop/Keys/Wml.hs30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs
index ae71e5f..52c5e28 100644
--- a/src/Rahm/Desktop/Keys/Wml.hs
+++ b/src/Rahm/Desktop/Keys/Wml.hs
@@ -479,37 +479,36 @@ readNextWorkspace =
readNextLocationSet :: (KeyFeeder m) => MaybeT m [Location]
readNextLocationSet =
- readNextKey $ \mask sym str ->
+ readNextKey $ \mask sym str -> do
+ macros <- (lift . fromX) $ windowsetMacros <$> XS.get
+
case (mask, sym, str) of
-- Escape returns nothing and aborts reading the next location.
(_, e, _) | e == xK_Escape -> MaybeT $ return Nothing
+ -- Macros takes precedence.
+ (mask, keysym, _) | (Just macro) <- Map.lookup (mask, keysym) macros -> do
+ macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . windowsetMacros <$> XS.get)
+ lift $ fromX $ logs Info "Executing Macro: %s" (show macro)
+ fromMaybeTX $ locationSetForKeysT macro
-- A character is the base-case. Refers to a collection of windows.
(_, _, [ch]) | isAlpha ch -> mt $ getMarkedLocations [ch]
-
-- Goes to the most recent location in history.
(_, _, "0") -> (: []) <$> MaybeT (fromX getMostRecentLocationInHistory)
-
-- A Digit goes to the past history.
(_, _, [ch])
| isDigit ch ->
(: []) <$> MaybeT (fromX $ pastHistory (ord ch - 0x30))
-
-- The current window.
(_, _, ".") -> (: []) <$> mt getCurrentLocation
-
-- The window on the far-left of the screens.
(_, _, "^") -> (: []) <$> fromMaybeTX farLeftWindow
-
-- The windows on the far-right of the screens.
(_, _, "$") -> (: []) <$> fromMaybeTX farRightWindow
-
-- The next location in history.
(_, _, "\"") -> (: []) <$> MaybeT (fromX nextLocation)
-
-- The previous location in history.
(_, _, "'") -> (: []) <$> MaybeT (fromX lastLocation)
-
-- All visible windows.
(_, _, "*") -> mt $ do
wins <-
@@ -522,12 +521,10 @@ readNextLocationSet =
(_, _, "-") ->
fromMaybeTX $
mapM windowLocation =<< lift getAlternateWindows
-
-- Search for the windows.
(_, _, "/") ->
fromMaybeTX $
mapM windowLocation =<< MaybeT askWindowId
-
-- All windows.
(_, _, "%") -> fromMaybeTX $ do
ret <- mapM windowLocation =<< lift (withWindowSet (return . sortOn Down . W.allWindows))
@@ -538,16 +535,12 @@ readNextLocationSet =
(_, _, s)
| s == "\t" || s == "@" || s == "\n" ->
(mt . windowsInWorkspace) =<< readNextWorkspaceName
-
-- The first window in the next window set.
(_, _, "!") -> (: []) <$> joinMaybe (head <$> readNextLocationSet)
-
-- The windows except the first in a window set.
(_, _, ",") -> tail <$> readNextLocationSet
-
-- The next window set, but reversed
(_, _, "~") -> reverse <$> readNextLocationSet
-
-- All the floating windows
(_, _, ":") ->
mt $
@@ -556,7 +549,6 @@ readNextLocationSet =
. mapM (runMaybeT . windowLocation)
. Map.keys
. W.floating
-
-- If the next read window set is not empty, then this location
-- otherwise the next read location.
(_, _, "?") -> do
@@ -572,7 +564,6 @@ readNextLocationSet =
-- Empty window set.
(_, _, "_") -> return []
-
-- The next location set differenced with the next-next location set
(_, _, "\\") -> do
l1 <- readNextLocationSet
@@ -584,11 +575,6 @@ readNextLocationSet =
l1 <- readNextLocationSet
l2 <- readNextLocationSet
return $ filter (`elem` l2) l1
-
- (mask, keysym, _) -> do
- macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . windowsetMacros <$> XS.get)
- lift $ fromX $ logs Info "Executing Macro: %s" (show macro)
- fromMaybeTX $ locationSetForKeysT macro
where
mt :: (KeyFeeder m) => X a -> MaybeT m a
mt = lift . fromX