X.Prompt: Execute keypress when it has an action associated to it

It might be that the keypress does not have a valid stroke associated to
it, but is still bound to an action (e.g., xK_Left an friends). In this
case, we still want to execute it.

Closes: https://github.com/xmonad/xmonad-contrib/issues/845
This commit is contained in:
Tony Zorman 2023-12-16 14:42:30 +01:00
parent 5c30cadaf6
commit 00993d46fa

View File

@ -708,18 +708,21 @@ handleMain stroke@(keysym, keystr) = \case
getCurrentCompletions >>= handleCompletionMain Next getCurrentCompletions >>= handleCompletionMain Next
| (keymask, keysym) == prevCompKey -> | (keymask, keysym) == prevCompKey ->
getCurrentCompletions >>= handleCompletionMain Prev getCurrentCompletions >>= handleCompletionMain Prev
| otherwise -> unless (isModifier stroke) $ do | otherwise -> do
keymap <- gets (promptKeymap . config)
let mbAction = M.lookup (keymask, keysym) keymap
-- Either run when we can insert a valid character, or the
-- pressed key has an action associated to it.
unless (isModifier stroke && isNothing mbAction) $ do
setCurrentCompletions Nothing setCurrentCompletions Nothing
if keysym == modeKey if keysym == modeKey
then modify setNextMode >> updateWindows then modify setNextMode >> updateWindows
else handleInput keymask else handleInput keymask mbAction
event -> handleOther stroke event event -> handleOther stroke event
where where
-- Prompt input handler for the main loop. -- Prompt input handler for the main loop.
handleInput :: KeyMask -> XP () handleInput :: KeyMask -> Maybe (XP ()) -> XP ()
handleInput keymask = do handleInput keymask = \case
keymap <- gets (promptKeymap . config)
case M.lookup (keymask,keysym) keymap of
Just action -> action >> updateWindows Just action -> action >> updateWindows
Nothing -> when (keymask .&. controlMask == 0) $ do Nothing -> when (keymask .&. controlMask == 0) $ do
insertString $ utf8Decode keystr insertString $ utf8Decode keystr