Re: [xmonad] submapDefault patch - default action for submaps

Hello Stacey and the list since this includes a patch.
I could not reproduce the behaviour, but I can clearly see where it
fits in. The problem for me is that I cannot currently change the
repeat rate (because of a bug in evdev) and my repeat rate is
obviously too low for the bug to appear, but that is another issue.
The problem is as you stated that ungrab-grab is run between key
presses, so I moved the ungrab till after the selected command has
been run. This should result in "grab new"-"ungrab old" behaviour and
fix your problem, I think, but I haven't actually reproduced the bug
so please check if this works and report the success or failure.
It all seems to work for me, but I would like some feedback from
someone a little bit more experienced than me since I'm rather new to
haskell and xmonad myself.
First question: It is okay to run grabKeyboard in a nested way like this, right?
Second question: I dunno, is it just me, or is
grabKeyboard/ungrabKeyboard not defined ANYWHERE? It must come from
somewhere... But I could not find it when I tried to follow the import
chain.
/Anders Engström
2009/4/26 Stacey Sheldon
I'm trying to use the submapDefault functionality that you contributed to XMonad, and I'm running into a small problem with it. Any assistance that you can offer on this would be very much appreciated. If there are any additional details that you require, I'd be happy to provide them.
[Goal]
I want to trigger a sticky submap, and then be able to move a floating window around with the arrow keys. When I hit enter or escape, I want to return to the normal keybindings. The basic functionality works as expected so I think I've got the various moving parts connected properly.
[Problem]
When I use the arrow keys to move the windows around, I typically hold down the arrow key until the window ends up in the right position. I've noticed that some of the repeats of the arrow key are leaking through to the focused window rather than being captured by the submap. This is especially noticeable if I switch to using vi keys (h,j,k,l) rather than the arrow keys to push the floating windows around. I then get a string of these leaked h's in the focused window.
I suspect this is caused by the ungrabKeyboard that (I think) happens between handling one keypress and handling the next (repeating) one. If the ungrab only occurred once the "exit" key had been pressed, maybe this problem would go away.
I'm not a complete haskell noob but I still don't quite have a handle on how monads work. I have no idea how to fix this.
[Context]
I'm fairly certain that the issue that I'm seeing is unrelated to the particular versions that I'm using but I'll give you the context anyway. I'm using XMonad 0.8-1 on Ubuntu Intrepid (8.10) as the base version. I've pulled the definition for submapDefault from the latest darcs revision into my xmonad.hs file since your patch isn't in the ubuntu release.
I'm using submapDefault like this in my xmonad.hs file:
entersub = submapDefault entersub sublist sublist = M.fromList $ [ -- Window floating stuff ((0, xK_Return), return ()) , ((0, xK_Escape), return ()) , ((0, xK_t ), withFocused $ windows . W.sink) , ((0, xK_Left ), (withFocused (keysMoveWindow (-20,0))) >> entersub) , ((0, xK_Right ), (withFocused (keysMoveWindow (20,0))) >> entersub) , ((0, xK_Up ), (withFocused (keysMoveWindow (0,-20))) >> entersub) , ((0, xK_Down ), (withFocused (keysMoveWindow (0,20))) >> entersub) ]
If you've got the time to look at this, I'd be happy to try any suggestions for how to fix this.
Thanks.
Stacey.

On Apr 26, 2009, at 13:36 , Anders Engström wrote:
First question: It is okay to run grabKeyboard in a nested way like this, right?
Nested grabs should be okay.
Second question: I dunno, is it just me, or is grabKeyboard/ungrabKeyboard not defined ANYWHERE? It must come from
http://hackage.haskell.org/packages/archive/X11/1.4.5/doc/html/Graphics-X11-... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

I just noticed that my first reply didn't make it back to the list since I wasn't subscribed. I can confirm that the submapDefaultFixLeak patch patch fixes the issue for me. I no longer see keypresses leaking from the submap. In case anyone is interested, here are my keybindings for moving/resizing floating windows. Just invoke floatsub from some initial keybinding and then use arrows or vi or emacs bindings to move/resize the windows. Hit enter or escape to break out of the submode. floatsub = submapDefault floatsub floatsublist floatsublist = M.fromList $ [ -- Window floating stuff ((0, xK_Return), return ()) , ((0, xK_Escape), return ()) , ((0, xK_t ), withFocused $ windows . W.sink) -- arrow bindings , ((0, xK_Left ), moveFloatLeft) , ((0, xK_Right ), moveFloatRight) , ((0, xK_Up ), moveFloatUp) , ((0, xK_Down ), moveFloatDown) , ((shiftMask, xK_Left ), shrinkFloatRight) , ((shiftMask, xK_Right ), expandFloatRight) , ((shiftMask, xK_Up ), shrinkFloatBottom) , ((shiftMask, xK_Down ), expandFloatBottom) -- vi bindings , ((0, xK_h ), moveFloatLeft) , ((0, xK_l ), moveFloatRight) , ((0, xK_k ), moveFloatUp) , ((0, xK_j ), moveFloatDown) , ((shiftMask, xK_h ), shrinkFloatRight) , ((shiftMask, xK_l ), expandFloatRight) , ((shiftMask, xK_k ), shrinkFloatBottom) , ((shiftMask, xK_j ), expandFloatBottom) -- emacs bindings , ((0, xK_b ), moveFloatLeft) , ((0, xK_f ), moveFloatRight) , ((0, xK_p ), moveFloatUp) , ((0, xK_n ), moveFloatDown) , ((shiftMask, xK_b ), shrinkFloatRight) , ((shiftMask, xK_f ), expandFloatRight) , ((shiftMask, xK_p ), shrinkFloatBottom) , ((shiftMask, xK_n ), expandFloatBottom) ] where moveFloatLeft = (withFocused (keysMoveWindow (-20, 0))) >> floatsub moveFloatRight = (withFocused (keysMoveWindow ( 20, 0))) >> floatsub moveFloatUp = (withFocused (keysMoveWindow ( 0,-20))) >> floatsub moveFloatDown = (withFocused (keysMoveWindow ( 0, 20))) >> floatsub shrinkFloatRight = (withFocused (keysResizeWindow (-10, 0) (0,0))) >> floatsub expandFloatRight = (withFocused (keysResizeWindow ( 10, 0) (0,0))) >> floatsub shrinkFloatBottom = (withFocused (keysResizeWindow ( 0,-10) (0,0))) >> floatsub expandFloatBottom = (withFocused (keysResizeWindow ( 0, 30) (0,0))) >> floatsub Note that this only works properly with the submapDefaultFixLeak patch from Anders: http://www.haskell.org/pipermail/xmonad/2009-April/007821.html Stacey.
participants (3)
-
Anders Engström
-
Brandon S. Allbery KF8NH
-
Stacey Sheldon