This commit is contained in:
Leon Kowarschick 2020-06-13 15:17:00 +02:00
parent de8881498a
commit 50a655aa87
2 changed files with 5 additions and 13 deletions

View file

@ -12,6 +12,7 @@ import Data.Semigroup ( All(..) )
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.List ( isInfixOf ) import Data.List ( isInfixOf )
import Control.Monad ( when ) import Control.Monad ( when )
import qualified XMonad.Layout.Hidden as Hidden
swallowEventHook :: [Query Bool] -> [Query Bool] -> Event -> X All swallowEventHook :: [Query Bool] -> [Query Bool] -> Event -> X All
@ -28,17 +29,16 @@ swallowEventHook parentQueries childQueries event = do
oldFloating <- XS.gets floatingBeforeClosing oldFloating <- XS.gets floatingBeforeClosing
case (maybeSwallowedParent, maybeOldStack) of case (maybeSwallowedParent, maybeOldStack) of
(Just parent, Just oldStack) -> do (Just parent, Just oldStack) -> do
Hidden.popHiddenWindow parent
windows windows
(\ws -> (\ws ->
updateCurrentStack updateCurrentStack
(const $ Just $ oldStack { W.focus = parent }) (const $ Just $ oldStack { W.focus = parent })
$ onWorkspace "NSP" (W.delete' parent)
$ copyFloatingState childWindow parent $ copyFloatingState childWindow parent
$ ws { W.floating = oldFloating } $ ws { W.floating = oldFloating }
) )
XS.modify XS.modify $ removeSwallowed childWindow
(removeSwallowed childWindow . setStackBeforeWindowClosing Nothing XS.modify $ setStackBeforeWindowClosing Nothing
)
_ -> return () _ -> return ()
return () return ()
@ -53,13 +53,12 @@ swallowEventHook parentQueries childQueries event = do
(Just (parentPid : _), Just (childPid : _)) -> do (Just (parentPid : _), Just (childPid : _)) -> do
isChild <- liftIO $ fi childPid `isChildOf` fi parentPid isChild <- liftIO $ fi childPid `isChildOf` fi parentPid
when isChild $ do when isChild $ do
-- TODO use https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Layout-Hidden.html
windows windows
(updateCurrentStack (fmap (\x -> x { W.focus = childWindow })) (updateCurrentStack (fmap (\x -> x { W.focus = childWindow }))
. onWorkspace "NSP" (W.insertUp parentWindow)
. copyFloatingState parentWindow childWindow . copyFloatingState parentWindow childWindow
) )
XS.modify (addSwallowedParent parentWindow childWindow) XS.modify (addSwallowedParent parentWindow childWindow)
Hidden.hideWindow parentWindow
_ -> return () _ -> return ()
return () return ()
_ -> return () _ -> return ()
@ -88,13 +87,6 @@ copyFloatingState from to ws = ws
(M.lookup from (W.floating ws)) (M.lookup from (W.floating ws))
} }
onWorkspace
:: (Eq i, Eq s)
=> i
-> (W.StackSet i l a s sd -> W.StackSet i l a s sd)
-> (W.StackSet i l a s sd -> W.StackSet i l a s sd)
onWorkspace n f s = W.view (W.currentTag s) . f . W.view n $ s
-- | check if a given process is a child of another process. This depends on "pstree" being in the PATH -- | check if a given process is a child of another process. This depends on "pstree" being in the PATH
-- NOTE: this does not work if the child process does any kind of process-sharing. -- NOTE: this does not work if the child process does any kind of process-sharing.