[SOLVED]How to center the mouse pointer?

When i use Alt + Tab to switch programs , the mouse pointer alway moves to the left top corner( the title-bar button ).My wireless mouse need click to wake up. I rarely use mouse.After using keyboard for a while , if have to use mouse, click or rolling the mouse wheel always pop up a menu ,and , sometimes i close the program mistakenly .

I run conky in a small window to show my computer’s statics. i want to press some key to show the window, release hide the window.I do not know how to do that.

Thank you for the extremely fast , flexible program !

This is because Alt-Tab invokes the WindowListFunc which invokes a command “WarpToWindow 5p 5p” which places the cursor at the top-left corner of the window. What you can do to mitigate that is to, say, place it in the centre.

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

So you want some toggling action?

DestroyFunc ToggleConky
AddToFunc ToggleConky
+ I None (conky, CirculateHit) Exec exec conky
+ I Next (conky, CirculateHit) Close

Key SomeKey A MC ToggleConky

Where “SomeKey” is the key you want. The above binding also ensures you press Alt and Control together with SomeKey to activate it – this is a useful decision to make in situations where you want the binding to apply anywhere.

– Thomas Adam

After inserted your code into ~/.fvwm/.fvwmrc2 , the “How to center the mouse pointer” (how to place the cursor in the centre) has been solved. :smiley:

And , i can exec and close conky by Super_R+Tab now.And , i think i can
modify it to hide and show .

I use this approach for my kuake urxvt+screen, but it should work exactly the same for conky or whatever:

# -1 hidden, any other value means it is visible
SetEnv kuake_pos        -1

DestroyModuleConfig FvwmKuakeitor: *
*FvwmKuakeitor: Frame 0
*FvwmKuakeitor: Font $[ThemeFont]
*FvwmKuakeitor: Colorset 9
*FvwmKuakeitor: Rows 21
*FvwmKuakeitor: Columns 2
*FvwmKuakeitor: (2x20, Padding 3 0, Swallow (Respawn, UseOld, NoClose) 'tabbed_URxvt' 'Exec exec urxvt -name tabbed_URxvt -e screen -S Kuake -R')
*FvwmKuakeitor: (2x1, Padding 10 0, Icon terminal.png, ActiveIcon terminal_bright.png, PressIcon terminal_pressed.png, \
    Title (Side,Left) "Quakeitor, by Johnny Valderrama's Inc. (c)", Action (Mouse 1) toggle_kuakeitor)
Piperead 'echo SetEnv i $(($(($[vp.height] - $[bottom_margin]))/2))'
Piperead 'echo SetEnv j $(($[vp.width] - 2* $[small_margin]))'
Module FvwmButtons -g $[j]x$[i]+0-10000 FvwmKuakeitor

DestroyFunc toggle_kuakeitor
AddToFunc toggle_kuakeitor
+ I Test (EnvMatch kuake_pos -1) All (FvwmKuakeitor) AnimatedMove +$[small_margin]p +0p
+ I Test (EnvMatch kuake_pos -1) All (FvwmKuakeitor) Focus
+ I Test (EnvMatch kuake_pos -1) All (FvwmKuakeitor) WarpToWindow 90 90
+ I Test (EnvMatch kuake_pos 1) All (FvwmKuakeitor) AnimatedMove +$[small_margin]p -10000p
+ I Piperead 'echo SetEnv kuake_pos $((${kuake_pos} * -1))'

Key     z       A   4   toggle_kuakeitor

In case it helps.

I have learned two things from your code
1.using shell environment variable to store window states
2.place the window outside the screen to hide it(?).

Conky is a strange program . The title-bar keeps gray even i click it.I can move it,maximize it . “+ I All(conky) SomeCommand”, SomeCommand never get called.

 My FVWM version is 2.5. The conky window properties are
                     Focus Policy : No Input
                            -Input Field: False
                            -WM_TAKE_FOCUS: Absent

Except unfortunately it’s not a good lesson to learn. At no point in that function is the environment variable cleared - it shouldn’t even be used in the first place. You could just set a State on the window, although what would be easier is if you used this:

DestroyFunc SomeFunc
AddToFunc    SomeFunc
+ I Next (some_window, !CurrentPage, !Visible) AnimatedMove m+0 m+0
+ I TestRc (Match) Next (some_window) Raise
+ I TestRc (Match) Break
+ I TestRc (NoMatch) Next (some_window) AnimatedMove -5000 -5000

That way, there’s no need to hold any values, or remember to unset any environment variables, etc.

It doesn’t request focus in its own window.

– Thomas Adam

It would not work if that variable was cleared in that function. In fact, that variable NEEDS a value from the start of the session. Otherwise, you don’t have the actual stated of the window, and the rest of the code is useless.

I like your alternative idea, though, and will play with it. It is more efficient (as usual), so, if there is no problem with it, I might change my kuake to use this. Thanks.

I love the FVWM configure file . it likes a nature language ,not C or C++.

Thanks :smiley:. :smiley:.

Do not want to create one more topic with the same name, so i will write here.
I need to move mouse pointer to the some(static) position on the screen (the screen can be with windows or without).
For example i have 1280x1024 resolution of screen and i need function that will move pointer to position 1000x800 pixels.
In documentation i only find “CursorMove” function, but it moves pointer from current position to some % or pixels up or down, and is there some function which will just set pointer to position i need?
Or can i use CursorMove for this, but with some math calculations of pixels to which i need to move (current position - needed position)?

When you specify a coordinate such as “fooXbar”, you’re really trying to translate those to co-ordinates anyway, so CursorMove actually helps you here. So work out the static location in pixel terms.

– Thomas Adam

how is that? CursorMove 50p 50p ? But it just move the pointer from current position to 50p to the right and 50p to the down…

Then how about something like this?

WindowId root WarpToWindow 100p 30p

You’re still going to have to find out the pixel locations for where your cursor should end up.

– Thomas Adam

Ohhh, i thought that WarpToWindow working only if we have an opened windows.
Thanks for help.

No – FVWM controls the root window too.

– Thomas Adam