{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# LANGUAGE MultiParamTypeClasses, Rank2Types, ViewPatterns #-}
module XMonad.Layout.Groups.Helpers (
swapUp
, swapDown
, swapMaster
, focusUp
, focusDown
, focusMaster
, toggleFocusFloat
, swapGroupUp
, swapGroupDown
, swapGroupMaster
, focusGroupUp
, focusGroupDown
, focusGroupMaster
, moveToGroupUp
, moveToGroupDown
, moveToNewGroupUp
, moveToNewGroupDown
, splitGroup ) where
import XMonad hiding ((|||))
import qualified XMonad.StackSet as W
import qualified XMonad.Layout.Groups as G
import XMonad.Actions.MessageFeedback (sendMessageB)
import XMonad.Prelude (unless)
import qualified Data.Map as M
alt :: G.ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt :: ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt ModifySpec
f WindowSet -> WindowSet
g = GroupsMessage -> X () -> X ()
alt2 (ModifySpec -> GroupsMessage
G.Modify ModifySpec
f) forall a b. (a -> b) -> a -> b
$ (WindowSet -> WindowSet) -> X ()
windows WindowSet -> WindowSet
g
alt2 :: G.GroupsMessage -> X () -> X ()
alt2 :: GroupsMessage -> X () -> X ()
alt2 GroupsMessage
m X ()
x = do Bool
b <- forall a. Message a => a -> X Bool
sendMessageB GroupsMessage
m
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
b X ()
x
swapUp :: X ()
swapUp :: X ()
swapUp = ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt ModifySpec
G.swapUp forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.swapUp
swapDown :: X ()
swapDown :: X ()
swapDown = ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt ModifySpec
G.swapDown forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.swapDown
swapMaster :: X ()
swapMaster :: X ()
swapMaster = ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt ModifySpec
G.swapMaster forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.swapMaster
focusUp :: X ()
focusUp :: X ()
focusUp = X () -> X () -> X ()
ifFloat X ()
focusFloatUp X ()
focusNonFloatUp
focusDown :: X ()
focusDown :: X ()
focusDown = X () -> X () -> X ()
ifFloat X ()
focusFloatDown X ()
focusNonFloatDown
focusMaster :: X ()
focusMaster :: X ()
focusMaster = ModifySpec -> (WindowSet -> WindowSet) -> X ()
alt ModifySpec
G.focusMaster forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.shiftMaster
toggleFocusFloat :: X ()
toggleFocusFloat :: X ()
toggleFocusFloat = X () -> X () -> X ()
ifFloat X ()
focusNonFloat X ()
focusFloatUp
getFloats :: X [Window]
getFloats :: X [Window]
getFloats = forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets forall a b. (a -> b) -> a -> b
$ forall k a. Map k a -> [k]
M.keys forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> Map a RationalRect
W.floating forall b c a. (b -> c) -> (a -> b) -> a -> c
. XState -> WindowSet
windowset
getWindows :: X [Window]
getWindows :: X [Window]
getWindows = forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets forall a b. (a -> b) -> a -> b
$ forall a. Maybe (Stack a) -> [a]
W.integrate' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current forall b c a. (b -> c) -> (a -> b) -> a -> c
. XState -> WindowSet
windowset
ifFloat :: X () -> X () -> X ()
ifFloat :: X () -> X () -> X ()
ifFloat X ()
x1 X ()
x2 = (Window -> X ()) -> X ()
withFocused forall a b. (a -> b) -> a -> b
$ \Window
w -> do [Window]
floats <- X [Window]
getFloats
if Window
w forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Window]
floats then X ()
x1 else X ()
x2
focusNonFloat :: X ()
focusNonFloat :: X ()
focusNonFloat = GroupsMessage -> X () -> X ()
alt2 GroupsMessage
G.Refocus X ()
helper
where helper :: X ()
helper = (Window -> X ()) -> X ()
withFocused forall a b. (a -> b) -> a -> b
$ \Window
w -> do
[Window]
ws <- X [Window]
getWindows
[Window]
floats <- X [Window]
getFloats
let ([Window]
before, [Window]
after) = forall a. (a -> Bool) -> [a] -> ([a], [a])
span (forall a. Eq a => a -> a -> Bool
/=Window
w) [Window]
ws
case forall a. (a -> Bool) -> [a] -> [a]
filter (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Window]
floats) forall a b. (a -> b) -> a -> b
$ [Window]
after forall a. [a] -> [a] -> [a]
++ [Window]
before of
[] -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Window
w':[Window]
_ -> Window -> X ()
focus Window
w'
focusHelper :: (Bool -> Bool)
-> ([Window] -> [Window])
-> X ()
focusHelper :: (Bool -> Bool) -> ([Window] -> [Window]) -> X ()
focusHelper Bool -> Bool
f [Window] -> [Window]
g = (Window -> X ()) -> X ()
withFocused forall a b. (a -> b) -> a -> b
$ \Window
w -> do
[Window]
ws <- X [Window]
getWindows
let ([Window]
before, forall a. Int -> [a] -> [a]
drop Int
1 -> [Window]
after) = forall a. (a -> Bool) -> [a] -> ([a], [a])
span (forall a. Eq a => a -> a -> Bool
/=Window
w) [Window]
ws
let toFocus :: [Window]
toFocus = [Window] -> [Window]
g forall a b. (a -> b) -> a -> b
$ [Window]
after forall a. [a] -> [a] -> [a]
++ [Window]
before
[Window]
floats <- X [Window]
getFloats
case forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem [Window]
floats) [Window]
toFocus of
[] -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Window
w':[Window]
_ -> Window -> X ()
focus Window
w'
focusNonFloatUp :: X ()
focusNonFloatUp :: X ()
focusNonFloatUp = GroupsMessage -> X () -> X ()
alt2 (ModifySpec -> GroupsMessage
G.Modify ModifySpec
G.focusUp) forall a b. (a -> b) -> a -> b
$ (Bool -> Bool) -> ([Window] -> [Window]) -> X ()
focusHelper Bool -> Bool
not forall a. [a] -> [a]
reverse
focusNonFloatDown :: X ()
focusNonFloatDown :: X ()
focusNonFloatDown = GroupsMessage -> X () -> X ()
alt2 (ModifySpec -> GroupsMessage
G.Modify ModifySpec
G.focusDown) forall a b. (a -> b) -> a -> b
$ (Bool -> Bool) -> ([Window] -> [Window]) -> X ()
focusHelper Bool -> Bool
not forall a. a -> a
id
focusFloatUp :: X ()
focusFloatUp :: X ()
focusFloatUp = (Bool -> Bool) -> ([Window] -> [Window]) -> X ()
focusHelper forall a. a -> a
id forall a. [a] -> [a]
reverse
focusFloatDown :: X ()
focusFloatDown :: X ()
focusFloatDown = (Bool -> Bool) -> ([Window] -> [Window]) -> X ()
focusHelper forall a. a -> a
id forall a. a -> a
id
wrap :: G.ModifySpec -> X ()
wrap :: ModifySpec -> X ()
wrap ModifySpec
x = forall a. Message a => a -> X ()
sendMessage (ModifySpec -> GroupsMessage
G.Modify ModifySpec
x)
swapGroupUp :: X ()
swapGroupUp :: X ()
swapGroupUp = ModifySpec -> X ()
wrap ModifySpec
G.swapGroupUp
swapGroupDown :: X ()
swapGroupDown :: X ()
swapGroupDown = ModifySpec -> X ()
wrap ModifySpec
G.swapGroupDown
swapGroupMaster :: X ()
swapGroupMaster :: X ()
swapGroupMaster = ModifySpec -> X ()
wrap ModifySpec
G.swapGroupMaster
focusGroupUp :: X ()
focusGroupUp :: X ()
focusGroupUp = ModifySpec -> X ()
wrap ModifySpec
G.focusGroupUp
focusGroupDown :: X ()
focusGroupDown :: X ()
focusGroupDown = ModifySpec -> X ()
wrap ModifySpec
G.focusGroupDown
focusGroupMaster :: X ()
focusGroupMaster :: X ()
focusGroupMaster = ModifySpec -> X ()
wrap ModifySpec
G.focusGroupMaster
moveToGroupUp :: Bool -> X ()
moveToGroupUp :: Bool -> X ()
moveToGroupUp Bool
b = ModifySpec -> X ()
wrap (Bool -> ModifySpec
G.moveToGroupUp Bool
b)
moveToGroupDown :: Bool -> X ()
moveToGroupDown :: Bool -> X ()
moveToGroupDown Bool
b = ModifySpec -> X ()
wrap (Bool -> ModifySpec
G.moveToGroupDown Bool
b)
moveToNewGroupUp :: X ()
moveToNewGroupUp :: X ()
moveToNewGroupUp = ModifySpec -> X ()
wrap ModifySpec
G.moveToNewGroupUp
moveToNewGroupDown :: X ()
moveToNewGroupDown :: X ()
moveToNewGroupDown = ModifySpec -> X ()
wrap ModifySpec
G.moveToNewGroupDown
splitGroup :: X ()
splitGroup :: X ()
splitGroup = ModifySpec -> X ()
wrap ModifySpec
G.splitGroup