Subject: FVWM: fvwm-perl tutorial example

From: Peter McAlpine <[email-masked]>
Date: Thu, 7 Nov 2002 22:24:34 -0500

hey,

I'm trying to write a Perl module... and am getting tripped up trying
to figure out what the new page is upon a M_NEW_PAGE.

My problem is that M_NEW_PAGE->_vp_width/height only give me the
maximum width/height for the top left corner... but I need the top
right to figure out what page was just switched to, don't I (I can't
assume the screen res)? The only thing I can think of to fix this is
to have DeskTopSize inputted as a config option.

I tried using the module-flash @:
ftp://ftp.fvwm.org/pub/fvwm/devel/sources/tests/perl/module-flash

But it has the same problem I'm having, it doesn't report the correct
page (as it claims it will).

peter =)

--
Peter McAlpine
[email-masked]
--
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: Richard Lister <[email-masked]>
Date: Fri, 08 Nov 2002 14:17:10 -0500 (EST)

Peter McAlpine <[email-masked]> wrote on Thu, 7 Nov 2002 22:24:34 -0500:
>
> Subject: FVWM: fvwm-perl tutorial example
>
> hey,
> 

Peter

I'm not quite sure what you're asking for. Are you trying to
figure out if a particular window is on the current page?
That's just a matter of comparing the window's coordinates
to the screen position. I can send code for that if you need it.

The page is just defined by the x and y coords of its top left,
as given by vp_x and vp_y. So the top left page is +0+0. I have
screen res of 1600x1200 so if I move down a page I am on +0+1200.
Move right and I am now on +1600+1200.

The problem for a module that doesn't load any X libraries is
finding out the screen resolution. It would be great if fvwm
passed this in e.g. M_CONFIG_INFO (future enhancement, anyone?).

I solve it in the following clunky manner:

  my $screen;

  open(XWININFO, "xwininfo -root|") || die "can't run xwininfo";
  while ( <XWININFO> ) {
    $screen->{w} = $1 if /Width:\s*(\d+)/;
    $screen->{h} = $1 if /Height:\s*(\d+)/;
  }
  close(XWININFO);

I would love a better solution if anyone has one :-)

Cheers
Ric

Richard J Lister
Dept of Neuroscience
Georgetown University Medical Center
http://cns.georgetown.edu/~ric/
--
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: Peter McAlpine <[email-masked]>
Date: Fri, 8 Nov 2002 16:01:24 -0500

> I would love a better solution if anyone has one :-)

Thank you! this is exactly what I needed.

-peter =)

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 9 Nov 2002 03:57:50 +0000

> > page (as it claims it will).

Interesting, what does it report if not the correct page numbers?
It works for me with 2.5.4.

> I would love a better solution if anyone has one :-)

I should be missing something, please enlighten me.
Is not it exactly what vp_width and vp_height arguments of M_NEW_PAGE are?
And M_NEW_DESK/M_NEW_PAGE are sent on Send_WindowList from modules.

Regards,
Mikhael.

---

From: Peter McAlpine <[email-masked]>
Date: Sat, 9 Nov 2002 14:52:13 -0500

> It works for me with 2.5.4.

Well, I've got a 3x3 desk. So:
{(0,0), (0,1), (1,0), (1,1)} :: module-flash shows: (0,0)
{(2,0), (2,1)} :: module-flash shows: (1,0)
{(0,2), (1,2)} :: module-flash shows: (0,1)
{(2,2)} :: module-flash shows: (1,1)

examining the formula in module-flash:
    my $page_nx = int($event->_vp_x / $width);
    my $page_ny = int($event->_vp_y / $height);

the highest values that page_nx/ny can possibly be is 1. They will
never be higher.

> And M_NEW_DESK/M_NEW_PAGE are sent on Send_WindowList from modules.

I don't completely follow what you're saying here. M_NEW_DESK/PAGE are
sent TO modules, are they not? And M_NEW_PAGE's vp_width/height show
(from the online docs): 
The fourth [vp_width] and fifth [vp_height] values are the maximum
allowed values of the coordinates of the upper-left hand corner of the
viewport.

Seeing as how it is possible (using FvwmPager) to be "in-between" two
pages, I can see how the values passed with an M_NEW_PAGE signal are
useful. Is there any way to get fvwm to send me the page size, though?
or is this considered an X issue?

thanks,
-peter =)

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 9 Nov 2002 21:53:45 +0000

> the highest values that page_nx/ny can possibly be is 1. They will

Ok, I see it now. This example only works well with the 2x2 desktop.
Thanks for pointing this out.

> or is this considered an X issue?

It is pretty silly that the page size is not send. I thought the 4-th and
5-th arguments of M_NEW_PAGE are the page size, now I should rename them.

Anyway, it is still possible currently to calculate the page size
using these 2 silly values (the maximal left-upper coordinate possible
in the pager) and "DesktopSize 3 3" (this is the first M_CONFIG_INFO
packet sent on Send_ConfigInfo). I will think what to do about M_NEW_PAGE.

Regards,
Mikhael.