From 49fecdf4ebe45e134fc167541ef7dfa774ebeb28 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 26 Oct 2016 17:00:14 -0700 Subject: [PATCH 1/4] X.A.WindowGo: Add arg for custom focus fn to raiseNextMaybe --- XMonad/Actions/WindowGo.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/XMonad/Actions/WindowGo.hs b/XMonad/Actions/WindowGo.hs index 46b651ad..1ee62e2c 100644 --- a/XMonad/Actions/WindowGo.hs +++ b/XMonad/Actions/WindowGo.hs @@ -21,6 +21,7 @@ module XMonad.Actions.WindowGo ( runOrRaiseNext, raiseMaybe, raiseNextMaybe, + raiseNextMaybeCustomFocus, raiseBrowser, raiseEditor, @@ -38,7 +39,7 @@ module XMonad.Actions.WindowGo ( import Control.Monad import Data.Char (toLower) 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 XMonad.ManageHook import XMonad.Operations (windows) @@ -141,12 +142,15 @@ raiseNext = raiseNextMaybe $ return () -} 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 case foc of Just w | w `elem` ws -> let (_:y:_) = dropWhile (/=w) $ cycle ws -- cannot fail to match - in windows $ W.focusWindow y - _ -> windows . W.focusWindow . head $ ws + in windows $ focusFn y + _ -> windows . focusFn . head $ ws -- | 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. From 8e061c0c6de75c895b51ddbeacb544cb218c6acf Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 26 Oct 2016 17:24:45 -0700 Subject: [PATCH 2/4] X.A.WindowGo: Remove uncurry from raiseNextMaybeCustomFocus --- XMonad/Actions/WindowGo.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XMonad/Actions/WindowGo.hs b/XMonad/Actions/WindowGo.hs index 1ee62e2c..e4760d6d 100644 --- a/XMonad/Actions/WindowGo.hs +++ b/XMonad/Actions/WindowGo.hs @@ -144,7 +144,7 @@ raiseNext = raiseNextMaybe $ return () raiseNextMaybe :: X () -> Query Bool -> X () raiseNextMaybe = raiseNextMaybeCustomFocus W.focusWindow -raiseNextMaybeCustomFocus :: (Window -> (WindowSet -> WindowSet)) -> X() -> Query Bool -> X() +raiseNextMaybeCustomFocus :: (Window -> WindowSet -> WindowSet) -> X() -> Query Bool -> X() raiseNextMaybeCustomFocus focusFn f qry = flip (ifWindows qry) f $ \ws -> do foc <- withWindowSet $ return . W.peek case foc of From c51bd739d749f89793d028f2613ab36b2eb66d13 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 3 Nov 2016 19:21:52 -0700 Subject: [PATCH 3/4] X.A.WindowGo: Add a haddock comment to raiseNextMaybeCustomFocus --- XMonad/Actions/WindowGo.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/XMonad/Actions/WindowGo.hs b/XMonad/Actions/WindowGo.hs index e4760d6d..4b772510 100644 --- a/XMonad/Actions/WindowGo.hs +++ b/XMonad/Actions/WindowGo.hs @@ -144,6 +144,10 @@ raiseNext = raiseNextMaybe $ return () raiseNextMaybe :: X () -> Query Bool -> X () raiseNextMaybe = raiseNextMaybeCustomFocus W.focusWindow +{- | See 'raiseMaybe' and 'raiseNextMaybe'. + In addition to all of the options offered by 'raiseNextMaybe' + 'raiseNextMaybeCustomFocus' allows the user to supply the function that + should be used to shift the focus to any window that is found. -} raiseNextMaybeCustomFocus :: (Window -> WindowSet -> WindowSet) -> X() -> Query Bool -> X() raiseNextMaybeCustomFocus focusFn f qry = flip (ifWindows qry) f $ \ws -> do foc <- withWindowSet $ return . W.peek From 856b1251865ffbc90c2f3813905e284fea8dc7d2 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 3 Nov 2016 19:22:49 -0700 Subject: [PATCH 4/4] X.A.WindowGo: Make comment style more consistent --- XMonad/Actions/WindowGo.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/XMonad/Actions/WindowGo.hs b/XMonad/Actions/WindowGo.hs index 4b772510..0acfc564 100644 --- a/XMonad/Actions/WindowGo.hs +++ b/XMonad/Actions/WindowGo.hs @@ -138,9 +138,7 @@ raiseNext = raiseNextMaybe $ return () 'raiseNextMaybe' is an alternative version that allows cycling through the matching windows. If the focused window matches the query the next matching window is raised. If no matches are found - the function f is executed. --} - + the function f is executed. -} raiseNextMaybe :: X () -> Query Bool -> X () raiseNextMaybe = raiseNextMaybeCustomFocus W.focusWindow @@ -175,7 +173,8 @@ raiseAndDo :: X () -> Query Bool -> (Window -> X ()) -> X () raiseAndDo f qry after = ifWindow qry (afterRaise `mappend` raiseHook) f where afterRaise = ask >>= (>> idHook) . liftX . after -{- | If a window matching the second argument is found, the window is focused and the third argument is called; +{- | If a window matching the second argument is found, the window is focused and + the third argument is called; otherwise, the first argument is called. -} runOrRaiseAndDo :: String -> Query Bool -> (Window -> X ()) -> X () runOrRaiseAndDo = raiseAndDo . safeSpawnProg @@ -190,7 +189,6 @@ raiseMaster raisef thatUserQuery = raiseAndDo raisef thatUserQuery (\_ -> window {- | If the window is found the window is focused and set to master otherwise, action is run. - > runOrRaiseMaster "firefox" (className =? "Firefox")) - -} + > runOrRaiseMaster "firefox" (className =? "Firefox")) -} runOrRaiseMaster :: String -> Query Bool -> X () runOrRaiseMaster run query = runOrRaiseAndDo run query (\_ -> windows W.swapMaster)