Subject: Re: FVWM: Intricacies of the Next() function / Conditionals

From: Nicholas Paul Johnson <[email-masked]>
Date: Sat, 1 May 2004 13:18:46 -0400 (EDT)

Mikhael et al,

Thanks for the response.  I appologize for my earlier impatience.

On Sat, 1 May 2004, Mikhael Goikhman wrote:
> 
> If you use MouseFocus this does quite not work, since you just get the
> window under the pointer (or no window) focused. This is what MouseFocus
> is all about.
>
I use MouseFocus.

I want more than just the Focus; I want the desk to switch automatically
to the newly focused window.  The Focus function will do this (and even
move the mouse over the top left corner of the window; perhaps a
consequence of MouseFocus), but the SloppyFocus feature will not.

>
> As for your Next command question, try this command:
> 
>   Prev (CurrentDesk, !Sticky) Focus
>
This is good.  Is there any way to have it execute some statement if there
is no window on the CurrentDesk which is not Sticky?  Specifically, can I
tell fvwm to try to focus one on the current desk, and only if there is no
window on the CurrentDesk, focus one on /any/ desk?

>
> Take a look at FvwmEvent module, it does what you want.
> 
> Just don't use both methods simultaneously, chose either "smart" close
> button, or "smart" close event.
>
Good call.  This is exactly the answer to my second question.

Thanks a lot,
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Nicholas Paul Johnson
  o nickjohnson \at\ virginia \dot\ edu
  o 3ebf10a7 subkeys.pgp.net
  o http://manjac.ath.cx/nick
  o "When all you've got is a hammer,
    everything looks like a nail.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
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 19:05:51 +0000

On 01 May 2004 13:18:46 -0400, Nicholas Paul Johnson wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Mikhael et al,
> 

These side effects of the Focus command work regardless of the focus
policy. You may read about this command and its argument. There are a lot
of other good things in the man page.

If you want something else than just focus with page change (not desk
change if you work on the same desk), then create a function, like:

  DestroyFunc MySwitchToWindow
  AddToFunc   MySwitchToWindow
  + I Iconify off
  + I Focus    # or FlipFocus
  + I Raise
  + I WarpToWindow 10p 10p

> window on the CurrentDesk, focus one on /any/ desk?

There is TestRc command in 2.5.x that basically implements the "else"
statement for conditional commands like Next.

There is a way to implement a similar if-else construction in 2.4.x too,
using a temporary function that you create in the condition (and before
it), and then execute such function. But I would rather suggest to use
2.5.10 than such hack.

Regards,
Mikhael.

---

From: Nicholas Paul Johnson <[email-masked]>
Date: Sun, 2 May 2004 18:18:40 -0400 (EDT)

This works great! Thank you.

I'll quote the portion of my .fvwm2rc for the archives here:

#---------------- snip .fvwm2rc
# Abstract: to automatically focus a new window when one window closes
# tries to choose a window in the same desk, but will default to 
# a window on any desk if unavailable
#
# Requires fvwm 2.5.x+

DestroyFunc FocusAndRaise
AddToFunc FocusAndRaise
+ "I" Focus
+ "I" Raise

# For my alt-tab binding
# switch to any other non-sticky window
DestroyFunc Cycle
AddToFunc Cycle
+ "I"           Next (!Sticky) Function FocusAndRaise
Key Tab A M     Cycle

# cycle windows whenever a window is closed.
# switch to another non-sticky window
# try first a window on the same desk,
# default to any non-sticky window
DestroyFunc CycleLocally
AddToFunc CycleLocally
+ "I"           Next (CurrentDesk, !Sticky)  Function FocusAndRaise
+ "I"           TestRC (0) Next (!Sticky) Function FocusAndRaise
*FvwmEvent: destroy_window 'Function CycleLocally'

#----------------

Thanks a lot,