From 224cb93b1788c9d0474cb9fffc1ed967c94eaac8 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 29 Nov 2016 11:28:17 -0800 Subject: [PATCH] [XMonad] Add shiftToEmptyNextScreen --- dotfiles/xmonad/xmonad.hs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/dotfiles/xmonad/xmonad.hs b/dotfiles/xmonad/xmonad.hs index 3ef6ad10..4639a15c 100644 --- a/dotfiles/xmonad/xmonad.hs +++ b/dotfiles/xmonad/xmonad.hs @@ -18,7 +18,7 @@ import System.Taffybar.Hooks.PagerHints import Text.Printf import XMonad hiding ( (|||) ) -import XMonad.Actions.CycleWS +import XMonad.Actions.CycleWS hiding (nextScreen) import qualified XMonad.Actions.DynamicWorkspaceOrder as DWO import XMonad.Actions.Minimize import XMonad.Actions.WindowBringer @@ -439,6 +439,34 @@ greedyBringWindow w = greedyFocusWindow w . bringWindow w shiftToEmptyAndView = doTo Next EmptyWS DWO.getSortByOrder (windows . shiftThenView) +setFocusedScreen :: ScreenId -> WindowSet -> WindowSet +setFocusedScreen to ws = + maybe ws (flip setFocusedScreen' ws) $ find ((to ==) . W.screen) (W.visible ws) + +setFocusedScreen' to ws @ W.StackSet + { W.current = prevCurr + , W.visible = visible + } = ws { W.current = to + , W.visible = prevCurr:(deleteBy screenEq to visible) + } + + where screenEq a b = W.screen a == W.screen b + +nextScreen ws @ W.StackSet { W.visible = visible } = + case visible of + next:_ -> setFocusedScreen (W.screen next) ws + _ -> ws + +viewOtherScreen ws = W.greedyView ws . nextScreen + +shiftThenViewOtherScreen ws w = (viewOtherScreen ws) . (W.shiftWin ws w) + +shiftCurrentToWSOnOtherScreen ws s = + fromMaybe s (flip (shiftThenViewOtherScreen ws) s <$> W.peek s) + +shiftToEmptyNextScreen = + doTo Next EmptyWS DWO.getSortByOrder $ windows . shiftCurrentToWSOnOtherScreen + swapFocusedWith w ws = W.modify' (swapFocusedWith' w) (W.delete' w ws) swapFocusedWith' w (W.Stack current ls rs) = W.Stack w ls (rs ++ [current]) @@ -512,6 +540,7 @@ addKeys conf@XConfig {modMask = modm} = , ((modm, xK_backslash), toggleWS) , ((modm, xK_space), deactivateFullOr $ sendMessage NextLayout) , ((modm, xK_z), shiftToNextScreen) + , ((modm .|. shiftMask, xK_z), shiftToEmptyNextScreen) , ((modm, xK_x), windows $ W.shift "NSP") , ((modm .|. shiftMask, xK_h), shiftToEmptyAndView) -- These need to be rebound to support boringWindows