Subject: RecaptureWindow needed

From: Stefan Merten <[email-masked]>
Date: Mon, 02 Feb 2004 12:46:23 +0100

-----BEGIN PGP SIGNED MESSAGE-----

Hi!

I'm writing because this entry

       Recapture
              This  command  is obsolete and should not be
              used anymore.  Should you want to  do  some
              thing  specific  that  you cannot do without
              it, please report this to  the  fvwm-workers
              mailing  list ([email-masked]).  This
              command will be removed at some point in the
              future.   Please read the note at the end of
              the section DELAYED EXECUTION OF COMMANDS to
              learn  about how to avoid the Recapture com
              mand.

in the man page of `fvwm2'

	$ fvwm -version
	fvwm 2.5.7 compiled on Sep 23 2003 at 23:03:38

told me to do so. Actually I'm not using `Recapture' - though this
also worked - but `RecaptureWindow'. I'll try a description of the
problem I had where only `RecaptureWindow' seems to be a solution.

I have a `fvwm2' setup where the mouse is more or less obsolete.
Everything is controlled by keys. I defined a special "window manager
key" as modifier 5 and in combination with other keys I can do
everything necessary. In particular switching the focus between
windows on a virtual desktop is controlled by keys.

This setup worked perfectly for years but now there is a strange
behavior with current Mozilla 1.4 (Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.4) Gecko/20030821). On one of my virtual desktop lives
Mozilla. Strange things happen when I have more than one Mozilla
window open and I try to switch focus from one window to the next by
the appropriate key combination. Most of the time the first switch
works but later switches *seem* to switch the focus - i.e. `fvwm2'
updates the window decoration accordingly - but when I press a key
like CursorDown or PageUp it actually *goes* to the window which had
the focus before that window. In other words: For `fvwm2' the focus
has switched while for Mozilla it stayed in the old window. If I then
switch the focus to the next window the window decoration is updated
to indicate having focus but the focus actually moves to the previous
window. This stays this way for further focus switches. This way the
focus of Mozilla is always one window behind the window `fvwm2'
considers focused.

I can remedy the effect when I click into the Mozilla window but this
is of course what I'm trying to prevent with my keyboard control
setup.

I experimented a lot with various things but nothing worked well. The
only thing which actually changed at least something was playing
around with the `Layer' command. Also the focus switched to the right
window when I manually gave `RaiseLower' two times. Finally I found
`RecaptureWindow' and this did what I need - though it's ugly.

I can't see this behavior with any other application before or now so
I guess it has to do more with Mozilla than anything else. Also
Mozilla 0.9.4 did not show this behavior before.

I included some excerpts from my `fvwm2rc' so you can experiment if
you like. If necessary I can send the complete `fvwm2rc' but only by
private mail.

If this mail goes to a mailing list: I'm not on this list. I'm ready
to reply to questions but note that you need to contact me directly.

						Mit Freien Grüßen

						Stefan

- --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
Style	"*"		SlipperyIcon
Style	"*"		TileCascadePlacement
Style	"*"		NoPPosition
Style	"*"		SkipMapping

Style	"*"		ClickToFocusRaisesOff
Style	"*"		MouseFocusClickRaisesOff

# Needed for smooth desktop switching
Style	"*"		ClickToFocus

FocusStyle	"*"	GrabFocus
FocusStyle	"*"	ReleaseFocus
FocusStyle	"*"	GrabFocusTransient
FocusStyle	"*"	ReleaseFocusTransient
FocusStyle	"*"	SortWindowlistByFocus

###############################################################################
# Functions for key bindings

#define WARP_VER 10
#define WARP_HOR 90

# Raise current window and warp pointer to top right corner
AddToFunc RaiseCur
# transfer focus
+	"I"	Current Raise
+	"I"	Current WarpToWindow WARP_HOR WARP_VER

# Steps to $0 window meeting conditions $1@ on current desk and warps to it
AddToFunc StepWarp
+	"I"	$0 (CurrentDesk $1 $2 $3 $4 $5 $6 $7 $8 $9) FlipFocus
+	"I"	Function RaiseCur
+	"I"	Current ("Mozilla-bin") RecaptureWindow

# Focus the raised window on this desktop
AddToFunc FocusRaised
+	"I"	Prev (CurrentDesk $0 $1 $2 $3 $4 $5 $6 $7 $8 $9) Focus
+	"I"	Next (CurrentDesk $0 $1 $2 $3 $4 $5 $6 $7 $8 $9) Focus

# Warps to the raised window on current desktop
AddToFunc WarpRaised
+	"I"	Function FocusRaised !"*Buttons" !"FvwmPager" !Iconic
+	"I"	None (CurrentDesk !"*Buttons" !"FvwmPager" !Iconic) Function FocusRaised !"GlobalButtons" !"FvwmPager" !Iconic
+	"I"	Function RaiseCur

# Warp to a window given by ID $0
AddToFunc WarpId
+	"I"	WindowId $0 Focus
+	"I"	Function RaiseCur

# Warp to desk $0 and there to raised window
AddToFunc DeskWarp
+	"I"	GotoDesk 0 $0
+	"I"	Function WarpRaised

# Deiconifies a window and warps to it
AddToFunc DeiconifyWarp
+	"I"	Iconify -1
+	"I"	Function WarpId $[w.id]

# Closes a window by '$0' and warps to the previous one
AddToFunc CloseWarp
+	"I"	$0
+	"I"	StepWarp Prev !Sticky !Iconic !"*Buttons"

# Warps to buttons on desk '$0'
AddToFunc DeskButtons
+	"I"	GotoDesk 0 $0
+	"I"	Function StepWarp Next !Sticky !Iconic "*Buttons"

#define DESK_TERM 0
#define DESK_EDIT 1
#define DESK_GRAPHIC 2
#define DESK_WEB 3
#define DESK_FILES 4
#define DESK_MAIL 5
#define DESK_RECREATION 6
#define DESK_OFFICE 7

#define COLOR_DESK_TERM bisque2
#define COLOR_DESK_EDIT DeepSkyBlue1
#define COLOR_DESK_MAIL green4
#define COLOR_DESK_WEB DarkOrchid3
#define COLOR_DESK_FILES yellow2
#define COLOR_DESK_GRAPHIC grey50
#define COLOR_DESK_RECREATION orange2
#define COLOR_DESK_OFFICE tan4

###############################################################################
# Jump to desks

Key	t	A	5	Function DeskWarp DESK_TERM
Key	e	A	5	Function DeskWarp DESK_EDIT
Key	g	A	5	Function DeskWarp DESK_GRAPHIC
Key	w	A	5	Function DeskWarp DESK_WEB
Key	f	A	5	Function DeskWarp DESK_FILES
Key	m	A	5	Function DeskWarp DESK_MAIL
Key	r	A	5	Function DeskWarp DESK_RECREATION
Key	o	A	5	Function DeskWarp DESK_OFFICE

AddToMenu DeskKeys "Jump desk" Title
+	"Terminals     W-T"	Function DeskWarp DESK_TERM
+	"Emacs         W-E"	Function DeskWarp DESK_EDIT
+	"Graphic       W-G"	Function DeskWarp DESK_GRAPHIC
+	"Web           W-W"	Function DeskWarp DESK_WEB
+	"Files         W-F"	Function DeskWarp DESK_FILES
+	"Mail          W-M"	Function DeskWarp DESK_MAIL
+	"Recreation    W-R"	Function DeskWarp DESK_RECREATION
+	"Office        W-O"	Function DeskWarp DESK_OFFICE

AddToMenu AllKeys
+	"&Jump desk"	Popup DeskKeys

###############################################################################
# Switch windows

Key	Prior	A	5	Function StepWarp Prev !Sticky !Iconic !"*Buttons"
Key	Prior	A	5S	Function StepWarp Prev !Sticky Iconic
Key	Prior	A	5SC	Function StepWarp Prev Sticky !Iconic !"*Buttons"
Key	Next	A	5	Function StepWarp Next !Sticky !Iconic !"*Buttons"
Key	Next	A	5S	Function StepWarp Next !Sticky Iconic
Key	Next	A	5SC	Function StepWarp Next Sticky !Iconic !"*Buttons"

AddToMenu CircKeys "Switch through windows" Title
+	"Prev window   W-Prior"	Function StepWarp Prev !Sticky !Iconic !"*Buttons"
+	"Next window   W-Next"	Function StepWarp Next !Sticky !Iconic !"*Buttons"
+	""			Nop
+	"Prev icon    WS-Prior"	Function StepWarp Prev !Sticky Iconic
+	"Next icon    WS-Next"	Function StepWarp Next !Sticky Iconic
+	""			Nop
+	"Prev sticky WSC-Prior"	Function StepWarp Prev Sticky !Iconic !"*Buttons"
+	"Next sticky WSC-Next"	Function StepWarp Next Sticky !Iconic !"*Buttons"

AddToMenu AllKeys
+	"Switch &window"	Popup CircKeys

###############################################################################
# Explicit stacking

Key	Prior	A	5C	FlipFocus
Key	Next	WTFS	5C	RaiseLower
Key	Next	RI	5C	Function WarpRaised

AddToMenu StackKeys "Explicit change stacking" Title
+	"Top focus       WC-Prior"	FlipFocus
+	"Lower           WC-Next"	RaiseLower

AddToMenu AllKeys
+	"Change &stacking"	Popup StackKeys
+	""			Nop

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Mon, 2 Feb 2004 13:12:47 +0000

> Mozilla 0.9.4 did not show this behavior before.

Recent messages in [email-masked] seem to indicate there is some known
focus problem in Mozilla 1.4 and related browsers.

> you like. If necessary I can send the complete `fvwm2rc' but only by

Here are some config hints.

> +	"I"	Next (CurrentDesk $0 $1 $2 $3 $4 $5 $6 $7 $8 $9) Focus

The last lines are better be written using $*.  Of course this can't be
done in StepWarp, in which case you should be aware of parameters like
!"My Spaced Name".

> +	"I"	None (CurrentDesk !"*Buttons" !"FvwmPager" !Iconic) Function FocusRaised !"GlobalButtons" !"FvwmPager" !Iconic

Only one name may be used in conditions. I.e. !"FvwmPager" is ignored,
since there is already non-option name !"*Buttons". Maybe instead you want
to use something like !Sticky or !CirculateHit (default for Prev/Next).

> +	"I"	Function WarpId $[w.id]

The functions WarpId and DeiconifyWarp may be written as:

  AddToFunc Warp
  + I Focus
  + I RaiseCur

  AddToFunc DeiconifyWarp
  + I Iconify off
  + I Warp

[the rest is skipped]

Regards,
Mikhael.