Can FVWM pass a button-event as keypress to an app? [SOLVED]

I was wondering, if using FVWM I can ditch imwheel for mapping mouse-button-events to keypress-events.

I know, it is no problem, to bind mouse buttons to actions, but this is not about actions to be performed by FVWM, but actions to be processed by applications.

In particular I want mouse-buttons 8 & 9 to act as XF86Forward / XF86Back or Alt_L|Left / Alt_L|Right in either all or certain applications, but I still want to be able to use that buttons for other things, when focus is not on an application window.

Is there a way to do this?

In favour of using xmodmap, yes.

But then you see, If FVWM has nothing to do for a binding, it will pass it to the underlying application to deal with it. If the application doesn’t know what to do with it, nothing happens.

– Thomas Adam

I was more thinking of an interaction between FVWM & apps concerning keybindings.

I am actually using 6thpink’s fabulous config, and he has the following in his keybindings-file for mouse-buttons 8 & 9:Silent Mouse 8 W N user_Move Silent Mouse 9 W N user_Resize
What if I want to keep these settings for general application windows, but want do pass these mouse-button-events as keypress Alt_L|Left / Alt_L|Right to Firefox, and as XF86Forward / XF86Back to Konqueror?

Isn’t this a chain of processing mouse-button-events, that has to be initiated by FVWM (so first checking the event and context, to either act or pass a mapped keypress on to the specified apps), and can that even be done at all?

Then you would use window-specific bindings.

Mouse (name_of_window) some_binding some_modifier --

The “–” part says to pass the event through to the underlying named application.

See above. See also:

starshine.org/xteddy/thomas/~n6t … ioning.txt

– Thomas Adam

As Thomas said, look into window specific bindings and the “–”.

There are already a few examples of window specific bindings in the bindings.config file, though I just use them to cancel bindings on certain windows, for example, to avoid closing the kuake panel (alt+f4) and to avoid the fullscreen binding in the same panel (win+enter).

Ah, I see, the “–” was the missing info. Ok, this way the event is passed on to the app and I would just need a solution for mapping the mousebutton to a keypress or key-combination as mentioned. Any exact idea how to do this? xmodmap can be used to reorder mousebuttons, and assign keycodes to keymap, but it seems not to be able to do something like “button8 = XF86Back and Alt_L|Left”.

The ideal solution would be, if FVWM could just do the mapping before passing it to the app window, so something likeMouse (firefox) 8 W N -- "Alt_L|Left" Mouse (konqueror) 8 W N -- "XF86Back"
Even if there should be a way to use xmodmap to accomplish the mentioned goal, it would have to either use a primary + alternate keybinding (like in KDE), or a detection of the app to apply to (firefox the one key-combination, konqueror the one keypress).

I am sorry, if this goes OT, or if it should be obvious that FVWM can’t or shouldn’t handle such matter, but I am just looking for an easy to apply solution for this problem, I am neither a programmer, nor do I know much about the configurability and capability of FVWM by now (still being a total newbie).

Well, it can, but they’re typically esoteric uses. I’m still not fully understanding what it is you’re wanting to do though.

No – that’s the job of the XServer.

– Thomas Adam

Can’t believe my intent is that uncommon :wink:

It’s quite simple: Mouse buttons 8 & 9 (usually the thumb buttons on the side) cause buttons events which normally are not automatically assigned to functions by the usual WM’s and DE’s. I am used to use these buttons for the Back & Forward functions in webbrowsers (back to last page & forward to next page), which are accessible by keybindings (XF86Back & XF86Forward in Konqueror, Alt_L|Left & Alt_L|Right in Firefox). Until now (means in other DEs and WMs) I just used imwheel to establish this functionality, but I thought because these buttons can be used directly in FVWM, there is a way of replacing imwheel with FVWM functionality.

Assigning keymap-events to mouse-button events does not seem to be a job of the xserver, because the xserver only enables the use of mouse button events, but there is no connection to the keymap (you can only assign a keycode to keymap, but no mouse button to keymap with xmodmap, AFAIK), that’s why there is imwheel available in the first place.

So none of the other WMs, DEs or apps even can use these extra-mouse-buttons out of the box, except FVWM, that’s why I thought it would be logical to make enhanced use of it, by not only using these button events for FVWM actions, but also to allow forwarding and mapping to key-events for apps, which are generally not aware of these additional mouse-button-events. As seen so far, the forwarding part is there, but not the mapping-part, for which again another app has to be used.

The problem could be the interaction, if another app like imwheel has to be used for this, because I don’t know if imwheel takes the mouse button events exclusively then, making FVWM not aware any more about these buttons, which means either have these buttons used in apps (which imwheel), or by FVWM, but not both. If that should be true, I hope you see the point, why it would be a good idea for FVWM to handle these events with mapping to keyevents for apps.

Right – so what you’re saying is that if you click button 8 or button 9 on your mouse, then you want different behaviour depending whether or not the underlying window is, say, FireFox, or or nothing at all if it is just to be used via FVWM. Again, that’s possible with window-specific bindings.

Window-specific key-bindings work in FVWM by FVWM doing the following (I’ll even draw you a picture):

+-----------++				+-----------------+
|  Xserver   |------------->|   FVWM catches  |
| sends event|				|  event          |
+------------+              +-----------------+
									|
									|
									|
			Yes				+-----------------+					No
	v----------------------	|  Is the binding |--------------------------------v
+------------+				| trapped by FVWM?|						+-------------------+      No
| Perform    |				+-----------------+			Yes			| Is it window      |-----------------------v 
| function   |										v--------------	| specific?         |				+---------------+
+------------+								+-----------+			+-------------------+               | If binded for |
											| Perform   |                                               | FVWM perform  |
											| Action if |   Pass to App?								| action        |
											| not propa-|----------------v                              +---------------+
											| gated.    |			+------------------+						|
											+-----------+           | App. receives	   |						| else
											                        | Synthetic event  |						|
																	+------------------+			+--------------------+
																									| Discard event; do  |
																									| nothing.			 |
																									+--------------------+

A synthetic event is a fake event, if you like. It’s what the application is expecting to receive. Note that it is always up to the application as to whether or not it knows how to handle the event. If it doesn’t, then it can’t peform its operation. Now, if I understand what you want to do, it’s something like this:

Mouse 8 A N SomeAction
Mouse 9 A N SomeAction

Which in the general sense will perform ‘SomeAction’ whenever the mouse button 8 or 9 is used anywhere in FVWM. Of course, in mitigating this you can tell FVWM that actually, you want the events the application expects to react to when button 8 and 9 is issued, to be used normally. Hence in that situation, you’d have:

Mouse (Firefox-bin) A N --
Mouse (Firefox-bin) A N --

And here you fall apart at the first hurdle, because… and this is the key point: What you think of as actions from mapping of keys is meaningless. The names (XF86Back, XF86Forward) are just a means of referencing a key. That does not imply the action the key has whatsoever – all it does is make X11 realise the key is valid and that an application may or may not expect the symcode to mean something when it is pressed – again, I’ll reiterate this: the application decides whether or not or how or why or if it will or can or knows how to react to a key-press. FVWM has no interference in this unless told to do so (see above – the diagram is true for key-bindings as well, save for how the application and XServer communicate in terms of knowing whether a key was pressed with a modifier, for instance).

– Thomas Adam

Yes, I know the diagram is screwed – but I am sure you can piece it together yourself without too much effort.

– Thomas Adam

Thanks for clarifying this matter, but nevertheless I still have no idea how to solve the issue.

I know now, how either FVWM can act on the button action by itself, or how to pass the button action on to specified apps.

What I still don’t know is, if I let FVWM pass the button action on, how to generate a fake-keypress-event from that mouse-button-event for the app. The app (for this example firefox) can not handle mouse-button 8 or 9, but keybindings ALT+LEFT and ALT+RIGHT instead. imwheel does that job, it captures the mousebuttons I want (in my case buttons 8 & 9), and maps their events to keypress-events (ALT+LEFT & ALT+RIGHT), but as assumed before, imwheel (which runs as a daemon) not only watches the specified mouse button events, but grabs them, which means, when imwheel is running, FVWM does not recognise the specified buttons any more.

That’s what I mentioned before: Not using imwheel, I can let FVWM handle these mouse-button-events, but not any apps (because there are no apps, that act on mouse-buttons 8 & 9), and when using imwheel, apps can act on these mouse-button-events, but these mouse-button-bindings (8 & 9) do not work any more in FVWM. This way, it’s one or the other, but not both.

I only know of imwheel capable of doing this job, so I am pretty stuck here.

If anybody knows a way out of this, please let me know.

Redesign everything to suite your whim.

So you could use:

Mouse (some_window_name) 1 A W FakeKeyPress press KeyName

– Thomas Adam

Wow, it can be THAT easy, thanks a lot, thomasadam, FakeKeyPress is exactly what I was looking for! :slight_smile:

Really didn’t think, there would be such a command, but I have to admit I am really bad at reading man-page (will have to work on that).