xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
588 stars 274 forks source link

`debugManageHookOn` doesn't turn off #706

Closed geekosaur closed 2 years ago

geekosaur commented 2 years ago

(this is basically a reminder for myself)

Problem Description

I used X.H.ManageDebug to debug an issue with a VirtualBox window going into a tight loop on startup (which I still haven't solved, but it appears to have fixed itself in the meantime, possibly because it's some first-run greeting window). Afterward I noticed that the logHook portion continues to report on every invocation of the logHook instead of shutting itself off after the first run.

Steps to Reproduce

  1. Configure your xmonad.hs with debugManageHookOn
  2. Trigger it with the defined key sequence
  3. Note that it continues to report after the window appears, every time the logHook runs

Configuration File

Please include the smallest full configuration file that reproduces the problem you are experiencing:

module Main (main) where

import XMonad
import XMonad.Hooks.ManageDebug

main :: IO ()
main = xmonad $ debugManageHookOn "M-S-d" def

Checklist

geekosaur commented 2 years ago

It's only the logHook that reports repeatedly… but it doesn't start until debugManageHookOn has been triggered, so it's not simply ignoring the flag in XS. Nor does the manageHook part continue to report, so it's clearly turning the XS flag off. This seems odd.

geekosaur commented 2 years ago

Okay, code answered that. It's two flags instead of one, controlling respectively the logHook and manageHook. So now I have to remember why I did it that way; in particular, it may manage multiple windows before the logHook and can't know which is wanted, so it should log both. I think I simplify this to a single Bool which is enabled in the key event and disabled in the logHook.

…Oh wait: separate is because of the always-ManageDebug case, right.

Oddly, it looks like the code does the right thing (checking and disabling the logHook debugging flag.

It's also the definition of Boolean blindness, so I may rewrite just to make things more obvious. That might even fix the bug.

geekosaur commented 2 years ago

Also the note above about multiple managed windows means the logHook should disable both flags instead of the manageHook disabling its flag.

geekosaur commented 2 years ago

For the record, the flags are in order the logHook trigger (always activated by the manageHook) and the key trigger for the triggered manageHook (ignored if the unconditional manageHook is used).

geekosaur commented 2 years ago

Well, that seems to have fixed it, so I presume I had some confusion about which Bool was which somewhere.