xmonad / xmonad-contrib

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

X.U.NamedScratchpad: Initialise if necessary #730

Closed slotThe closed 2 years ago

slotThe commented 2 years ago

Description

Fixes: https://github.com/xmonad/xmonad-contrib/issues/728

Since 3fc830aa09368dca04df24bf7ec4ac817f2de479, scratchpads are now added in namedScratchpadManageHook. This, however, means that we need some kind of MapRequestEvent to happen before processing scratchpads, otherwise the manageHook didn't run yet and our extensible state is being left empty. When trying to open a scratchpad right after starting xmonad—i.e., before having opened a window—this may not be the case.

Here is a small config to reproduce the problem. When first starting up xmonad, pressing M-m does not do anything since we haven't opened a window yet. After, e.g., spawning a terminal everything works.

import XMonad
import XMonad.StackSet
import XMonad.Util.EZConfig (additionalKeysP)
import XMonad.Util.NamedScratchpad

main :: IO ()
main = xmonad $ def
  { manageHook = manageHook def <> namedScratchpadManageHook scratchpads }
 `additionalKeysP` [("M-m", namedScratchpadAction scratchpads "xterm")]

scratchpads :: [NamedScratchpad]
scratchpads =
  [NS "xterm"
      "xterm"
      (className =? "XTerm")
      (customFloating $ RationalRect (1 / 6) (1 / 6) (2 / 3) (2 / 3))]

Checklist

exorcist365 commented 2 years ago

Thank you!

exorcist365 commented 2 years ago

It does indeed work.