Subject: FVWM: How to move to the next/previous page

From: [email-masked] (Marc Schlienger)
Date: Thu, 20 May 2004 22:46:21 +0200

Hi,

I want to create a function that moves a window to the next/previous page. For 
example, if the current Page is 0 1 I want the window to be moved to 
Page 0 2.

Any ideas?
--
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: Phil Stracchino <[email-masked]>
Date: Thu, 20 May 2004 17:10:01 -0400

> example, if the current Page is 0 1 I want the window to be moved to 

Try this (it requires FvwmPerl and assumes a 4x4 grid):

DestroyFunc MoveWindowToNextPage
AddToFunc MoveWindowToNextPage
+		I	WindowId ${w.id} MoveToPage \
		%{ ${page.nx} < 3 ? ${page.nx} + 1 : \
			${page.ny} < 3 ? 0 : 3 }% \
                %{ ${page.nx} < 3 ? ${page.ny} : \
			${page.ny} < 3 ? ${page.ny} + 1 : 3 }%

This should consider 3,3 as the "last page" and not try to move a window
on beyond it. By changing both occurrences of ': 3 }%' to ': 0 }%', you
could make the "next page" from 3,3 wrap around to 0,0.

-- 
 .*********  Fight Back!  It may not be just YOUR life at risk.  *********.
 : phil stracchino : unix ronin : renaissance man : mystic zen biker geek :
 :  [email-masked][email-masked][email-masked]  :
 :   2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)   :
 :    Linux Now!   ...Because friends don't let friends use Microsoft.    :
--
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: [email-masked] (Marc Schlienger)
Date: Thu, 20 May 2004 23:49:59 +0200

Am Donnerstag, 20. Mai 2004 23:10 schrieb Phil Stracchino:
> > I want to create a function that moves a window to the next/previous
> > page. For example, if the current Page is 0 1 I want the window to be
> > moved to Page 0 2.
> >
> > Any ideas?
>
I tried this but it doesn't work. I added

+ I Module FvwmPerl 

to my init function. And I tested whether it works if I add

+ I SendToModule FvwmPerl preprocess -c

to the MoveWindowToNextPage function. I had no luck.

Thanks.

Any ideas?

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 20 May 2004 22:21:31 +0000

> to the MoveWindowToNextPage function. I had no luck.

Yes, the sample above, although an ok idea, is just incorrect.
Good you figured out how to pass it to a preprocessing.
You should also replace every ${var} with correct $[var].

This sample should work:

  Module FvwmPerl

  DestroyFunc .
  AddToFunc   .
  + I SendToModule FvwmPerl preprocess -c -- $*

  DestroyFunc MoveWindowToRightPage
  AddToFunc   MoveWindowToRightPage
  + I . MoveToPage %{ $[page.nx]+1 == $[desk.pagesx] ? 0 : $[page.nx]+1 }% 0p

And if you don't want to loop, then a simple "MoveToPage +1p 0p" will do
what you want.

Regards,
Mikhael.

---

From: Phil Stracchino <[email-masked]>
Date: Thu, 20 May 2004 18:31:42 -0400

> You should also replace every ${var} with correct $[var].

Oops.  Sorry about that.

---

From: [email-masked] (Marc Schlienger)
Date: Fri, 21 May 2004 11:01:28 +0200

>   + I . MoveToPage %{ $[page.nx]+1 == $[desk.pagesx] ? 0 : $[page.nx]+1 }%
This also doesn't work. I think that MoveToPage has to be invoked either by

MoveToPage 1 2

or 

MoveToPage +1p 0p.

In your sample you seem to use the two possibilities together. But even when I 
trie it with 

+ I . MoveToPage %{ $[page.nx]+1 == $[desk.pagesx] ? 0 : $[page.nx]+1 }%  1

it doesn't work.    
> And if you don't want to loop, then a simple "MoveToPage +1p 0p" will do
I know, but I want, for example, move from Page 2 0 to Page 0 1 (3x2 desk).
> Mikhael.
Any ideas ?

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 21 May 2004 13:02:20 +0000

> This also doesn't work. I think that MoveToPage has to be invoked either by

True, you should use $[page.ny] instead of 0p above.

> + I . MoveToPage %{ $[page.nx]+1 == $[desk.pagesx] ? 0 : $[page.nx]+1 }% 1

I hope you have a recent fvwm version. It should work, but it asks for a
window to select, this is a general problem of SendToModule loosing the
window context, so you may need the WindowId trick below.

> I know, but I want, for example, move from Page 2 0 to Page 0 1 (3x2 desk).

Please next time explain exactly what is "next page" for you, so we don't
need to guess. If I understand it correctly, then one of the solutions is:

+ I . WindowId $[w.id] MoveToPage \
      %{ $[page.nx] + 1 < $[desk.pagesx] ? $[page.nx] + 1 : 0 }% \
      %{ $[page.nx] + 1 < $[desk.pagesx] ? $[page.ny] : \
         $[page.ny] + 1 < $[desk.pagesy] ? $[page.ny] + 1 : 0 }%

But maybe the "next page" for you is not from the current page, but from
the window's page, then you should play with window coordinates $[w.x],
$[vp.width] and Move, not with MoveToPage.

Regards,
Mikhael.

---

From: stu <[email-masked]>
Date: Fri, 21 May 2004 15:14:49 +0200

> page. For example, if the current Page is 0 1 I want the window to be

# Ctrl-Alt-Left and Right to move a window to the previous or next page
Key   Left      A     CM    MoveToPage 0p -1p
Key   Right     A     CM    MoveToPage 0p +1p

Don't think it'll handle wrap arounds tho.

- -- 
Stuart Logie
Programmer

UNIVERSAL COMPUTER SERVICES (PTY) LTD
   
Powered by Debian GNU/Linux - testing/unstable

---

From: [email-masked] (Marc Schlienger)
Date: Fri, 21 May 2004 23:17:09 +0200

Am Freitag, 21. Mai 2004 15:02 schrieb Mikhael Goikhman:
> > > > > > I want to create a function that moves a window to the
> > > > > > next/previous page. For example, if the current Page is 0 1 I
> > > > > > want the window to be moved to Page 0 2.
> > > > >
> > In your sample you seem to use the two possibilities together. But even
> > when I trie it with
> >
> > > And if you don't want to loop, then a simple "MoveToPage +1p 0p" will
> > > do what you want.
> >

First I want to thank you for your tips. Now everything works fine except one 
thing. I bound the functions to a mouse click on a button. Now when I click 
on the button it stays pressed in and no action is done until I click on it 
another time. Why?
Here is my configuration:

DestroyFunc .
AddToFunc .
+	  "I"	SendToModule FvwmPerl preprocess -c -- $*

DestroyFunc MoveAndGoToPreviousDesk
AddToFunc MoveAndGoToPreviousDesk
+	  "I"	. MoveToDesk 0 %{$[desk.n] == 0 ? 3 : $[desk.n]-1}%
+	  "I"	. GotoDesk 0 %{$[desk.n] == 0 ? 3 : $[desk.n]-1}%

DestroyFunc MoveToPreviousDesk
AddToFunc MoveToPreviousDesk
+	  "I"	. MoveToDesk 0 %{$[desk.n] == 0 ? 3 : $[desk.n]-1}%

DestroyFunc MoveAndGoToNextDesk
AddToFunc MoveAndGoToNextDesk
+	  "I"	. MoveToDesk 0 %{$[desk.n] == 3 ? 0 : $[desk.n]+1}%
+	  "I"	. GotoDesk 0 %{$[desk.n] == 3 ? 0 : $[desk.n]+1}%

DestroyFunc MoveToNextDesk
AddToFunc MoveToNextDesk
+	  "I"	. MoveToDesk 0 %{$[desk.n] == 3 ? 0 : $[desk.n]+1}%

DestroyFunc MoveAndGoToPreviousPage
AddToFunc MoveAndGoToPreviousPage
+	  "I"	 . MoveToPage %{$[page.nx] == 0 ? $[desk.pagesx]-1:\
			        $[page.nx]-1}% \
			      %{$[page.nx] > 0 ? $[page.ny]:\
         		        $[page.ny] > 0 ? $[page.ny]-1:\
				$[desk.pagesy]-1}%
+	  "I"	 . GotoPage %{$[page.nx] == 0 ? $[desk.pagesx]-1:\
			      $[page.nx]-1}% \
			    %{$[page.nx] > 0 ? $[page.ny]:\
         		      $[page.ny] > 0 ? $[page.ny]-1:\
			      $[desk.pagesy]-1}%

DestroyFunc MoveToPreviousPage
AddToFunc MoveToPreviousPage
+	  "I"	 . MoveToPage %{$[page.nx] == 0 ? $[desk.pagesx]-1:\
			        $[page.nx]-1}% \
			      %{$[page.nx] > 0 ? $[page.ny]:\
         		        $[page.ny] > 0 ? $[page.ny]-1:\
				$[desk.pagesy]-1}%

DestroyFunc MoveAndGoToNextPage
AddToFunc MoveAndGoToNextPage
+	  "I"	 . MoveToPage %{$[page.nx]+1 == $[desk.pagesx] ? 0:\
			        $[page.nx]+1}% \
			      %{$[page.nx]+1 < $[desk.pagesx] ? $[page.ny]:\
         		        $[page.ny]+1 < $[desk.pagesy] ? $[page.ny]+1:0}%
+	  "I"	 . GotoPage %{$[page.nx]+1 == $[desk.pagesx] ? 0:\
			        $[page.nx]+1}% \
			      %{$[page.nx]+1 < $[desk.pagesx] ? $[page.ny]:\
         		        $[page.ny]+1 < $[desk.pagesy] ? $[page.ny]+1:0}%

DestroyFunc MoveToNextPage
AddToFunc MoveToNextPage
+	  "I"	 . MoveToPage %{$[page.nx]+1 == $[desk.pagesx] ? 0:\
			        $[page.nx]+1}% \
			      %{$[page.nx]+1 < $[desk.pagesx] ? $[page.ny]:\
         		        $[page.ny]+1 < $[desk.pagesy] ? $[page.ny]+1:0}%

.
.
.

Mouse   1	8	A	Function "MoveAndGoToNextDesk" 
Mouse   3	8	A	Function "MoveToNextDesk" 
Mouse   1	0	A	Function "MoveAndGoToPreviousDesk" 
Mouse   3	0	A	Function "MoveToPreviousDesk"  
Mouse   1	7	A	Function "MoveAndGoToNextPage"
Mouse   3	7	A	Function "MoveToNextPage"
Mouse   1	5	A	Function "MoveAndGoToPreviousPage"
Mouse   3	5	A	Function "MoveToPreviousPage"

Remark: All functions work well and the effect mentioned above appears with 
all functions, too.