Locking the mouse

Hi there,
(please move if this post should be somewhere else :blush: )

I’m doing a config for my notebook at the moment and ran into a problem, maybe you can help me out.

What I want is basically a function, which locks the access to my mouse/touchpad as long as I’m not giving a key-sequence.
Roughly described I want something like this:
When FVWM starts, move the mouse to the bottom right corner, make it unmovable and send all mouseclicks into nirvana/ignore them. Then when I press i.e. CS+F5 the mouse should be unlocked and moved to the center of the screen and clicks should be available. If I press the combination again, the cursor should move back to b/r …
Right now I’m using MouseFocusClickRaises which maybe needs to be changed on the fly to make my thoughts above work.

Another little problem is that when I press Alt-Tab to change to another window, the cursor moves to the top-left corner of the newly activated window, where my close-button is, but I’d like it to be in the middle of the activated window, cause I accidently closed some windows by that.

Any ideas, hints links?


Well, moving the mouse cursor to the bottom right of the screen is fine:

AddToFunc StartFunction I CursorMove -0 -0

… keeping it there is another matter – the movement of the mouse isn’t controlled by FVWM – it’s part of the Xserver, so you’d have to find some other program to do that. Of course, the other option you have is to just not move the mouse. :stuck_out_tongue:

As for the mouse being ignored, you can do something like this:

DestroyFunc ClearMouseBindings
AddToFunc   ClearMouseBindings
+ I Mouse 0 A A Nop
Key F5 C A RePosMouse
+ I CursorMove 100 100
+ I RestoreMouseBindings 

… then:

DestroyFunc RestoreMouseBindings
AddToFunc  RestoreMouseBindings
+ I Mouse 1 1 .....
+ I Mouse 1 2 ......

I’ll let you write the toggle function – there’s plenty of examples on this forum.

You need to redefine the WindowListFunc function:

DestroyFunc WindowListFunc
AddToFunc  WindowListFunc
+ I Iconify off
+ I FlipFocus
+ I Raise
+ I WarpToWindow 50 50

– Thomas Adam

Hi ThomasAdam,

Hm, that could make it more complicated than I thought it would be, but thanks for the hint, I’m gonna see what I can do about this.

If it just would be that easy :confused:
The problem here is, that the touchpad is very close to the keys and that I sometimes acciedently hit it while typing, this does remind me of something: “It’s not a trick, it’s a Sony”, 11,1" notebook, not even enough space for 5mm between touchpad and space, anyway … :laughing:

Nice, that’s the way I wanted it to be, thanks.

Yep, that should be no problem, already got another function for toggling something.

D’oh, I always thougth that it’s maybe intendend that way and couldn’t be changed. Works like a charme, though.

Thanks Thomas for your help so far.
If someone has an idea/hint/link/program concerning the problem of locking the mouse, I’d very much apreciate it.


Well, I took a different approach and did this to lock it:

xset m 0 1

… however, it locks the mouse but the cursor will always be in the
top-left. Note that in my earlier post, I made a rather stupid error. In
order to warp the pointer to the bottom right – you’ll need WarpToWindow,
and just check that the window is the root window – something like:

WindowId root 1 WarpToWindow 100 100

… although given that isn’t going to be much use to you, might I suggest
that you ignore the placement of the cursor, and if you need to hide it,
install and run “unclutter”:

AddToFunc StartupFunc I Exec exec unclutter

To regain control of your mouse, you can then do:

xset m 0 0

I’ll let you slot the various parts together – although if you want help,
just shout.

– Thomas Adam

Another thing you may do is

To deactivate the mouse:

[code]WindowId root WarpToWindow 100 100
EdgeLeaveCommand E WindowId root WarpToWindow 100 100
EdgeLeaveCommand S WindowId root WarpToWindow 100 100

+ possible something to change focus policy


And to reactivate it just do

EdgeLeaveCommand E -
EdgeLeaveCommand S -
# + possible change focus policy