Subject: FVWM: NearestEdgeResizing

From: Gert Brinkmann <[email-masked]>
Date: Sat, 01 May 2004 17:38:39 +0200

Hello,

I have tried to configure fvwm so that it behaves the same as other 
window-manager on resizing and moving: When pressing ALT, clicking into 
a window with the left mousebutton should move the window, clicking the 
right mousebutton should grep the nearest edge (or border, what I had to 
add to the shellscript) of the window and do a resize.

Below you see the configuration for this. The attached script (that 
certainly has to be executable and stored in the search path; it 
probably requires bash.) calculates the nearest corner and prints out 
the statement to move the mouse cursor to it.

Moving works fine. On resizing the problem is that you have to release 
the right mousebutton before resizing is started. Is there a way to 
change this behaviour to directly starting the resizing on mouse press?

(I have started this experiments some months ago, but did not find the 
time to work on it for longer now)

Thank you,

Gert

#---- Alt+Mouse to handle windows.
DestroyFunc MyMove
AddToFunc MyMove
+ M Move
+ C RaiseLower

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 PipeRead `FvwmWarpToNearestEdge  $[w.width] $[w.height] 
$[pointer.wx] $[pointer.wy]`

Mouse 1 WTSF M MyMove
Mouse 3 WTSF M MyResize

#!/bin/bash

# required Parameters:
# $1 w.width
# $2 w.height
# $3 pointer.wx
# $4 pointer.wy

# some default, just to be sure.
WARPX=100
WARPY=100

# define x position
if [[ $[ $1/2 - $3 ] > 0 ]]; then WARPX=0; else WARPX=100; fi

# define y position
if [[ $[ $2/2 - $4 ] > 0 ]]; then WARPY=0; else WARPY=100; fi

echo "WarpToWindow $WARPX $WARPY"

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 1 May 2004 18:44:34 +0000

> change this behaviour to directly starting the resizing on mouse press?

A small side note. I would divide the window into 9 squares and not 4,
and warp to the 8 corresponding points on the border. In 90% of cases I
only need/want to resize one direction, not two. And if I need both
directions then I probably want Maximize anyway. So probably 4 triangles
(with only side center border points) would be good for me too.

> + I RecallMousePos

Replace all "I" with "H":

  DestroyFunc MyResize
  AddToFunc MyResize
  + H StoreMousePos
  + H WarpToNearestEdge
  + H Resize
  + H RecallMousePos

Then it works like you want with a small click-time delay, about 0.15
seconds. You may like this delay, otherwise add one more wrapper function:

  DestroyFunc MyResize0
  AddToFunc MyResize0
  + I ClickTime 0
  + I MyResize
  + I ClickTime 150

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 [email-masked].
To report problems, send mail to [email-masked].

---

From: Gert Brinkmann <[email-masked]>
Date: Sat, 01 May 2004 22:46:21 +0200

> A small side note. I would divide the window into 9 squares and not 4,

Yes, you are right. I have planned to do this, but did not enhance the 
script yet, because the whole behaviour was very useless for me... until 
now.

Thank you very much for your hints. They are working great. Now I can 
start using fvwm for real ;)

> Replace all "I" with "H":

I have read this part of the man page several times. But did not 
understand the resulting behaviour for H instead of I.

> seconds. You may like this delay, otherwise add one more wrapper function:

No, I do not like the delay, so I am using the following wrapper 
function. (hmm, as I am writing this mail I ask myself if it is possible 
to include the clicktime-lines in MyResize without another wrapper 
function? I will test this)

>   + I ClickTime 150

In the last line the "150" can be omitted. This will switch back to the 
default.

What do you think of my solution conceptionally? Is this the right way 
to solve this or are there better ways?

Thank you again,

Gert

PS: Is there a collection of such configuration snippets somewhere where 
I can "publish" my solution? I think there might be others who are 
interested in such a resize-behaviour, too.
--
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 [email-masked].
To report problems, send mail to [email-masked].

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 1 May 2004 21:10:21 +0000

> understand the resulting behaviour for H instead of I.

I hope you understand that "H" means holding the mouse as opposed to "C",
"M", "D" and "I", it is activated after ClickTime milliseconds.

Now, Resize operation is normally started by a mouse press. Exception is
"M" and "H", then Resize does not require an initial press, sinse we are
in the dragging mode already. This is from my experience only, it is
possible there are additional nuances (2.4.x may be different here).

> function? I will test this)

Don't do this. This ClickTime affects the whole function execution,
so changing it in the same function may work if it is done using "I",
but it may as well fail or work strangely. The actual behaviour is not
defined well and may stop working in the future. Use a wrapper function.

> to solve this or are there better ways?

The "better" way is to patch move_resize.c to allow another resize option.

Regards,
Mikhael.

---

From: Gert Brinkmann <[email-masked]>
Date: Mon, 03 May 2004 11:03:34 +0200

> "M", "D" and "I", it is activated after ClickTime milliseconds.

I always thought "I" means "immediately" after mouse press (the man page 
says "is executed as soon as the function is invoked". This seems not to 
be true, is it?).

 > defined well and may stop working in the future. Use a wrapper function.

Well, it works in 2.5.10. The first command is "+ I ClickTime 0" all the 
other commans "+ H ...", including the "+ H Clicktime" as the last 
command. I think this is a defined behaviour. But ok, if it is more safe 
I will use a wrapper-function.

 > The "better" way is to patch move_resize.c to allow another resize 
option.

I did take a look to this C-function, but because I do not know anything 
about the fvwm-code (which global variables do exist, where do I get the 
parameters from, which function is to be called for some functionality, 
etc.) and because I cannot find enough time, I have to wait until 
someone else will implement this. ;|

If I implemented it I had chosen a 3x3-field as you mentioned. Because 
one might only want to resize a window at the border I had created two 
parameters: "Resize NearestEdge NearestCorner". The first one only 
allows to grab an edge for resizing the window in only one direction.

But let's wait if and when someone will do this and how.

Ciao,

Gert

---

From: Mikhael Goikhman <[email-masked]>
Date: Mon, 3 May 2004 10:15:39 +0000

> says "is executed as soon as the function is invoked". This seems not to 

"I" does work immediately.

I just played with it a bit and my previous explanation was not fully
correct. It is not Resize that requires mouse release with "I", but a
combination of PipeRead printing WarpToWindow. This currently only
supports dragging with "M" and "H", but not with "I".

Here are 3 examples doing the same thing, to demonstrate the problem:

  Mouse 3 WTSF M MyResize

  DestroyFunc MyResize
  AddToFunc MyResize
  + I WarpToWindow 100 100
  + I Resize

This first example works like you want. But the following second example
requires mouse release (and then Resize requires mouse click, since we
are not dragging anymore):

  DestroyFunc MyResize
  AddToFunc MyResize
  + I PipeRead `echo WarpToWindow 100 100`
  + I Resize

Seems like a bug, because the following works without additional mouse
release and click:

  DestroyFunc MyResize
  AddToFunc MyResize
  + I PipeRead `echo Echo just to have some command executed`
  + I WarpToWindow 100 100
  + I Resize

I think this should be fixed, but let's wait for the Dominik's reply.

Regards,
Mikhael.

---

From: Gert Brinkmann <[email-masked]>
Date: Wed, 05 May 2004 10:13:25 +0200

> I think this should be fixed, but let's wait for the Dominik's reply.

Just to point attention to this: Is it a bug, Dominik?

btw: I have found that my solution does not work reliable. When moving 
the mousepointer to fast, resizing often starts to late after the 
mousewarping so that the mouse pointer is no longer on the window's 
corner and you have to move the mouse back to it. The higher the load of 
my slow machine, the more often this happens.

It would be good to change the order of the commands. First "Resize" and 
then "WarpToWindow", but "Resize" must not block then. I think this is 
not possible.

So it would be great if someone could implement this in fvwm sometime.

Thank you,

Gert