Add switchTopicWith

This commit is contained in:
slotThe 2020-11-16 20:32:45 +01:00
parent 1400d167ad
commit ae6c658bc4

View File

@ -31,6 +31,7 @@ module XMonad.Actions.TopicSpace
, topicAction , topicAction
, currentTopicAction , currentTopicAction
, switchTopic , switchTopic
, switchTopicWith
, switchNthLastFocused , switchNthLastFocused
, switchNthLastFocusedExclude , switchNthLastFocusedExclude
, shiftNthLastFocused , shiftNthLastFocused
@ -318,10 +319,15 @@ currentTopicAction tg = topicAction tg =<< gets (W.tag . W.workspace . W.current
-- | Switch to the given topic. -- | Switch to the given topic.
switchTopic :: TopicConfig -> Topic -> X () switchTopic :: TopicConfig -> Topic -> X ()
switchTopic tg topic = do switchTopic = switchTopicWith (const True)
-- | Like 'switchTopic', but give a custom filtering function to
-- 'setLastFocusedTopic'.
switchTopicWith :: (Topic -> Bool) -> TopicConfig -> Topic -> X ()
switchTopicWith predicate tg topic = do
-- Switch to topic and add it to the last seen topics -- Switch to topic and add it to the last seen topics
windows $ W.greedyView topic windows $ W.greedyView topic
setLastFocusedTopic tg topic (const True) setLastFocusedTopic tg topic predicate
-- If applicable, execute the topic action -- If applicable, execute the topic action
wins <- gets (W.integrate' . W.stack . W.workspace . W.current . windowset) wins <- gets (W.integrate' . W.stack . W.workspace . W.current . windowset)