mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Respect maxTopicHistory when entering topics into the history
So far, maxTopicHistory was only used when pretty-printing the history via pprWindowSet, which does not line up with the documentation that it has.
This commit is contained in:
parent
4c0b5330e7
commit
aa67fa5352
@ -271,13 +271,13 @@ getLastFocusedTopics = XS.gets getPrevTopics
|
|||||||
|
|
||||||
-- | Given a 'TopicConfig', a topic, and a predicate to select topics that one
|
-- | Given a 'TopicConfig', a topic, and a predicate to select topics that one
|
||||||
-- wants to keep, this function will filter the list of last focused topics
|
-- wants to keep, this function will filter the list of last focused topics
|
||||||
-- according to the predicate and cons the topic in front of that list.
|
-- according to the predicate and cons the topic in front of that list. Note
|
||||||
setLastFocusedTopic :: Topic -> (Topic -> Bool) -> X ()
|
-- that we prune the list in case its length exceeds 'maxTopicHistory'.
|
||||||
setLastFocusedTopic w predicate =
|
setLastFocusedTopic :: TopicConfig -> Topic -> (Topic -> Bool) -> X ()
|
||||||
|
setLastFocusedTopic tc w predicate =
|
||||||
XS.modify $ PrevTopics
|
XS.modify $ PrevTopics
|
||||||
. seqList . nub . (w:) . filter predicate
|
. take (maxTopicHistory tc)
|
||||||
. getPrevTopics
|
. nub . (w :) . filter predicate . getPrevTopics
|
||||||
where seqList xs = length xs `seq` xs
|
|
||||||
|
|
||||||
-- | Reverse the list of "last focused topics"
|
-- | Reverse the list of "last focused topics"
|
||||||
reverseLastFocusedTopics :: X ()
|
reverseLastFocusedTopics :: X ()
|
||||||
@ -293,7 +293,8 @@ pprWindowSet tg pp = do
|
|||||||
urgents <- readUrgents
|
urgents <- readUrgents
|
||||||
let empty_workspaces = map W.tag $ filter (isNothing . W.stack) $ W.workspaces winset
|
let empty_workspaces = map W.tag $ filter (isNothing . W.stack) $ W.workspaces winset
|
||||||
maxDepth = maxTopicHistory tg
|
maxDepth = maxTopicHistory tg
|
||||||
setLastFocusedTopic (W.tag . W.workspace . W.current $ winset)
|
setLastFocusedTopic tg
|
||||||
|
(W.tag . W.workspace . W.current $ winset)
|
||||||
(`notElem` empty_workspaces)
|
(`notElem` empty_workspaces)
|
||||||
lastWs <- getLastFocusedTopics
|
lastWs <- getLastFocusedTopics
|
||||||
let depth topic = fromJust $ elemIndex topic (lastWs ++ [topic])
|
let depth topic = fromJust $ elemIndex topic (lastWs ++ [topic])
|
||||||
@ -320,7 +321,7 @@ switchTopic :: TopicConfig -> Topic -> X ()
|
|||||||
switchTopic tg topic = do
|
switchTopic 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 topic (const True)
|
setLastFocusedTopic tg topic (const True)
|
||||||
|
|
||||||
-- 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user