X.A.WindowGo: Add arg for custom focus fn to raiseNextMaybe

This commit is contained in:
Ivan Malison 2016-10-26 17:00:14 -07:00
parent ae7fd21e29
commit 49fecdf4eb
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -21,6 +21,7 @@ module XMonad.Actions.WindowGo (
runOrRaiseNext, runOrRaiseNext,
raiseMaybe, raiseMaybe,
raiseNextMaybe, raiseNextMaybe,
raiseNextMaybeCustomFocus,
raiseBrowser, raiseBrowser,
raiseEditor, raiseEditor,
@ -38,7 +39,7 @@ module XMonad.Actions.WindowGo (
import Control.Monad import Control.Monad
import Data.Char (toLower) import Data.Char (toLower)
import Data.Monoid import Data.Monoid
import XMonad (Query(), X(), ManageHook, 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)
@ -141,12 +142,15 @@ raiseNext = raiseNextMaybe $ return ()
-} -}
raiseNextMaybe :: X () -> Query Bool -> X () raiseNextMaybe :: X () -> Query Bool -> X ()
raiseNextMaybe f qry = flip (ifWindows qry) f $ \ws -> do raiseNextMaybe = raiseNextMaybeCustomFocus W.focusWindow
raiseNextMaybeCustomFocus :: (Window -> (WindowSet -> WindowSet)) -> X() -> Query Bool -> X()
raiseNextMaybeCustomFocus focusFn f qry = flip (ifWindows qry) f $ \ws -> do
foc <- withWindowSet $ return . W.peek foc <- withWindowSet $ return . W.peek
case foc of case foc of
Just w | w `elem` ws -> let (_:y:_) = dropWhile (/=w) $ cycle ws -- cannot fail to match Just w | w `elem` ws -> let (_:y:_) = dropWhile (/=w) $ cycle ws -- cannot fail to match
in windows $ W.focusWindow y in windows $ focusFn y
_ -> windows . W.focusWindow . head $ ws _ -> windows . focusFn . head $ ws
-- | Given a function which gets us a String, we try to raise a window with that classname, -- | Given a function which gets us a String, we try to raise a window with that classname,
-- or we then interpret that String as a executable name. -- or we then interpret that String as a executable name.