toggle auto-raise, per-window, on mb3 press on titlebar?

Hi,

I’ve started working with fvwm this week, and to get myself familiar,
I am now first trying to emulate the behaviour I had with vtwm.

Under vtwm I had autoraise for emacs and a few special xterms. I have
implemented that with:

AutoRaise on a per-window basis:

DestroyFunc MyAutoRaise
AddToFunc MyAutoRaise

  • I Current (!Raised !Iconic xterm) Raise
  • I Current (emacs) Raise

However, also under vtwm I had the ability for /any/ window to have
autoraise toggled, when mouse button 3 was clicked on the titlebar,
using these commands:

Function “toggle_autoraise”
{
f.autoraise
}
Button3 = : title : f.function “toggle_autoraise”

How can I replicate this in fvwm? I guess I need to be able to
dynamically modify (on the press of mb3) the list of windows to
which MyAutoRaise currently applies.

Any ideas?

bjd

[size=84][color=darkblue]
Ok, I managed to implement this using the State style attribute present in fvwm-2.5.x (I also have an implementation using flag files that works under fvwm-2.4.x).

For the benefit of others, I am giving the 2.5.x code here, with added comments (if anybody wants the 2.4.x code, just mail me). To the Maintainer of this forum: feel free to put this in the FAQ or elsewhere on this site.
I’ve been using fvwm for just over a week and this little challenge has been great in teaching me the .fvwmrc basics and the power of fvwm.

Introduction:

Autoraise across the board is very nice, but can become annoying fast (whilst remaining indispensable). This snippet here reduces the annoyance and introduces added flexibilty. Here’s the .fvwm2rc code.

Usage:

In the function AutoRaiseInit (see below), specify any windows for which you want AutoRaise enabled by default. With X and fvwm running, those windows should now autoraise as soon as the pointer enters the window.

Now, to dynamically enable Autoraise for other windows, press MouseButton 3 on the Window or the Titlebar of the window you want autoraised. To disable, also press MouseButton 3 on the Window or Titlebar. Simple as that – mb3 toggles the Autoraise state of any window.

Note that you may want to call AutoRaiseReset in RestartFunction if you don’t want to preserve current dynamic Autoraise information (i.e. windows that have Autoraise currently set, but don’t have it set by default).

There may yet be some minor flaws in this – if you find any, or have any improvements, please drop me a note. I think fvwm during startup sometimes has trouble catching up with what windows are mapped, so sometimes not all Autoraise default windows have their Autoraise state enabled yet after startup. To that end, a menu item with AutoRaiseReset comes in handy.

TODO: add changing Button or Titlebar dependent of Autoraise state.
[/size][/color]

###########################################################
# Autoraise on a dynamic, per-window basis, with defaults #
# bjd@xs4all.nl                                           #
# note: using State 17 as Autoraise state                 #
###########################################################

# specify windows that should have autoraise ON by default here:
DestroyFunc AutoRaiseInit
AddToFunc AutoRaiseInit
+ I All (*XTERM*|*emacs*)  State 17 True

# note: I also have a menu item from which I can call AutoRaiseReset
DestroyFunc AutoRaiseReset
AddToFunc AutoRaiseReset
+ I All (State 17) State 17 False
+ I AutoRaiseInit

# called when pointer enters window;
# check if State 17 is set; if so, Raise window
DestroyFunc AutoRaise
AddToFunc AutoRaise
+ I Current (State 17) Raise

# toggle Autoraise for current window;
# this function is put on mb3 (see below), and called when mb3
# on Titlebar or in Window (the latter for Titlebar-less windows)
DestroyFunc AutoRaiseToggle
AddToFunc AutoRaiseToggle
+ I Current State 17 toggle
+ I AutoRaise

# attach AutoRaiseToggle to mb3 press on Titlebar or Window
Mouse 3 TW A AutoRaiseToggle

DestroyFunc StartFunction
AddToFunc StartFunction
+ I Module FvwmBanner
+ I Module FvwmAuto 120 -menter "AutoRaise" "Nop"

DestroyFunc InitFunction
AddToFunc InitFunction
+ I Exec exec x11-setbg
+ I AutoRaiseReset

DestroyFunc RestartFunction
AddToFunc RestartFunction
# note: comment out if autoraise info needs to be preserved across fvwm restarts
#+ I AutoRaiseReset
+ I Module FvwmAuto 120 -menter "AutoRaise" "Nop"