Subject: FVWM: Timing problems with Close?

From: [email-masked]
Date: Fri, 6 Jun 1997 12:11:45 +0100 (BST)

I have the following function bound to the Break key:

AddToFunc my_kill       "I" Close
+                       "I" my_prev

together with the following focus moving functions

AddToFunc my_home	"I" Next [FrontPanel CirculateHit CirculateHitIcon] 
my_deiconify
AddToFunc my_nexticon	"I" Next [Iconic CurrentDesk] my_focus
+			"I" None [Iconic CurrentDesk] my_home
AddToFunc my_nexticon_s	"I" Next [Iconic CurrentDesk CirculateHitIcon] my_focus
+			"I" None [Iconic CurrentDesk CirculateHitIcon] my_home
AddToFunc my_previcon	"I" Prev [Iconic CurrentDesk] my_focus
+			"I" None [Iconic CurrentDesk] my_home
AddToFunc my_previcon_s	"I" Prev [Iconic CurrentDesk CirculateHitIcon] my_focus
+			"I" None [Iconic CurrentDesk CirculateHitIcon] my_home
AddToFunc my_next	"I" Next [!Iconic CurrentDesk] my_focus
+			"I" None [!Iconic CurrentDesk] my_nexticon
AddToFunc my_next_s	"I" Next [!Iconic CurrentDesk CirculateHit] my_focus
+			"I" None [!Iconic CurrentDesk CirculateHit] my_nexticon
AddToFunc my_prev	"I" Prev [!Iconic CurrentDesk] my_focus
+			"I" None [!Iconic CurrentDesk] my_previcon
AddToFunc my_prev_s	"I" Prev [!Iconic CurrentDesk CirculateHit] my_focus
+			"I" None [!Iconic CurrentDesk CirculateHit] my_previcon
AddToFunc my_focus	"I" Focus
+			"I" my_cursorwarp
AddToFunc my_cursorwarp	"I" WarpToWindow 50p 50p /* Top left button on most */
+			"I" Current [*term] WarpToWindow 97 90 /* scrollbar */
+			"I" Current [xterm] WarpToWindow 3 90 /* sb on left */
+			"I" Current [dockit] WarpToWindow 50 50 /* FrameMaker */
+			"I" Current [xpsview] WarpToWindow 50p 100p
+			"I" Current [FrontPanel] WarpToWindow 50 50

The intent of all this is that when I kill a window the focus moves somewhere 
sensible.  This fails sometimes when the window I am about to kill is the only 
window on the screen that does not have a CirculateSkip style .  What should 
happen is that the focus should find its way back to the FrontPanel window 
(FvwmButtons).  What I think is happening is that the Close in my_kill is being 
done but the window doesn't go away until after the Prev in my_kill is executed. 
 The Prev in my_kill finds that window that is going to die and happily sets the 
focus to it, it then dies and focus is left marooned.

Is there a way to stop execution of a function until after the Close has 
happened?  Failing that is there a clever way of making a window go-away before 
the next line of a function runs? (FvwmBanner; wait FvwmBanner; does not count 
as clever).

Cheers,
Tim Phipps.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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] (David S. Goldberg)
Date: 06 Jun 1997 08:43:32 -0400

I don't know if it's possible to do what you want directly in your
fvwm config file, but if you're willing to let an external shell do
the work for you, you can take advantage of the FvwmCommand module
(it's in the extras directory).  For example, I do the following in my
.X11Startup:

doweb(){
    FvwmCommand 'Style "Netscape" StartsOnDesk 5, SkipMapping'
    $HOME/bin/xcmd netscape -geometry 900x725+1+1
    until [ `xwininfo -root -tree | grep -c Netscape` -eq 2 ] ; do
	sleep 1
    done
    FvwmCommand 'Style "Netscape" StartsAnyWhere, ShowMapping'
}

This ensures that when I fire up netscape at login, it's first window
goes on desk number 5.  I look for two windows because (I'm guessing)
netscape seems to have an unmapped second window that actually gets
created first (you can't imagine how long it took me to debug that!).
But anyway, after that, I use browse-url within emacs to pop up web
pages and I don't want to have to jump to desk 5 to see them.  Thus,
after I detect that netscape has started and mapped its window, I
reset the style to StartsAnywhere.  For a long while I'd been doing
this manually with a hardcoded Style and used FvwmTalk and then
FvwmConsole to do the reset to StartsAnywhere.  When I discovered
FvwmCommand, boy was I psyched!  I can see this method being used in
the following manner for your situation:

In a shell script called, say fvwmclose.sh:

#!/bin/sh
until ! xwininfo -id $1 >/dev/null 2>&1 ; do
sleep 1
done
FvwmCommand your_focus_function_here

Where your my_close function calls Close and then Execs the shell
script with $w as argument.

It's almost certainly not very efficient, but it should work well
enough to keep you happy.  Note, though, that I have not tested the
above at all (except for the syntax of the until loop).  Your mileage
may vary and the rest of the usual disclaimers apply.

hth,

--
Dave Goldberg
Post: The Mitre Corporation\MS B305\202 Burlington Rd.\Bedford, MA 01730
Phone: 617-271-3887
Email: [email-masked]

---

From: [email-masked]
Date: Fri, 6 Jun 1997 16:46:29 +0200 (MET DST)

On 6 Jun 1997, David S. Goldberg wrote:

> Date: 06 Jun 1997 08:43:32 -0400
> From: "David S. Goldberg" <[email-masked]>
> Reply-To: "David S. Goldberg" <[email-masked]>
> To: [email-masked]
> Cc: [email-masked]
> Subject: FVWM: Re: Timing problems with Close?
> 
> ..X11Startup:

Why not just define a function like this ?

AddToFunc  "ChangeStyle"
+  "I"  Style "Netscape" StartsAnyWhere, ShowMapping

bye,
   Lars

--
Lars Uffmann, [email-masked], fon: +49 5202 15372
Public Key available, send in e-mail, Subject: Your Key, Please

---

From: [email-masked] (David S. Goldberg)
Date: Fri, 06 Jun 1997 15:24:21 -0400

> + "I" Style "Netscape" StartsAnyWhere, ShowMapping

Because then I have to remember to run that function every time after
Netscape starts.  I also have to reset it if I quit netscape (which
occasionally I need to do to free up colors; I find -install is broken
for plugins and applets) and want to rerun it.  And there's no way to
define a run-netscape function the way I had wanted:

AddToFunc "DoNetscape" 
+ "I" Style "Netscape" StartsOnDesk 5, SkipMapping
+ "I" Exec netscape
+ "I" Wait "Netscape"
+ "I" Style "Netscape" StartsAnywhere, ShowMapping

It doesn't work basically the the second Style gets executed before
the Netscape window pops up.  I don't know why.  Mabye it's that
same unmapped window problem I had with the shell script.

In addition, Netscape is not the only application I want this behavior
for, and I happen to be lazy.  What FvwmCommand combined with a shell
gives me is the ability to have all this stuff happen automatically
without having to do all that typing to FvwmConsole.  Sure I could
define a bunch of functions for every application and situtation.  I'd
also have to define them twice, once in .fvwm2rc and once to
FvwmConsole since I hate doing restarts unless absolutely necessary.
With FvwmCommand and the shell, I get the behavior I want at the cost
of writing a few lines of /bin/sh and I only have to type them once.
In the worst case, I decide to add an Exec for a given script to a
menu or FvwmButton, but that's pretty rare.  I do most of this stuff
at login.