Discussion:
FVWM: how to? FakeClick for Middle button
Spoofing
2013-01-25 15:23:01 UTC
Permalink
sup.

I like to use "Shift + Insert" for paste text from clipboard everywhere,
and for example, when I run Firefox, want to press "Shift + Insert" for
open URL from clipboard, like the mouse middle (button 2) click.

Key Insert A S FakeClick depth 2 press 2 wait 250 release 2

doesn't work, and also try to change depth, but nothing happens...

how to simulate mouse middle click button with Shift + Insert? :)
Jaimos F Skriletz
2013-01-25 17:26:10 UTC
Permalink
Post by Spoofing
sup.
I like to use "Shift + Insert" for paste text from clipboard everywhere,
and for example, when I run Firefox, want to press "Shift + Insert" for
open URL from clipboard, like the mouse middle (button 2) click.
Key Insert A S FakeClick depth 2 press 2 wait 250 release 2
doesn't work, and also try to change depth, but nothing happens...
how to simulate mouse middle click button with Shift + Insert? :)
First, not all applications like fake (or synthetic) events, and as per
the man page FakeClick and FakeKeyPress are for debugging fvwm and not
going to work in all situations. So your approach should be rethought.

Second it is not firefox that 'pastes' when you click the middle mouse
button. It is xorg that intercepts the middle mouse click and then sends
the resulting paste to the window. So sending the middle mouse button
click to the root window or the firefox window (or any other window)
will note generate the paste event. Firefox does not know to paste when
it receives a middle mouse click.

On the other hand firefox and many applications honor the ctrl-V paste
button. In my testing I got

FakeKeyPress depth 2 modifiers 8 press v

To work just fine and correctly paste something into chromium (provided
I copied with ctrl-C from an application first).

So that may work for you, but now you need to get a clipboard manager to
keep the clipboard and cutbuffer in sync. It looks like something like
'autocutsel' may do that for you. Though it could be possible that there
are more advanced clibboard managers and you could use one of those to
not only keep the two methods of copying/pasting in sync can probably
set up custom key bindings to send the clibboard to the desired window.
This is the direction I would look. It looks like clipit may have that
functionality.

Using FakeKeyPress to make shift-insert work like ctrl-V will only work
for applications which already honor ctrl-V so you are just changing the
default. It will have no effect (or even other effects) because each
application will honor the ctrl-V how ever it deems is correct. So even
though that works in some applications it may not do what you want.

So I think getting a clipboard manager that has the feature to set up a
keybinding would be the direction to go (note I have never messed with
them, so I am unsure what sort of things the clipboard managers can do).

jaimos
Chris Siebenmann
2013-01-25 18:09:16 UTC
Permalink
| Second it is not firefox that 'pastes' when you click the middle mouse
| button. It is xorg that intercepts the middle mouse click and then
| sends the resulting paste to the window. So sending the middle mouse
| button click to the root window or the firefox window (or any other
| window) will note generate the paste event. Firefox does not know to
| paste when it receives a middle mouse click.

This portion is not correct. Neither the X server nor the window
manager intercept middle mouse clicks and turn them into magic paste
events (or into streams of characters). Pasting is entirely handled
by the program involved and Firefox really does receive a middle
mouse button click event[*] and then invoke its own code to paste
stuff. Programs can and do do entirely different things in response to
middle mouse buttons (for example, I am writing this email in a program
that does something different with it).

- cks
[*: actually it doesn't even get a click event; it gets a button-down
and then a button-up event in very close succession. Interested
parties can use 'xev' to see exactly what event streams the X server
sends in various circumstances.
]
Jaimos Skriletz
2013-01-25 21:17:03 UTC
Permalink
This post might be inappropriate. Click to display it.
Chris Siebenmann
2013-01-25 22:04:38 UTC
Permalink
| First xorg has three buffers, primary, secondary and clipboard. The
| primary gets used in the select/middle mouse paste, while the
| clipboard gets used by some programs with ctrl-c/ctrl-v is the
| standard. So depending on which buffer you want to paste from adjust
| the following.

The easy rule of thumb for keeping the selections straight is that if
you just select text it becomes the primary selection (for example, if
you triple-click the URL bar in Firefox or sweep out some text in your
terminal program) while if you actually do an explicit 'copy' action (eg
Ctrl-C or picking Copy from a menu) it becomes the clipboard selection.
Most of the time, making something the clipboard selection also makes it
the primary selection.

Middle mouse button paste usually comes from the primary selection.
Explicit Ctrl-v or Paste actions from menus usually come from the
clipboard selection.

(All of this is implemented by individual programs, so every so often
you will stumble over one that has decided to go its own way and do
something completely different.)

One little gotcha about selections in general: all selections are
held by the program that created them, and they vanish if you exit the
program. If you select some text in Firefox and then quit Firefox before
you paste it into anything, poof, it's gone. This is true even if you
used Copy/Ctrl-c.

(And if Firefox is being hellaciously slow you may not be able to paste
that text you selected in it until it recovers.)

- cks
Thomas Adam
2013-01-25 23:44:54 UTC
Permalink
Post by Chris Siebenmann
| First xorg has three buffers, primary, secondary and clipboard. The
| primary gets used in the select/middle mouse paste, while the
| clipboard gets used by some programs with ctrl-c/ctrl-v is the
| standard. So depending on which buffer you want to paste from adjust
| the following.
The easy rule of thumb for keeping the selections straight is that if
you just select text it becomes the primary selection (for example, if
you triple-click the URL bar in Firefox or sweep out some text in your
terminal program) while if you actually do an explicit 'copy' action (eg
Ctrl-C or picking Copy from a menu) it becomes the clipboard selection.
Most of the time, making something the clipboard selection also makes it
the primary selection.
Just install 'parcellite'; in its prefences settings, set it to "Synchronise
clipboards" and then you'll never have to worry again.

-- Thomas Adam
--
"It was the cruelest game I've ever played and it's played inside my head."
-- "Hush The Warmth", Gorky's Zygotic Mynci.
Loading...