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
|
||||
|
||||
import XMonad
|
||||
import XMonad.Prelude (when)
|
||||
import XMonad.Hooks.DebugStack
|
||||
import XMonad.Util.DebugWindow
|
||||
import XMonad.Util.EZConfig
|
||||
import qualified XMonad.Util.ExtensibleState as XS
|
||||
|
||||
-- persistent state for manageHook debugging to trigger logHook debugging
|
||||
newtype ManageStackDebug = MSD (Bool,Bool)
|
||||
-- state for manageHook debugging to trigger logHook debugging
|
||||
data MSDFinal = DoLogHook | SkipLogHook deriving Show
|
||||
data MSDTrigger = MSDActivated | MSDInactive deriving Show
|
||||
data ManageStackDebug = MSD MSDFinal MSDTrigger deriving Show
|
||||
instance ExtensionClass ManageStackDebug where
|
||||
initialValue = MSD (False,False)
|
||||
initialValue = MSD SkipLogHook MSDInactive
|
||||
|
||||
-- | A combinator to add full 'ManageHook' debugging in a single operation.
|
||||
debugManageHook :: XConfig l -> XConfig l
|
||||
@ -61,7 +62,7 @@ debugManageHookOn key cf = cf {logHook = manageDebugLogHook <+> logHook cf
|
||||
-- final 'StackSet' state.
|
||||
--
|
||||
-- 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 = do
|
||||
w <- ask
|
||||
@ -69,31 +70,38 @@ manageDebug = do
|
||||
trace "== manageHook; current stack =="
|
||||
debugStackString >>= trace
|
||||
ws <- debugWindow w
|
||||
trace $ "new:\n " ++ ws
|
||||
XS.modify $ \(MSD (_,key)) -> MSD (True,key)
|
||||
trace $ "new window:\n " ++ ws
|
||||
-- technically we don't care about go here, since only maybeManageDebug
|
||||
-- uses it
|
||||
XS.modify $ \(MSD _ go') -> MSD DoLogHook go'
|
||||
idHook
|
||||
|
||||
-- | @manageDebug@ only if the user requested it with @debugNextManagedWindow@.
|
||||
maybeManageDebug :: ManageHook
|
||||
maybeManageDebug = do
|
||||
go <- liftX $ do
|
||||
MSD (log_,go') <- XS.get
|
||||
XS.put $ MSD (log_,False)
|
||||
MSD _ go' <- XS.get
|
||||
-- leave it active, as we may manage multiple windows before the logHook
|
||||
-- so we now deactivate it in the logHook
|
||||
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.
|
||||
manageDebugLogHook :: X ()
|
||||
manageDebugLogHook = do
|
||||
MSD (go,key) <- XS.get
|
||||
when go $ do
|
||||
trace "== manageHook; final stack =="
|
||||
debugStackFullString >>= trace
|
||||
XS.put $ MSD (False,key)
|
||||
idHook
|
||||
MSD log' _ <- XS.get
|
||||
case log' of
|
||||
DoLogHook -> do
|
||||
trace "== manageHook; final stack =="
|
||||
debugStackFullString >>= trace
|
||||
-- see comment in maybeManageDebug
|
||||
XS.put $ MSD SkipLogHook MSDInactive
|
||||
_ -> idHook
|
||||
|
||||
-- | 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
|
||||
-- (presumably with 'const'), 'startupHook', etc.
|
||||
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