Merge pull request #126 from pauleve/master

Fix #120 - Make Actions.WindowGo.raiseNextMaybe span over all workspaces
This commit is contained in:
Peter J. Jones 2016-12-08 14:39:30 -07:00 committed by GitHub
commit c69b2933a3
2 changed files with 16 additions and 2 deletions

View File

@ -57,6 +57,11 @@
The project itself was already being deleted, this just deletes The project itself was already being deleted, this just deletes
the workspace created for it as well. the workspace created for it as well.
* `XMonad.Actions.WindowGo`
- Fix `raiseNextMaybe` cycling between 2 workspaces only.
## 0.12 (December 14, 2015) ## 0.12 (December 14, 2015)
### Breaking Changes ### Breaking Changes

View File

@ -38,13 +38,14 @@ module XMonad.Actions.WindowGo (
import Control.Monad import Control.Monad
import Data.Char (toLower) import Data.Char (toLower)
import qualified Data.List as L (nub,sortBy)
import Data.Monoid import Data.Monoid
import XMonad (Query(), X(), ManageHook, WindowSet, withWindowSet, runQuery, liftIO, ask) import XMonad (Query(), X(), ManageHook, WindowSet, withWindowSet, runQuery, liftIO, ask)
import Graphics.X11 (Window) import Graphics.X11 (Window)
import XMonad.ManageHook import XMonad.ManageHook
import XMonad.Operations (windows) import XMonad.Operations (windows)
import XMonad.Prompt.Shell (getBrowser, getEditor) import XMonad.Prompt.Shell (getBrowser, getEditor)
import qualified XMonad.StackSet as W (allWindows, peek, swapMaster, focusWindow) import qualified XMonad.StackSet as W (peek, swapMaster, focusWindow, workspaces, StackSet, Workspace, integrate', tag, stack)
import XMonad.Util.Run (safeSpawnProg) import XMonad.Util.Run (safeSpawnProg)
{- $usage {- $usage
@ -66,12 +67,20 @@ appropriate one, or cover your bases by using instead something like:
For detailed instructions on editing your key bindings, see For detailed instructions on editing your key bindings, see
"XMonad.Doc.Extending#Editing_key_bindings". -} "XMonad.Doc.Extending#Editing_key_bindings". -}
-- | Get the list of workspaces sorted by their tag
workspacesSorted :: Ord i => W.StackSet i l a s sd -> [W.Workspace i l a]
workspacesSorted s = L.sortBy (\u t -> W.tag u `compare` W.tag t) $ W.workspaces s
-- | Get a list of all windows in the 'StackSet' with an absolute ordering of workspaces
allWindowsSorted :: Ord i => Eq a => W.StackSet i l a s sd -> [a]
allWindowsSorted = L.nub . concatMap (W.integrate' . W.stack) . workspacesSorted
-- | If windows that satisfy the query exist, apply the supplied -- | If windows that satisfy the query exist, apply the supplied
-- function to them, otherwise run the action given as -- function to them, otherwise run the action given as
-- second parameter. -- second parameter.
ifWindows :: Query Bool -> ([Window] -> X ()) -> X () -> X () ifWindows :: Query Bool -> ([Window] -> X ()) -> X () -> X ()
ifWindows qry f el = withWindowSet $ \wins -> do ifWindows qry f el = withWindowSet $ \wins -> do
matches <- filterM (runQuery qry) $ W.allWindows wins matches <- filterM (runQuery qry) $ allWindowsSorted wins
case matches of case matches of
[] -> el [] -> el
ws -> f ws ws -> f ws