forked from colonelpanic/dotfiles
[XMonad] Restore all from same class on focus
This commit is contained in:
parent
d4bd87ed71
commit
ca0508b9ba
@ -197,24 +197,39 @@ restoreFocus action = withFocused $ \orig -> action >> windows (W.focusWindow or
|
|||||||
withWorkspace f = withWindowSet $ \ws ->
|
withWorkspace f = withWindowSet $ \ws ->
|
||||||
maybe (return ()) f (W.stack . W.workspace . W.current $ ws)
|
maybe (return ()) f (W.stack . W.workspace . W.current $ ws)
|
||||||
|
|
||||||
minimizeOtherClassesInWorkspace = restoreFocus $
|
minimizeOtherClassesInWorkspace =
|
||||||
withWorkspace (windowsWithUnfocusedClass >=> mapM_ minimizeWindow)
|
actOnWindowsInWorkspace minimizeWindow windowsWithUnfocusedClass
|
||||||
|
maximizeSameClassesInWorkspace =
|
||||||
|
actOnWindowsInWorkspace maybeUnminimize windowsWithFocusedClass
|
||||||
|
|
||||||
windowsWithUnfocusedClass ws = windowsWithOtherClasses ws (W.focus ws)
|
-- Type annotation is needed to resolve ambiguity
|
||||||
|
actOnWindowsInWorkspace :: (Window -> X ()) -> (W.Stack Window -> X [Window]) -> X ()
|
||||||
|
actOnWindowsInWorkspace windowAction getWindowsAction = restoreFocus $
|
||||||
|
withWorkspace (getWindowsAction >=> mapM_ windowAction)
|
||||||
|
|
||||||
windowsWithOtherClasses workspace window = do
|
windowsWithUnfocusedClass ws = windowsWithOtherClasses (W.focus ws) ws
|
||||||
|
windowsWithFocusedClass ws = windowsWithSameClass (W.focus ws) ws
|
||||||
|
windowsWithOtherClasses = windowsMatchingPredicate (/=)
|
||||||
|
windowsWithSameClass = windowsMatchingPredicate (==)
|
||||||
|
|
||||||
|
windowsMatchingPredicate predicate window workspace =
|
||||||
|
windowsSatisfyingPredicate workspace $ do
|
||||||
windowClass <- getClass window
|
windowClass <- getClass window
|
||||||
let predicate = (/= windowClass)
|
return $ predicate windowClass
|
||||||
|
|
||||||
|
windowsSatisfyingPredicate workspace getPredicate = do
|
||||||
|
predicate <- getPredicate
|
||||||
filterM (\w -> predicate <$> getClass w) (W.integrate workspace)
|
filterM (\w -> predicate <$> getClass w) (W.integrate workspace)
|
||||||
|
|
||||||
windowIsMinimized w = do
|
windowIsMinimized w = do
|
||||||
minimized <- XS.gets minimizedStack
|
minimized <- XS.gets minimizedStack
|
||||||
return $ w `elem` minimized
|
return $ w `elem` minimized
|
||||||
|
|
||||||
maybeUnminimizeFocused = withFocused $ \w ->
|
maybeUnminimize w = windowIsMinimized w >>= flip when (maximizeWindow w)
|
||||||
windowIsMinimized w >>= flip when (maximizeWindow w)
|
|
||||||
|
|
||||||
maybeUnminimizeAfter = (>> maybeUnminimizeFocused)
|
maybeUnminimizeFocused = withFocused maybeUnminimize
|
||||||
|
|
||||||
|
maybeUnminimizeAfter = (>> maximizeSameClassesInWorkspace)
|
||||||
|
|
||||||
restoreAllMinimized = restoreFocus $
|
restoreAllMinimized = restoreFocus $
|
||||||
withLastMinimized $ \w -> maximizeWindow w >> restoreAllMinimized
|
withLastMinimized $ \w -> maximizeWindow w >> restoreAllMinimized
|
||||||
|
Loading…
Reference in New Issue
Block a user