Re: FVWM: Store and Recall MousePosition? (ALT+Mouse3-Resize)

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Wed, 31 Dec 2003 00:05:10 +0000

On 30 Dec 2003 22:10:57 +0100, Gert Brinkmann wrote:
>
> Mikhael Goikhman wrote:
>
> >I would say any complex function should normally have only one "M",
> >like in this sample:
>
> OK. Just one question to be sure to understand how execution of this
> complex functions works:
>
> > DestroyFunc MyResizeDispatcher
> > AddToFunc MyResizeDispatcher
> > + C MyResize0
> > + M MyResize
> > + H MyResize
> > + D MyResize2
>
> All of the lines are walked through sequentially from top to bottom? The
> "C" or "M" is just a condition if the line is executed or not, but
> execution is not paused until such a condition is fulfilled? Is this right?

Yes, this is right for these specifiers, but not if we also add "I".
It is better to look into complex functions from a different point.

The whole function is stored in the memory divided in parts before
its execution.

Any function has 5 possible independent parts, the "I" specifier part,
and "C", "M", "H", "D". Each such part preserves the command order.
But the order of the specifier parts themselves is not important,
they may be even mixed, i.e.:

  + C something1
  + M something2
  + C something3

is equivalent to:

  + M something2
  + C something1
  + C something3

When the function is called, the "I" part is always exacuted, if any.
Then only if the function is called from a mouse press, additionally one
and only one of the parts "C", "M", "H" or "D" is executed too if any,
depending on whether it was a mouse "c"lick, a mouse "m"otion, a mouse
"h"olding or a mouse "d"ouble click.

This simplified explanation is enough to understand complext functions.
I think the man page has its own explanation too.

> >The rest of the configuration is your whole example above with all 8 "M"
> >replaced with "I". Then it works. Just don't forget "p" here:
> >
> > WarpToWindow $[POINTERX]p $[POINTERY]p
>
> Yes, with this hints the function works as expected. Thank you very
> much. Here is the current version of the functions:
>
> -----------------------------------------------
> DestroyFunc MyResize
> AddToFunc MyResize
> + I StoreMousePos
> + I WarpToNearestEdge
> + I Resize
> + I RecallMousePos
>
> DestroyFunc StoreMousePos
> AddToFunc StoreMousePos
> + I SetEnv POINTERX $[pointer.wx]
> + I SetEnv POINTERY $[pointer.wy]
>
> DestroyFunc RecallMousePos
> AddToFunc RecallMousePos
> + I WarpToWindow $[POINTERX]p $[POINTERY]p
>
> DestroyFunc WarpToNearestEdge
> AddToFunc WarpToNearestEdge
> + I WarpToWindow 100 100
>
> Mouse 3 WTSF M MyResize

Well, if you use "I" then Resize is started immediatelly on the mouse
press, if you want it to start on a click or a motion, then use what
I wrote in the previous reply.

> -----------------------------------------------
>
> What is missing now is to calculate the nearest edge and add the mouse
> movement to the POINTERX/Y values. How can you calculate something in a
> function? I need something like
>
> DestroyFunc WarpToNearestEdge
> AddToFunc WarpToNearestEdge
> + I SetEnv WARPX ($[w.width]/2 - $[pointer.wx] > 0 ? 0 : 100)
> + I SetEnv WARPY ($[w.height]/2 - $[pointer.wy] > 0 ? 0 : 100)
> + I WarpToWindow $[WARPX] $[WARPY]
>
> There does not seem to exist a fvwm internal arithmetic language, so
> maybe I have to use a shell command that returns "0" or "100"?

You would better create a shell script ~/bin/my_wrap_pointer receiving
two parameters and printing this line (just an example):

  WarpToWindow 75 68

Then, define this function like:

  AddToFunc WarpToNearestEdge
  + I PipeRead `my_wrap_pointer $[pointer.wx] $[pointer.wy]`

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Tue Dec 30 2003 - 18:07:35 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:56 BST