Pass key press to application

I use the Meta modifier key for all my binds, however I would like these not to work when I’m using Emacs.
Based on what I read in the man pages and in other forum posts, I tried using this:

Silent Key x A M Silent ThisWindow (CurrentPage) Thumbnail
Silent Key (Emacs) x A M  --

Where -- is supposed to send the keypress to Emacs without thumbnailing the window, however this does not seem to work for me, as Emacs is still being thumbnailed and doesn’t register a M-x keypress.

Unsure if it is important or not, but the manual page puts the synthetic pass through event before the general one. Have you tried to put Key (Emacs) X A M -- before your other keybinding? If the keybinding is a linked list, it might just find the first binding that applies and use that, and since your global binding applies, run that before it gets to the window specific one.

You don’t need to put Silent before all your keybindings, this is really only useful for configs that bind keys that may or may not be available to just keep warnings down. But for your config, it really isn’t needed, and most keyboards should have an 'x key.

I’ve tried it both ways - no difference. I should say that using

Key x A M SomeFunction
Key (Emacs) x A M SomeOtherFunction

works the way I intend it to (only SomeOtherFunction runs when Emacs is focused), so I believe that the issue lies with --. Maybe a bug? I’m using Fvwm3 1.0.3, but I have the same issue in Fvwm2.
Thanks for letting me know about Silent though, I saw it in a config once and blindly applied it to all my binds.

It appears there was a bug in fvwm binding processing, -- was being treated as an unbind action.

Check out the branch js/passthrough-binding on github, I have fixed this, and -- now is a pass through action.

Though in my tests there are still issues, most likely in the fact synthetic events are just not well supported (and often ignored). So you can go try that branch, but your mileage may vary.

It could be you need to look for a different solution, maybe setup a Function that you can turn on/off these bindings that conflict with emacs. Then you can just turn off the bindings when working with emacs, and back on when needed. Here is an example of a function that may work for you, so you can temporally turn on your Thumbnail or other bindings, but they are off most the time to work in emacs.

https://www.fvwm.org/Archive/Faq/#how-can-i-define-emacs-type-multi-keystroke-fvwm-bindings

Interesting… but not ideal. Hopefully this will make it into the next release, but in the mean time I might just rebind Meta in Emacs itself to avoid any bind conflicts. Thanks for your efforts anyway.

I’m by no mean an expert on Emacs, but the most common key bindings that involve Meta are M-x and M-w. The use of Meta is not used as much as Control. I suppose you could be using a mode that makes extensive use of Meta. But if that’s not the case I would simply avoid using M-x and M-w as key bindings in fvwm to avoid any conflicts with Emacs.

Another temporary solution that does nor requires you to rebind Meta in Emacs would be to set your Focus to FocusFollowsMouse. This way if the cursor is not over Emacs any key bindings you currently have will not conflict with Emacs at all.

I just used M-x as an example, almost half of my keyboard is mapped to some action and there are plenty that overlap with Emacs. Regarding FocusFollowsMouse, I can’t see how that solves the issue, as I wouldn’t be able to interact with Emacs without it being focused, at which point the keybindings are active again.

@fuschu did you try the branch with the patch I submitted. I have tested it out and passthrough is working again (provided the application can accept synthetic events, which my understanding is emacs does).

Let me know if it worked for you.

@somiaj Sorry, I’d like to, but I don’t know how to compile FVWM from source… :sweat_smile:

It is quite easy to compile from source, but the patch has now been merged into master, so it will be in the next 1.0.4 release. You can test it out now if you want to learn to compile from source? What os do you use?

I’m on Void Linux, last time I tried compiling fvwm, I got an error and just gave up.

You most likely just need to install the build depends. I don’t know void linux so unsure on the quickest way to do that, or I guess just wait, but once you have the patch you should get pass through bindings working again, and emacs (haven’t tested) should work well with this.

I don’t mind waiting. Thanks for fixing the bug :+1:

Hi @somiaj, I can test it. I am an Emacs user. Will update you here.

It looks to me that the issue is still there. I used the latest master build. After adding the following keybindings to my config, when M-x (Alt-x) is pressed from Emacs, Fvwm iconifies the Emacs window. The key press is not passed on to Emacs.

Silent Key x A M Silent ThisWindow (CurrentPage) Thumbnail
Silent Key (Emacs) x A M  --
fvwm3 1.0.4 (1.0.3-105-gb7bbe2cb)
Arch Linux
Emacs 27.2

That works for me in xterm just fine using the same version, so unsure why it wouldn’t be working with Emacs. Since the window is being iconified this means that either Emacs is not correctly matching the class/resource/name of the window or maybe you didn’t restart your running version of fvwm3 before running this test.

My mistake’ sorry. You are right.
I did not realize that, the class name would be different. It has to be ‘Emacs-27.2’ in my case. I tried with it and can confirm that behavior is correct. Pressing M-x from Emacs run the emacs execute-extended-command, and from other applications iconify them.

Silent Key (Emacs-27.2) x A M  --

It is a nice post.Thank you.

My mistake’ sorry. You are right.
I did not realize that, the class name would be different. It has to be ‘Emacs-27.2’ in my case. I tried with it and can confirm that behavior is correct.

Sorry to raise an old post, but wanted to ask if the (window) is named in the binding, then does that mean the binding only works in that window class when it is in focus? Or is there a way to send the key binding to another window, maybe through a function, and have it execute a key stroke in that other window?