Subject: FVWM: Setting mouse bindings in functions

From: Marcus Lundblad <[email-masked]>
Date: Tue, 21 May 2002 09:53:45 +0200 (CEST)

I have 2 functions which I would like to change the binding of mouse
button 2 on the root window like this:

Mouse 2	R	A	HidePager

AddToFunc HidePager     "I"     All ("FvwmPager") Stick off
+                       "I"     All ("FvwmPager") MoveToDesk 123
+                      "I"     Mouse 2 R       A       ShowPager

AddToFunc ShowPager     "I"     All ("FvwmPager") Stick on
+                      "I"     Mouse 2 R       A       HidePager

So that pressing button 2 will toggle.
But this will not work, it seeems the last line tries to call the other
function, because the cursor changes to an hour-glass for about 1 second
(as if there's an infinity recursion that is interrupted).

Is it not possible to use the Mouse command in functions like this?
I didn't find anything about this in the man-page.

//Marcus

--
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: Dominik Vogt <[email-masked]>
Date: Tue, 21 May 2002 12:51:11 +0200

> I didn't find anything about this in the man-page.

I don't know how it exactly works internally, but you can not
expect that changing bindings or functions works inside complex
functions.  Anyway, there is a much simpler solution for what you
want to achieve.  Take a look at Q 7.12 from the FAQ:

----------------------------------------------------------------------

7.12  Toggling windows on and off.

   It is often desirable to have a menu item of perhaps a button in
   FvwmButtons or FvwmWharf that launches an application when used
   the first time and closes it if used a second time.  Although it
   is not obvious how to do this, it is possible.  Let's assume you
   need a menu item that toggles an FvwmConsole window on and off.
   Then put the following lines in your .fvwm2rc:

     AddToFunc ToggleFvwmConsole
     + I None (FvwmConsole) Module FvwmConsole
     + I Next (CurrentPage Visible FvwmConsole) Close
     + I Next (FvwmConsole) MoveToDesk
     + I Next (FvwmConsole) MoveToPage
     + I Next (FvwmConsole) Raise

     AddToMenu <some menu>
     + "toggle FvwmConsole" Function ToggleFvwmConsole

   Or if you prefer a button in the button bar:

     *FvwmButtons(Action ToggleFvwmConsole)

   The lines with MoveToDesk, MoveToPage and Raise will bring the
   window to the top of the current page if it is not visible
   instead of closing it.

   If you want to toggle one specific window, e.g. an xterm, but
   still want to have other xterms that are not toggled, you must
   give the window an unique name:

     AddToFunc ToggleXMessages
     + I None (XMessages) Exec ( TERM -T XMessages -n XMessages \
         -e exec tail -f /var/adm/?* ~/.X.err )
     + I Next (XMessages) Close

   Or for a toggling Netscape button:

     AddToFunc ToggleNetscape
     + I None (Navigator) Exec exec netscape
     + I All (Navigator) Close

   Keep in mind that these functions simply check if a window with
   the specified name exists.  They will happily close manually
   opened windows or launch an application multiple times if the
   application is slow to start (e.g. like netscape).

----------------------------------------------------------------------

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" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Marcus Lundblad <[email-masked]>
Date: Tue, 21 May 2002 15:11:53 +0200 (CEST)

>      + I All (Navigator) Close

I added a function like this:

AddToFunc TogglePager
+	I	None (FvwmPager) StartPager
+	I	All (FvwmPager) Close

(StartPager is another function used to start the pager (used also in the
init, it works...)

If the pager is not running, this function starts it. 
If it is running, it's closed and about a second or so later it starts
again.

I also wrote another function just to test, like this:

AddToFunc ToggleCalc
+	I	None (XCalc) Exec xcalc
+	I	All (XCalc) Close

it works as it should, toggling an xcalc.

Is the pager to slow to exit?

//Marcus

---

From: Mikhael Goikhman <[email-masked]>
Date: Tue, 21 May 2002 14:15:04 +0000

On 21 May 2002 15:11:53 +0200, Marcus Lundblad wrote:
> 
> > Anyway, there is a much simpler solution for what you

The FAQ examples are not quite universal, I will improve them.
Your function should be:

AddToFunc TogglePager
+     I       None (FvwmPager, CirculateHit) StartPager
+     I       Next (FvwmPager, CirculateHit) Close

Regards,
Mikhael.