Discussion:
FVWM: Key for special window changes behaviour for others
Kalten
2011-06-05 13:02:08 UTC
Permalink
Hello!

I tried to stop FireFox from acting on <Crtl>+<Q> (lets use emacs
syntax: C-q) and quitting without asking me (I often hit this by
accident) (BTW: another solution is to use the AddOn ``Always Ask''[1]).

I used:
Key (Firefox*) Q A C Nop

To see the real behaviour I changed that to:
Key (Firefox*) Q A C Exec exec xterm

And, as expected, an xterm did open when pressing C-q while the mouse
cursor was over the FireFox window, and did not while being over other
windows. So far, so good. But then I noticed, that C-q did not work in,
e.g., ``git gui'' or ``Thunderbird'' any more, although it did not raise
my little xterm I did bind to it for FireFox for testing purpose.

Any idea why this happens and how to correct it?
FakeKeypress for all others did not help:
Key (Firefox*) Q A C Exec exec xterm
Key Q A C Exec exec FvwmCommand 'FakeKeypress modifiers 8 press q'

When deleting these changes by using:
Key (Firefox*) Q A C -
Key Q A C -
in the FvwmConsole(1) all works normally again.

Greetings,
Kalten

[1] https://addons.mozilla.org/de/firefox/addon/always-ask/
--
fvwm 2.7.0 compiled on Jun 4 2011 at 19:28:23
(ReadLine, XPM, PNG, SVG, Shape, XShm, SM, Xinerama, XRender, XFT, NLS)
Thomas Adam
2011-06-05 13:09:13 UTC
Permalink
Post by Kalten
Hello!
I tried to stop FireFox from acting on <Crtl>+<Q> (lets use emacs
syntax: C-q) and quitting without asking me (I often hit this by
accident) (BTW: another solution is to use the AddOn ``Always Ask''[1]).
Key (Firefox*) Q A C Nop
As a general rule, don't use a glob-pattern here, use the window class.

But it won't help you unfortunately, as Firefox won't accept or listen to
synthetic key events, which is what FVWM sends along to the application. So
you can't do what you want.
Post by Kalten
fvwm 2.7.0 compiled on Jun 4 2011 at 19:28:23
(ReadLine, XPM, PNG, SVG, Shape, XShm, SM, Xinerama, XRender, XFT, NLS)
Use FVWM 2.6.1, please. 2.7.0 doesn't technically exist anymore.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Kalten
2011-06-05 13:46:08 UTC
Permalink
Hello Thomas Adam!
Post by Thomas Adam
I tried to stop FireFox from acting on [...] C-q [...]
Key (Firefox*) Q A C Nop
As a general rule, don't use a glob-pattern here, use the window class.
You mean, what FvwmIdent(1) tells as ``Class''? So it would have been
Key (Firefox) Q A C Nop
without the ``*'', am I right?
Post by Thomas Adam
But it won't help you unfortunately, as Firefox won't accept or listen
to synthetic key events, which is what FVWM sends along to the
application. So you can't do what you want.
Key (Firefox) Q A C Exec exec xterm
and FireFox /did/ react as I wanted it to (as described in my last mail)
as it did not receive the C-q command but fvwm started an xterm instead.

What you mentioned seems to be the problem with
Post by Thomas Adam
Key Q A C Exec exec FvwmCommand 'FakeKeypress modifiers 8 press q'
and programs like e.g., ``git gui'' or ``Thunderbird''. As I had been
warned in the manual page of fvwm2(1) that FakeKeypress might not work
with all applications, I was not too surprised.
But the point remains, that:
Key (Firefox*) Q A C -
Key Q A C -
Key (Firefox) Q A C Exec exec xterm
does change the behaviour of e.g., ``git gui'' or ``Thunderbird'' by not
quitting when receiving C-q anymore and reacting properly again after we
add:
Key (Firefox) Q A C -
Post by Thomas Adam
fvwm 2.7.0 compiled on Jun 4 2011 at 19:28:23 [...]
Use FVWM 2.6.1, please. 2.7.0 doesn't technically exist anymore.
Are you kidding me? 2.7.0 is older than 2.6.1??? Who should suspect such
a thing? And the news[1] page tells us:
---SCHNIPP--- news[1]
Changes in beta release 2.7.1 (not yet released)
Changes in beta release 2.7.0 (15-Apr-2011)
Changes in stable release 2.6.1 (16-Apr-2011)
---schnapp---
I would have assumed, that 2.6.1 is (as told there) the stable version,
and 2.7.0 is the current beta, and 2.7.1 is the future beta version.
I am confused! One should note such things on the news[1] page! :-(

(BTW: on other machine using 2.5.31, no time to update yet: same
behaviour about the threads original matter here)

Regards,
Kalten

[1] http://www.fvwm.org/news/
--
fvwm 2.5.31 compiled on Apr 10 2011 at 16:51:28
(ReadLine, XPM, PNG, SVG, Shape, XShm, SM, Xinerama, XRender, XFT)
Thomas Adam
2011-06-05 14:18:56 UTC
Permalink
Post by Kalten
Hello Thomas Adam!
Post by Thomas Adam
I tried to stop FireFox from acting on [...] C-q [...]
Key (Firefox*) Q A C Nop
As a general rule, don't use a glob-pattern here, use the window class.
You mean, what FvwmIdent(1) tells as ``Class''? So it would have been
Key (Firefox) Q A C Nop
without the ``*'', am I right?
Yes.
Post by Kalten
Post by Thomas Adam
But it won't help you unfortunately, as Firefox won't accept or listen
to synthetic key events, which is what FVWM sends along to the
application. So you can't do what you want.
Yes.
Post by Kalten
Post by Thomas Adam
Key (Firefox) Q A C Exec exec xterm
Yes.
Post by Kalten
and FireFox /did/ react as I wanted it to (as described in my last mail)
as it did not receive the C-q command but fvwm started an xterm instead.
What you mentioned seems to be the problem with
Post by Thomas Adam
Key Q A C Exec exec FvwmCommand 'FakeKeypress modifiers 8 press q'
and programs like e.g., ``git gui'' or ``Thunderbird''. As I had been
warned in the manual page of fvwm2(1) that FakeKeypress might not work
with all applications, I was not too surprised.
Key (Firefox*) Q A C -
Key Q A C -
Key (Firefox) Q A C Exec exec xterm
does change the behaviour of e.g., ``git gui'' or ``Thunderbird'' by not
quitting when receiving C-q anymore and reacting properly again after we
Key (Firefox) Q A C -
I'm sorry, but you're not being clear enough about what's wrong, and what
you expect. Do you really mean to clear the binding with "-", or do you
really want to try and pass the key event through to the application to
handle instead with "--"? That's what I assumed you meant before -- which
won't work, due to the reasons I outlined before.

There is no difference in having a global binding such as:

Key Q A C Exec exec foo

and then trying to override that per-application to enable ^Q to work in
Firefox, as in:

Key (FireFox) A C --

Or using:

Key ... FakeKeyPress ...

The problem here is, like with FakeKeyPress, they rely on the underlying
application accepting synthetic key events, which some won't due because of
security risks.

This is what the man page attempts to outline.

To automate this more, here's what you could try:

DestroyModuleConfig A:*
*A: focus_change SomeFunction

AddToFunc StartFunction I Module FvwmEvent A

DestroyFunc SomeFunction
AddToFunc SomeFunction
+ I ThisWindow ("Firefox|WindowA|WindowB") Key Q A C -
+ I TestRc (NoMatch) Key Q A C Exec exec xterm

Where, you can see the list of names there as the class names of the windows
you want to match which should unbind ^Q from its original meaning so that
FVWM doesn't intercept it.

If the focused window then doesn't match the names you want, the key is
reset to some default action.

You can improve upon this slightly. The list of windows might grow, so I
would be more inclined to use style conditions to give each of the windows
an identifier, as in:

Style FireFox State 2
Style WindowA State 2
Style WindowB State 2

Then you can change "SomeFunction" to do:

DestroyFunc SomeFunction
AddToFunc SomeFunction
+ I ThisWindow (State 2) Key Q A C -
+ I TestRc (NoMatch) Key Q A C Exec exec xterm

Which then only matches those windows with a state bit of "2" in this case.
Post by Kalten
Post by Thomas Adam
fvwm 2.7.0 compiled on Jun 4 2011 at 19:28:23 [...]
Use FVWM 2.6.1, please. 2.7.0 doesn't technically exist anymore.
Are you kidding me? 2.7.0 is older than 2.6.1??? Who should suspect such
I am not kidding.
Post by Kalten
---SCHNIPP--- news[1]
Changes in beta release 2.7.1 (not yet released)
Changes in beta release 2.7.0 (15-Apr-2011)
Changes in stable release 2.6.1 (16-Apr-2011)
---schnapp---
I would have assumed, that 2.6.1 is (as told there) the stable version,
and 2.7.0 is the current beta, and 2.7.1 is the future beta version.
I am confused! One should note such things on the news[1] page! :-(
It's autogenerated, so no. The download links for it have been removed.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Kalten
2011-06-05 18:12:29 UTC
Permalink
Hello Thomas Adam!
Post by Thomas Adam
I'm sorry, but you're not being clear enough about what's wrong, and
what you expect.
Oh---sorry: as you are likely to have noticed, I am not of English
origin. Please be patient again; I will try to explain it in short
and---as I hope---more clearly:

I want FireFox to ignore C-q.
I used
Key (Firefox) Q A C Exec exec xterm
to achieve that. It works fine: C-q is not passed through to FireFox
any more.

Now to the thing that does not work any more after this command:
Although C-q has been changed for FireFox only, it has a side effect on
other programs as well (and I am pretty sure that that is an error).
The side effect is as follows: e.g. ``git gui'' or ``thunderbird'' do
not react in the proper way (quitting) any more, when they have the
focus, and one hits C-q. (At ``git gui'' one can see some flickering in
the text field for the commit message)
Post by Thomas Adam
Do you really mean to clear the binding with "-", or do you really
want to try and pass the key event through to the application to
handle instead with "--"?
I looked this up in the manual page fvwm2(1). According to it, ``This is
only a valid action for window-specific bindings''. Tried it out, and it
needs some ``(blaaa)''.
Key (*) Q A C --
Does not change the behaviour in the right way: If I use the sequence
Key (Firefox) Q A C Exec exec xterm
Key (*) Q A C --
Even FireFox does not react on C-q, and does not receive it at
all---just flicker like ``git gui'' (as described earlier here).
If I use the sequence
Key (*) Q A C --
Key (Firefox) Q A C Exec exec xterm
No change to not using ``--'' at all.
Post by Thomas Adam
That's what I assumed you meant before -- which won't work, due to the
reasons I outlined before.
Exactly ;-)
Post by Thomas Adam
[...] The problem here is, like with FakeKeyPress, they rely on the
underlying application accepting synthetic key events, which some
won't due because of security risks.
That I do understand.
Post by Thomas Adam
To automate this more, here's what you could try: [...]
*huch* I will look into that---not so easy for me ;-)

As I see it, the following does work as I want it too:
DestroyModuleConfig A:*
*A: focus_change SomeFunction

AddToFunc StartFunction I Module FvwmEvent A

DestroyFunc SomeFunction
AddToFunc SomeFunction
+ I ThisWindow (!"Firefox") Key Q A C -
+ I TestRc (NoMatch) Key Q A C Exec exec xterm

It seems to send C-q to every window that does not match the Class
``Firefox'', and at FireFox it starts the xterm ;-) (to be changed from
``Exec exec xterm'' to ``Nop'')

But why does this work differently to just using the command:
Key (Firefox) Q A C Exec exec xterm
??? It seems to me, that it should act in the equal way!
Post by Thomas Adam
[2.7.0 is older than 2.6.1 but news[1] sounds different]
It's autogenerated, so no. The download links for it have been removed.
Oh. May I suggest to correct that in the news[1] in some way?

Thank you very much for your help! Now I know the mechanism to do
exactly what I wanted to achieve :-)

Greetings,
Kalten

[1] http://www.fvwm.org/news/
--
fvwm 2.5.31 compiled on Apr 10 2011 at 16:51:28
(ReadLine, XPM, PNG, SVG, Shape, XShm, SM, Xinerama, XRender, XFT)
Thomas Adam
2011-06-05 18:27:51 UTC
Permalink
Post by Kalten
I want FireFox to ignore C-q.
I used
Key (Firefox) Q A C Exec exec xterm
This will work just fine because you're not asking FVWM to then try and send
the event to Firefox.
Post by Kalten
Key (*) Q A C --
Does not change the behaviour in the right way: If I use the sequence
Key (Firefox) Q A C Exec exec xterm
Key (*) Q A C --
Even FireFox does not react on C-q, and does not receive it at
all---just flicker like ``git gui'' (as described earlier here).
If I use the sequence
That's a bug. I'll commit a fix to CVS for this in due course.
Post by Kalten
Key (*) Q A C --
This is meaningless.
Post by Kalten
Key (Firefox) Q A C Exec exec xterm
??? It seems to me, that it should act in the equal way!
It's easier this way than trying to manage per-window bindings.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Thomas Adam
2011-06-05 19:24:57 UTC
Permalink
Post by Thomas Adam
Post by Kalten
I want FireFox to ignore C-q.
I used
Key (Firefox) Q A C Exec exec xterm
This will work just fine because you're not asking FVWM to then try and send
the event to Firefox.
Post by Kalten
Key (*) Q A C --
Does not change the behaviour in the right way: If I use the sequence
Key (Firefox) Q A C Exec exec xterm
Key (*) Q A C --
Even FireFox does not react on C-q, and does not receive it at
all---just flicker like ``git gui'' (as described earlier here).
If I use the sequence
That's a bug. I'll commit a fix to CVS for this in due course.
Or not. I mis-remembered here. So I looked at the code. Whenever one sets
a window-specific key-binding, FVWM then compares all the bindings it
receives, and always then sends the binding on, which can only be synthetic
at this point.

So even if you had this:

Key (Foo) Q A C Exec exec xteddy

Where previously ^Q on dear little xteddy did something, if he doesn't
respond to synthetic events, no amount of ^Qs will make him work until all
global window-bindings are cleared from FVWM.

There is nothing I can, or will do about this. The applications in question
must either learn to accept and understand synthetic key events (with an
appropriate option) or go back and see my previous solution, but this is
going to likely be tedious for you.

That's really my final word on this -- there's nothing more for me to do or
suggest to you.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Loading...