mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
buggy boolean blindness
`ManageDebug` was continuing to report in the `logHook` even after the `manageHook` was done. In diagnosing this, I discovered that the original code was using a tuple of `Bool`s and not even a comment about which meant what. The code now uses a proper pair type, and dedicated `data`s for the two flags that make it clear what each means. This also fixed the bug, so apparently I had the `Bool`s confused somewhere. I also took the chance to clarify the documentation a little (a misleading "persistent", since it doesn't use persistent XS) and a few more cleanups. Also, it now logs all `manageHook` runs before the `logHook` in case multiple windows are opened.
This commit is contained in:
parent
923c5a2548
commit
80776d8969
@ -28,16 +28,17 @@ module XMonad.Hooks.ManageDebug (debugManageHook
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Prelude (when)
|
|
||||||
import XMonad.Hooks.DebugStack
|
import XMonad.Hooks.DebugStack
|
||||||
import XMonad.Util.DebugWindow
|
import XMonad.Util.DebugWindow
|
||||||
import XMonad.Util.EZConfig
|
import XMonad.Util.EZConfig
|
||||||
import qualified XMonad.Util.ExtensibleState as XS
|
import qualified XMonad.Util.ExtensibleState as XS
|
||||||
|
|
||||||
-- persistent state for manageHook debugging to trigger logHook debugging
|
-- state for manageHook debugging to trigger logHook debugging
|
||||||
newtype ManageStackDebug = MSD (Bool,Bool)
|
data MSDFinal = DoLogHook | SkipLogHook deriving Show
|
||||||
|
data MSDTrigger = MSDActivated | MSDInactive deriving Show
|
||||||
|
data ManageStackDebug = MSD MSDFinal MSDTrigger deriving Show
|
||||||
instance ExtensionClass ManageStackDebug where
|
instance ExtensionClass ManageStackDebug where
|
||||||
initialValue = MSD (False,False)
|
initialValue = MSD SkipLogHook MSDInactive
|
||||||
|
|
||||||
-- | A combinator to add full 'ManageHook' debugging in a single operation.
|
-- | A combinator to add full 'ManageHook' debugging in a single operation.
|
||||||
debugManageHook :: XConfig l -> XConfig l
|
debugManageHook :: XConfig l -> XConfig l
|
||||||
@ -61,7 +62,7 @@ debugManageHookOn key cf = cf {logHook = manageDebugLogHook <+> logHook cf
|
|||||||
-- final 'StackSet' state.
|
-- final 'StackSet' state.
|
||||||
--
|
--
|
||||||
-- Note that the initial state shows only the current workspace; the final
|
-- Note that the initial state shows only the current workspace; the final
|
||||||
-- one shows all workspaces, since your 'ManageHook' might use e.g. 'doShift',
|
-- one shows all workspaces, since your 'manageHook' might use e.g. 'doShift',
|
||||||
manageDebug :: ManageHook
|
manageDebug :: ManageHook
|
||||||
manageDebug = do
|
manageDebug = do
|
||||||
w <- ask
|
w <- ask
|
||||||
@ -69,31 +70,38 @@ manageDebug = do
|
|||||||
trace "== manageHook; current stack =="
|
trace "== manageHook; current stack =="
|
||||||
debugStackString >>= trace
|
debugStackString >>= trace
|
||||||
ws <- debugWindow w
|
ws <- debugWindow w
|
||||||
trace $ "new:\n " ++ ws
|
trace $ "new window:\n " ++ ws
|
||||||
XS.modify $ \(MSD (_,key)) -> MSD (True,key)
|
-- technically we don't care about go here, since only maybeManageDebug
|
||||||
|
-- uses it
|
||||||
|
XS.modify $ \(MSD _ go') -> MSD DoLogHook go'
|
||||||
idHook
|
idHook
|
||||||
|
|
||||||
-- | @manageDebug@ only if the user requested it with @debugNextManagedWindow@.
|
-- | @manageDebug@ only if the user requested it with @debugNextManagedWindow@.
|
||||||
maybeManageDebug :: ManageHook
|
maybeManageDebug :: ManageHook
|
||||||
maybeManageDebug = do
|
maybeManageDebug = do
|
||||||
go <- liftX $ do
|
go <- liftX $ do
|
||||||
MSD (log_,go') <- XS.get
|
MSD _ go' <- XS.get
|
||||||
XS.put $ MSD (log_,False)
|
-- leave it active, as we may manage multiple windows before the logHook
|
||||||
|
-- so we now deactivate it in the logHook
|
||||||
return go'
|
return go'
|
||||||
if go then manageDebug else idHook
|
case go of
|
||||||
|
MSDActivated -> manageDebug
|
||||||
|
_ -> idHook
|
||||||
|
|
||||||
-- | If @manageDebug@ has set the debug-stack flag, show the stack.
|
-- | If @manageDebug@ has set the debug-stack flag, show the stack.
|
||||||
manageDebugLogHook :: X ()
|
manageDebugLogHook :: X ()
|
||||||
manageDebugLogHook = do
|
manageDebugLogHook = do
|
||||||
MSD (go,key) <- XS.get
|
MSD log' _ <- XS.get
|
||||||
when go $ do
|
case log' of
|
||||||
trace "== manageHook; final stack =="
|
DoLogHook -> do
|
||||||
debugStackFullString >>= trace
|
trace "== manageHook; final stack =="
|
||||||
XS.put $ MSD (False,key)
|
debugStackFullString >>= trace
|
||||||
idHook
|
-- see comment in maybeManageDebug
|
||||||
|
XS.put $ MSD SkipLogHook MSDInactive
|
||||||
|
_ -> idHook
|
||||||
|
|
||||||
-- | Request that the next window to be managed be @manageDebug@-ed. This can
|
-- | Request that the next window to be managed be @manageDebug@-ed. This can
|
||||||
-- be used anywhere an X action can, such as key bindings, mouse bindings
|
-- be used anywhere an X action can, such as key bindings, mouse bindings
|
||||||
-- (presumably with 'const'), 'startupHook', etc.
|
-- (presumably with 'const'), 'startupHook', etc.
|
||||||
debugNextManagedWindow :: X ()
|
debugNextManagedWindow :: X ()
|
||||||
debugNextManagedWindow = XS.modify $ \(MSD (log_,_)) -> MSD (log_,True)
|
debugNextManagedWindow = XS.modify $ \(MSD log' _) -> MSD log' MSDActivated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user