xmonad / xmonad-contrib

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

Part of keymap is ignored in XPrompt #845

Closed dunric closed 7 months ago

dunric commented 8 months ago

Problem Description

When invoking shellPrompt dialog with promptKeymap config field set f.E. to emacsKeymap, all keys without a modifier(equal to 0) are ignored:

  ++
  map (first $ (,) 0) -- <key>
  [ (xK_Return, acceptSelection)
  , (xK_KP_Enter, acceptSelection)
  , (xK_BackSpace, deleteString Prev)
  , (xK_Delete, deleteString Next)
  , (xK_Left, moveCursor Prev)
  , (xK_Right, moveCursor Next)
  , (xK_Home, startOfLine)
  , (xK_End, endOfLine)
  , (xK_Down, moveHistory W.focusUp')
  , (xK_Up, moveHistory W.focusDown')
  , (xK_Escape, quit)
  ]

Steps to Reproduce

  1. modify XConfig for XPrompt to use emacs keymap myPromptTheme = def { promptKeymap = emacsLikeXPKeymap }
  2. assign XPrompt action to some keybinding ("M-<Escape>", shellPrompt myPromptTheme)
  3. invoke shellPrompt with above keybinding
  4. attempt to use any of keys without a modifier (ie. without controlMask, Mod1Mask) like Up, Down, Home, Right do not work

Configuration File

module Main (main) where

import XMonad
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Util.EZConfig

main :: IO ()
main = xmonad $ def
  { modMask = mod4Mask
  }
  `additionalKeysP`
  myKeymap

myKeymap =
  [  ("M-<Escape>",      shellPrompt myPromptTheme)
  ]

myPromptTheme = def { promptKeymap = emacsLikeXPKeymap }

EDIT: config file

geekosaur commented 8 months ago

I use emacsLikeXPKeymap here with git xmonad-contrib and the arrow keys work fine.

dunric commented 8 months ago

I use emacsLikeXPKeymap here with git xmonad-contrib and the arrow keys work fine.

Can you provide a minimal working example for shellPrompt?

In my case arrow keys do not work even with default defaultXPKeymap. I invoke shellPrompt with M-Escape, type-in some chars like "abcd", then press Left key and it does not move cursor at all. Arrow/Home/End/Delete etc however do work normally in Xorg session and other X11 or GTK+ applications.

additional info:

GHC 9.6.3 Xorg X server 21.1.9

geekosaur commented 8 months ago

My keybinding is at https://github.com/geekosaur/xmonad.hs/blob/hilfy-2023/xmonad.hs#L240 and myXPKeymap is defined at https://github.com/geekosaur/xmonad.hs/blob/hilfy-2023/xmonad.hs#L338-L341.

dunric commented 8 months ago

@geekosaur Thank you for the quick reply, however the same setup still does not make arrow keys work on my instance. I did even made a more reduced minimal example, where arrow keys do not work:

module Main (main) where

import XMonad
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Util.EZConfig

main :: IO ()
main = xmonad $ def
  { modMask = mod4Mask
  }
  `additionalKeys`
  [  ((mod4Mask, xK_p),      shellPrompt def)
  ]

I do remember when about a several months ago I have been using XMonad, arrow keys did worked normally in XPrompt. Weird.

geekosaur commented 8 months ago

Interestingly, that reduced example does not work in my testbed.

@slotThe, any ideas? I think you touched this code last.

slotThe commented 7 months ago

Whoops! This should be addressed by https://github.com/xmonad/xmonad-contrib/pull/850