aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Keys
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Keys')
-rw-r--r--src/Rahm/Desktop/Keys/Wml.hs30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs
index 78f02c0..86bc921 100644
--- a/src/Rahm/Desktop/Keys/Wml.hs
+++ b/src/Rahm/Desktop/Keys/Wml.hs
@@ -21,6 +21,7 @@ module Rahm.Desktop.Keys.Wml
moveLocationToWorkspace,
moveWindowToWorkspaceFn,
getAndResetWindowSelection,
+ getAndResetWindowSelectionOrCurrent,
getWindowSelection,
gotoWorkspaceFn,
toggleWindowInSelection,
@@ -66,15 +67,7 @@ import Data.List (find, intercalate, sortOn)
import Data.List.Safe (head, last)
import Data.Map (Map)
import qualified Data.Map as Map
- ( delete,
- elems,
- empty,
- insert,
- keys,
- lookup,
- member,
- )
-import Data.Maybe (catMaybes, fromJust, fromMaybe)
+import Data.Maybe (catMaybes, fromJust, fromMaybe, maybeToList)
import Data.Ord (Down (..))
import Data.Typeable (cast)
import Data.Void (Void, absurd)
@@ -103,6 +96,7 @@ import Rahm.Desktop.Marking
getMarkedLocations,
windowLocation,
)
+import Rahm.Desktop.StackSet (StackSet (current))
import qualified Rahm.Desktop.StackSet as W
import Rahm.Desktop.Submap (mapNextStringWithKeysym)
import Rahm.Desktop.Workspaces
@@ -257,6 +251,17 @@ getAndResetWindowSelection = do
XS.put (initialValue :: WindowSelect)
return (Map.keys mp)
+getAndResetWindowSelectionOrCurrent :: X [Window]
+getAndResetWindowSelectionOrCurrent = do
+ (WindowSelect mp) <- XS.get
+
+ if Map.null mp
+ then withWindowSet $ return . maybeToList . W.peek
+ else do
+ sequence_ (Map.elems mp)
+ XS.put (initialValue :: WindowSelect)
+ return (Map.keys mp)
+
data Workspace = forall a.
(Typeable a) =>
Workspace
@@ -584,7 +589,6 @@ readNextLocationSet' =
-- A character is the base-case. Refers to a collection of windows.
(_, _, [ch]) | isAlpha ch -> liftXToFeed $ getMarkedLocations [ch]
-
-- Goes to the most recent location in history.
-- (_, _, "0") -> (: []) <$> MaybeT (fromX getMostRecentLocationInHistory)
-- A Digit goes to the past history.
@@ -618,8 +622,9 @@ readNextLocationSet' =
hoistMaybeT $
mapM windowLocation =<< nonempty askWindowId
-- All windows.
- (_, _, "%") -> hoistMaybeT $
- mapM windowLocation =<< lift (withWindowSet (return . sortOn Down . W.allWindows))
+ (_, _, "%") ->
+ hoistMaybeT $
+ mapM windowLocation =<< lift (withWindowSet (return . sortOn Down . W.allWindows))
-- Windows in a workspace
(_, _, s)
| s == "\t" || s == "@" || s == "\n" ->
@@ -664,5 +669,4 @@ readNextLocationSet' =
l1 <- readNextLocationSet
l2 <- readNextLocationSet
return $ filter (`elem` l2) l1
-
_ -> feedFail