Subject: Learning pointer warping scheme

From: Tim Phipps <[email-masked]>
Date: Wed, 06 Mar 2002 09:58:14 +0000

Morning all,
	A feature request:

1) Could I have $[pointer.x]/$[pointer.y] variables to return the 
pointer position relative to the window frame? I would use this to 
create a WarpToWindow function so the number should be pixels from the 
top-left of the fvwm frame. It might be useful for "WindowId Root 
$[pointer.x]" to  return the absolute position (not sure about xinerama).

What I'm trying to do is to implement a learning cursor warping scheme. 
What I want is for fvwm to remember where the cursor was in each window 
when it was warped away so that if the cursor is warped back to a window 
it gets warped to the old location. At the moment I have a semi 
intelligent function to warp the cursor to sensible places but the 
function is going to get very large:

# functions to warp cursor to somewhere useful depending on window type
NewFunc(my_conditional_cursorwarp)
+ I                Current (Transient) WarpToWindow 50 50
+ I Cond (NoMatch) Current (XTerm)     WarpToWindow -10p -70p
+ I Cond (NoMatch) Current (Fvwm*)     WarpToWindow 50 50
+ I Cond (NoMatch) Current             WarpToWindow 35p 40p

What I'd like is something like this

NewFunc(my_NEW_conditional_cursorwarp)
+ I PointerWindow my_record_warp
+ I AddToFunc my_warp_$w I my_conditional_cursorwarp
+ I AddToFunc my_warp_$w I Break
+ I my_warp_$w

NewFunc(my_record_warp)
+ I DestroyFunc my_warp_$w
+ I AddToFunc my_warp_$w I WarpToWindow $[pointer.x]p $[pointer.y]p
+ I AddToFunc my_warp_$w I Break

I would end up with a lot of functions called my_warp_xxx but I can 
destroy each one when the window closes.

If a window is warped-to that hasn't been warped-from the function for 
that window would look like:

AddToFunc my_warp_1234 I my_conditional_cursorwarp
+ I Break

and the default warping would occur. If the window had been warped-from 
it would look like:

AddToFunc my_warp_1234 I WarpToWindow 56p 78p
+ I Break
+ I my_conditional_warp
+ I Break

Cheers,
Tim.

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Wed, 6 Mar 2002 11:45:11 +0100

On Wed, Mar 06, 2002 at 09:58:14AM +0000, Tim Phipps wrote:
> pointer position relative to the window frame?

Done.  Try pointer.x, pointer.y (position in root window),
pointer.wx, pointer.wy (position in frame) and pointer.cx,
pointer.cy position in client window.  See man page for details.

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: [email-masked]
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Tim Phipps <[email-masked]>
Date: Wed, 06 Mar 2002 16:18:06 +0000

> pointer.cy position in client window.  See man page for details.

Thanks, it's working nicely now. very useful when you middle-click a 
link in mozilla to get a new window, when you close the new window the 
pointer gets warped back to the link you pressed.  The functions truned 
out like this:

# functions to warp pointer to somewhere useful depending on window type
AddToFunc my_default_pointerwarp
+ I                This (Transient) WarpToWindow 50 50 # transients = centre
+ I Cond (NoMatch) This (XTerm)     WarpToWindow -10p -70p # rxvt = 
scrollbar
+ I Cond (NoMatch) This (Fvwm*)     WarpToWindow 50 50 # modules = centre
+ I Cond (NoMatch)                  WarpToWindow 35p 40p # default to 
menu bar

# this creates a function for each window to remember where to warp the 
pointer
AddToFunc my_record_warp
+ I DestroyFunc my_warp_$w
+ I This AddToFunc my_warp_$w I WarpToWindow $[pointer.wx]p $[pointer.wy]p
+ I AddToFunc my_warp_$w I Break # prevents falling through to default 
warping

# AI: This function learns the old location of the pointer and records 
it for later use
AddToFunc my_pointerwarp
+ I PointerWindow my_record_warp
+ I AddToFunc my_warp_$w I This (CurrentDesk !Iconic) my_default_pointerwarp
+ I my_warp_$w
+ I my_record_warp # removes the default from the end of the function

The "This" in my_record_warp was necessary to get the $[pointer.wx] to 
expand when my_record_warp is executed rather than getting passed to 
my_warp_$w and being expanded when my_warp_$w is executed.

Is this a feature of variable expansion?

Cheers,
Tim.

---

From: Mikhael Goikhman <[email-masked]>
Date: Wed, 6 Mar 2002 23:07:20 +0000

On 06 Mar 2002 16:18:06 +0000, Tim Phipps wrote:
> 
> # this creates a function for each window to remember where to warp the pointer
> AddToFunc my_record_warp
> + I AddToFunc my_warp_$w I Break # prevents falling through to default warping
> 

Both "+" and "AddToFunc" do not expand $[extended.var], while all other
commands do.  $w _is_ expanded.  And for module configs it is vice versa.

At least this is all intentional.

Regards,
Mikhael.