# Unfortunately, order does matter in this file
# The correct order for inserting configurations is:
# 1. Colors
# 2. Assorted configuration paramters such as ClickToFocus, or MWMBorders
# 3. Path setup (ModulePath, PixmapPath, IconPath)
# 4. Style settings, including the default style Style "*" ...
# 5. InitFunction and ResetFunction definitions.
# 6. Other Functions. Functions cannot be forward referenced from
#	other functions, but they can be backward referenced.
# 7. Menus definitions. Same caveats about forward referencing
# 8. Key and Mouse Bindings.
# 9. Module options.

# The order of steps 5, 6, and 7 is not critical, as long as there are
# no forward references to functions or menus.

# If you get it wrong, the most common problem is that color or font settings
# are ignored

#############################################################################
#
# Here's nation@rocket.sanders.lockheed.com's MWM like configuration,
# with several changes to make it more 4Dwm like by
# tabaer@magnus.acs.ohio-state.edu. Perhaps some mwm fans can
# fix this up a little, and mail the changes to:
#
#       nation@rocket.sanders.lockheed.com
#
# (This is actually a set of bug reports masquerading as a sample config)
#
# WARNING:  This is as much my personal preference as anything else.
# The button and menu layout is based on my experiences with SGI
# machines at Ohio State and NASA-Lewis, so your mileage may vary...
#  --tabaer@magnus
#
###########################################################################
# set up the colors
#
# this is used for non-selected windows, menus, and the panner

# 4Dwm is an mwm derivative, so this should look as "mwm" as possible
# without sacrificing any of the functionality I like.  --tabaer@magnus
MWMButtons
MWMDecorHints
MWMFunctionHints
MWMMenus

# User window placement became erratic with fvwm v1.16 -- sometimes
# you place the window, other times the WM places it automatically
# (usually at the top left of the screen).  In particular, I've found
# the following programs always autoplace themselves now:
#	emacs 18.59
#	all of the "GREAT" utilities (gfm, cmdframe, etc.)
#	Mosaic 2.0
#	ups
#	mpeg_play
#	xspread 7.0
#	xv (Control window)
# --tabaer@magnus
#
#RandomPlacement
#SmartPlacement

# SGI-ish button bar using GoodStuff
ModulePath /usr/X11/lib/X11/fvwm:/usr/X11/bin:/usr/local/bin
*GoodStuffGeometry 70x181+5+5
*GoodStuffColumns	1
*GoodStuffFont	-adobe-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*
*GoodStuffFore	Black
*GoodStuffBack	LightGray

# A minor complaint about the GoodStuff button:  the GoodStuff window
# doesn't size itself width-wise correctly, so it chops off the last letters
# on a couple of the button labels.  I'd like to see GoodStuff with the
# button text left-justified and the icons right-justified, like in SGI's
# toolchest, but I'll have to hack that out myself when I get the time.
# Also, is there any way to get the popup menus to cascade off the buttons,
# rather than appearing over them? --tabaer@magnus
#
#*GoodStuff	Button	Icon	Command
*GoodStuff	Shells	/usr/user/tabaer/popup.xbm	PopUp	"Shells"	Shells
*GoodStuff	Windows	/usr/user/tabaer/popup.xbm	PopUp	"Windows"	Windows
*GoodStuff	Tools	/usr/user/tabaer/popup.xbm	PopUp	"Tools"	Tools
*GoodStuff	Demos	/usr/user/tabaer/popup.xbm	PopUp	"Demos"	Demos
*GoodStuff	R-Hosts	/usr/user/tabaer/popup.xbm	PopUp	"R-Hosts"	R-Hosts
*GoodStuff	System	/usr/user/tabaer/popup.xbm	PopUp	"System"	System
*GoodStuff	EMACS	/usr/include/X11/xlogo32	Exec	""	exec emacs -i &

# this is used for the selected window
HiForeColor 		Yellow
HiBackColor 		RoyalBlue

PagerBackColor		#5c54c0

# Menu colors
MenuForeColor           Black
MenuBackColor           grey
MenuStippleColor        SlateGrey

############################################################################
# Now the fonts - one for menus/icons, another for window titles
Font			-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*
WindowFont		-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
IconFont		-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
###########################################################################
# Set up the major operating modes
#
# Set windows to auto-raise after 750 milliseconds
#AutoRaise 750

# Normally, we'll be in focus-follows mouse mode, but uncomment this 
# for mwm-style click-to-focus
#ClickToFocus

# The default icon box for SGI's seems to be on the top of the screen,
# starting at the left side just beyond the toolchest
IconBox 130 5 600 150

# If you don't like the default 150 msec click delay for the complex functions
# change this and uncomment it.
#ClickTime 150

ButtonStyle 1 50x22
ButtonStyle 2 50x50
ButtonStyle 4 22x22

###########################################################################
# Set up the virtual desktop and pager

#set the desk top size in units of physical screen size
DeskTopSize 1x1

# and the reduction scale used for the panner/pager
DeskTopScale 32

# flip by whole pages on the edge of the screen.
EdgeScroll 100 100

##########################################################################
# Icon paths
#
PixmapPath /usr/include/X11/pixmaps/
IconPath   /usr/include/X11/bitmaps/

############################################################################
# Set the decoration styles and window options
# Order is important!!!!
# If compatible styles are set for a single window in multiple Style
# commands, then the styles are ORed together. If conflicting styles
# are set, the last one specified is used.

# These commands should command before any menus or functions are defined,
# and before the internal pager is started.

# change the default width.
Style "*" BorderWidth 1, HandleWidth 7, Color Black/LightGray,Icon xlogo32

Style "Fvwm*"      NoTitle, NoHandles, Sticky, WindowListSkip,BorderWidth 0
Style "Fvwm Pager" StaysOnTop
Style "FvwmPager"  StaysOnTop
Style "FvwmBanner" StaysOnTop
Style "GoodStuff"  NoTitle, NoHandles, Sticky, WindowListSkip,BorderWidth 0
Style "*lock"      NoTitle, NoHandles, Sticky, WindowListSkip
Style "xbiff"      NoTitle,            Sticky, WindowListSkip
Style "Maker"      StartsOnDesk 1
Style "matlab"     StartsOnDesk 3
Style "signal"     StartsOnDesk 3 
Style "rxvt"       Icon  term.xpm
Style "xterm"      Icon xterm.xpm, Color black/grey
Style "Appointment" Icon datebook.xpm
Style "xcalc"      Icon xcalc.xpm
Style "xbiff"      Icon mail1.xpm
Style "xmh"        Icon mail1.xpm, StartsOnDesk 2
Style "xman"	   Icon xman.xpm
Style "xvgr"	   Icon graphs.xpm
Style "matlab"	   Icon math4.xpm
Style "xmag"	   Icon mag_glass.xpm
Style "xgraph"	   Icon graphs.xpm
Style "GoodStuff"  Icon toolbox.xpm

Style "Fudgit"       Icon g/graphp.xpm
Style "ghostview"    Icon g/gv.xpm
Style "Gnuplot"      Icon m/math.xpm
Style "idraw"        Icon d/draw3.xpm
Style "RLaB"	     Icon m/matrix1.xpm
Style "XSpread V7.0" Icon s/spreadsh.2.xpm
Style "velvet"       Icon tabaer/fem.xbm
Style "News"         Icon mail2.xpm
Style "xconsole"     Icon term.xpm



#############################################################################

# Stuff to do at start-up

Function "InitFunction"
	Module	"I"	FvwmBanner
	Exec	"I"	xpmroot /usr/include/X11/pixmaps/fvwm.xpm &
	Module	"I"	GoodStuff
	Exec	"I"	exec xterm -geometry 80x64+0+0 &
	Wait	"I"	xterm
	Desk	"I"	0 2
	Exec	"I"	exec xterm
	Wait	"I"	xterm
	Desk 	"I"	0 0
EndFunction

Function "RestartFunction"
	Exec	"I"	xsetroot -solid "#266294"      
	Module	"I"	GoodStuff
EndFunction

##############################################################################
# Now define the menus - defer bindings until later
# The first three menus are very basic and are used in several places.
# --tabaer@magnus

# This menu is invoked as a sub-menu - it allows you to quit,
# restart, or switch to another WM.
Popup "Quit-Verify"
	Title	"Really Quit Fvwm?"
	Nop	"This may log you out!"
	Nop	""
	Quit	"Yes, Really Quit"
	Restart "Restart fvwm" fvwm
	Restart "Start twm"	/usr/bin/X11/twm
# This SHOULD invoke gwm in Motif mode (mwm == "gwm -qf mwm -1"), but
# it's not as good as fvwm with this file IMHO... --tabaer@magnus
	Restart "Start mwm" 	/usr/bin/X11/mwm
	Restart "Start gwm"	/usr/X386/bin/gwm
	Restart	"Start olwm"	/usr/openwin/bin/olwm
	Restart "Start olvwm"	/usr/openwin/bin/olvwm
	Nop	""
	Nop	"No, Don't Quit"
EndPopup

PopUp	"WindowManagers"
	Restart "Restart fvwm" fvwm
	Restart "Start twm"	/usr/bin/X11/twm
# This SHOULD invoke gwm in Motif mode (mwm == "gwm -qf mwm -1"), but
# it's not as good as fvwm with this file IMHO... --tabaer@magnus
	Restart "Start mwm" 	/usr/bin/X11/mwm
	Restart "Start gwm"	/usr/X386/bin/gwm
	Restart	"Start olwm"	/usr/openwin/bin/olwm
	Restart "Start olvwm"	/usr/openwin/bin/olvwm
EndPopUp

# This menu checks to make sure you REALLY want to log out,
# assuming killing the WM will kick you out of X.
PopUp	"Logout-Verify"
	Title	"Do You REALLY want to log out?
	Nop	""
	Quit	"Yes, log me out."
	Nop	"No, cancel that."
EndPopUp

# The following menus form the bulk of the menu system I have hanging
# off the GoodStuff module; they contain most of my commonly used
# X-based tools.  Note that I use rxvt instead of xterm for most of my
# shells due to memory constraints; if you use xterms or some variant
# thereof (aixterm, cxterm, kxterm, etc.) you'll need to change quite
# a few things.  --tabaer@magnus

# A menu of VT100 size shells
PopUp	"80x25"
	Title	"80x25 Shells"
	Nop	""
	Exec	"Black on gray"	exec rxvt -geometry 80x25 -fg Black -bg LightGray &
	Exec	"Black on white"	exec rxvt -geometry 80x25 -fg Black -bg White &
	Exec	"Gold on black"	exec rxvt -geometry 80x25 -fg gold1 -bg Black &
	Exec	"Green on black"	exec rxvt -geomtery 80x25 -fg green2 -bg Black &
	Exec	"White on black"	exec rxvt -geometry 80x25 -fg White -bg Black &
	Exec	"Yellow on blue"	exec rxvt -geometry 80x25 -fg Yellow -bg Blue &
EndPopUp

# A menu of slightly larger shells
PopUp	"80x40"
	Title	"80x40 Shells"
	Nop	""
	Exec	"Black on gray"	exec rxvt -geometry 80x40 -fg Black -bg LightGray &
	Exec	"Black on white"	exec rxvt -geometry 80x40 -fg Black -bg White &
	Exec	"Gold on black"	exec rxvt -geometry 80x40 -fg gold1 -bg Black &
	Exec	"Green on black"	exec rxvt -geometry 80x40 -fg green2 -bg Black &
	Exec	"White on black"	exec rxvt -geometry 80x40 -fg White -bg Black &
	Exec	"Yellow on blue"	exec rxvt -geometry 80x40 -fg Yellow -bg Blue &
EndPopUp

PopUp	"Apps"
	Title	"Applications"
	Nop	""
	Exec	"Interviews Draw"	exec idraw &
	Exec	"X Spreadsheet"	exec xspread &
	Exec	"PostScript Previewer"	exec ghostview &
	Exec	"Pixmap Previewer"	exec xv &
EndPopUp

PopUp "AudioDemos"
	Title	"Audio Demos"
	Nop	""
# Put your favorite sounds here
EndPopUp

# All sorts of different time pieces
PopUp "Clocks"
	Title	"Clocks"
	Nop	""
	Exec	"Analog Clock"	exec xclock -analog &
	Exec	"Digital Clock"	exec xclock -digital &
	Exec	"Round Clock"	exec oclock &
EndPopUp

# A set of NASTY time killers...
PopUp "Games"
	Title	"Games"
	Nop	""
	Exec	"GnuChess"	exec xboard &
	Exec	"Lander"	exec xlander &
	Exec	"Puzzles"	exec xpuzzle &
EndPopUp

# A menu of various and sundry background graphics.
PopUp "Pixmaps"
	Title	"Backgrounds"
	Nop	""
	Exec	"MIT Logo"	exec xsetroot -bg White -fg LightSkyBlue -bitmap /usr/include/X11/bitmaps/mensetmanus &
	Exec	"X Logo"	exec xsetroot -bg White -fg Black -bitmap /usr/include/X11/bitmaps/xlogo64 &
	Exec	"Escher Knots"	exec xsetroot -bg LightSkyBlue -fg Black -bitmap /usr/include/X11/bitmaps/escherknot &
	Exec	"Woman"		exec xsetroot -bg White -fg Black -bitmap /usr/include/X11/bitmaps/woman &
EndPopUp
	
# Several math/science/engineering related applications
PopUp	"SciEngr"
	Title	"Science/Engineering"
	Nop	""
	Exec	"RLaB"		exec rxvt -T RLaB -n RLaB -e /usr/local/bin/rlab &
	Exec	"Fudgit"	exec rxvt -T Fudgit -n Fudgit -e /usr/local/bin/fudgit &
	Exec	"GnuPlot"	exec rxvt -T GnuPlot -n GnuPlot -e /usr/local/bin/gnuplot &
	Exec	"Velvet"	exec /usr/local/bin/velvet &
# I need other stuff here, but that'll come later... --tabaer@magnus
EndPopUp

# Menu of silly things every X setup should have
PopUp "Toys"
	Title	"Toys"
	Nop	""
	Exec	"X-Eyes"		exec xeyes &
	Exec	"X-Roaches"	exec xroach &
	Exec	"Ideal Gases"	exec xgas &
EndPopUp

# Here are the top-level menus hanging off GoodStuff.  As you'll see,
# they call other menus a lot.  --tabaer@magnus

PopUp "Shells"
	Title	"Shells"
	Nop	""
	PopUp	"80x25"	80x25
	PopUp	"80x40"	80x40
	Nop	"Misc"
EndPopUp

PopUp	"Windows"
	Title	"Windows"
	Nop	""
	PopUp	"Set Background"	Pixmaps
	Nop	"Set Screen Saver"
	PopUp	"Window Managers"	WindowManagers
	Nop	""
	CirculateUp	"Shuffle Up"
	CirculateDown	"Shuffle Down"
	Nop	"Tidy Icons (?)"
	Nop	""
	Nop	"Restore All (?)"
	Nop	"Minimize All (?)"
	Refresh	"Refresh All"
EndPopUp

PopUp	"Tools"
	Title	"Tools"
	Nop	""
	Exec	"Online Manual"	exec xman &
	PopUp	"Clocks"	Clocks
	Exec	"Calculator"	exec xcalc &
	Exec	"Calendar"	exec ical &	
	Exec	"Clipboard"	exec xclipboard &
	Exec	"System Load"	exec xload &
	Exec	"Memory Usage"	exec xmem &
	PopUp	"Engineering Apps."	SciEngr
	PopUp	"Misc. Apps."	Apps
EndPopUp

PopUp	"Demos"
	Title	"Demos"
	Nop	""
	PopUp	"Audio Demos"	AudioDemos
	PopUp	"X Demos and Toys"	Toys
	PopUp	"X Games"	Games
EndPopUp

PopUp	"R-Hosts"
	Title "Remote Hosts"
	Nop	""
	Nop	"These clients require"
	Nop	"networking to be up."
	Nop	""
	Exec	"Chimera (WWW)"	exec /usr/local/bin/chimera &
	Exec	"News"	rxvt -T News -i News -e /usr/local/bin/trn &
	Exec	"XArchie"	exec xarchie &
EndPopUp

PopUp	"System"
	Title "System
	Nop	""
	Exec	"Audio Control"	exec /usr/local/bin/xvmixer &
	Nop	""
	Exec	"Lock Terminal"	exec xlock -mode random &
	Nop	""
	PopUp	"Log Out"	Logout-Verify
EndPopUp

# The next few menus are mostly used in the root window.  They control
# basic things like window placement, iconification, and logging out.
# --tabaer@magnus
	
# This defines the most common window operations
# As with the key bindings (see below), these were appropriated from
# a stock SGI .4Dwmrc file
Popup "Window Ops"
# I'm not 100% sure what the "Restore" option is supposed to do in stock
# mwm/4Dwm, or if there's an equivalent in fvwm.  Right now I just have
# Restore defined the same as Raise.  --tabaer@magnus
	Raise	"Restore  (Alt-F5)"
	Move	"Move     (Alt-F7)"
	Resize	"Resize   (Alt-F8)"
	Iconify	"Minimize (Alt-F9)"
	Maximize	"Maximize (Alt-F10)"
	Raise	"Raise    (Alt-F1)"
	Lower	"Lower    (Alt-F3)"
	WindowList	"WinList  (Alt-F6)"
	Nop	""
	Destroy	"Close    (Alt-F4)"
	Delete	"Quit     (Alt-F2)"
EndPopup

# 4dwm-ish root window menu
PopUp "RootMenu"
	Title	"FVWM"
	Nop	""
	Exec	"Lock Terminal"	exec xlock -mode random &
	PopUp	"Log Out"	Logout-Verify
EndPopUp

#4dwm-ish long root window
PopUp "LongRootMenu"
	Title	"FVWM"
	Nop	""
	Exec	"New Window"	exec rxvt &
	CirculateUp	"Shuffle Up"
	CirculateDown	"Shuffle Down"
	Nop	"Tidy Icons (?)"
	Nop	"Restore All (?)"
	Refresh	"Refresh All"
	Nop	""
	Restart	"Restart fvwm"	fvwm
	PopUp	"Quit fvwm"	Quit-Verify
	Nop	""
	Exec	"Lock Terminal"	exec xlock -mode random &
	PopUp	"Log Out"	Logout-Verify
EndPopUp

############################################################################
# Now define some handy complex functions

# This one moves and then raises the window if you drag the mouse,
# only raises the window if you click,  or does a RaiseLower if you double 
# click
Function "Move-or-Raise"
	Move 		"Motion"
	Raise		"Motion"
	Raise		"Click"
	RaiseLower	"DoubleClick" 
EndFunction

# This one moves and then lowers the window if you drag the mouse,
# only lowers the window if you click,  or does a RaiseLower if you double 
# click
Function "Move-or-Lower"
	Move 		"Motion"
	Lower		"Motion"
	Lower		"Click"
	RaiseLower	"DoubleClick"
EndFunction

# This one resizes and then raises the window if you drag the mouse,
# only raises the window if you click,  or does a RaiseLower if you double 
# click
Function "Resize-or-Raise"
	Resize 		"Motion"
	Raise		"Motion"
	Raise		"Click"
	RaiseLower	"DoubleClick"
EndFunction

Function "Move-or-Iconify"
	Move 		"Motion"
	PopUp		"Click" Window Ops
	Iconify		"DoubleClick"
EndFunction

# This does the Motif/MSWin thing of killing the window when you
# double-click the top left button.  Very useful if you're used
# to Windows 3.1, SGI machines, or both (like me).  --tabaer@magnus
Function "Die-on-DoubleClick"
	Destroy		"DoubleClick"
	PopUp		"Click"	Window Ops
EndFunction

##############################################################################
# This defines the mouse bindings

# First, for the mouse in the root window
# I use the AnyModifier option for the modifier field, so you can hold down
# any shift-control-whatever combination you want!

#     Button	Context Modifi 	Function
Mouse 1		R   	A       PopUp "LongRootMenu"
# Mouse button 2 calls up the Tools menu in case GoodStuff doesn't work
Mouse 2		R    	A      	PopUp "Tools"
Mouse 3		R    	A      	PopUp "RootMenu"

# Now the title bar buttons
# Any button in the left title-bar button gives the window ops menu
# Any button in the right title-bar button Iconifies the window
# Note the use of "Mouse 0" for AnyButton.

#     Button	Context Modifi 	Function
Mouse 0		1    	A      	Function "Die-on-DoubleClick"
Mouse 0		2    	A     	Maximize
Mouse 0		4    	A     	Iconify

# Now the rest of the frame
# Here I invoke my complex functions for Move-or-lower, Move-or-raise,
# and Resize-or-Raise. 
# Button 1 in the corner pieces, with any modifiers, gives resize or raise
Mouse 1		FS	A	Function "Resize-or-Raise"
Mouse 2		FS	A	Function "Resize-or-Raise"
Mouse 1         T	A	Function "Move-or-Raise"
Mouse 2         T	A	Function "Move-or-Raise"
Mouse 1		I	A	Function "Move-or-Iconify"
Mouse 2		I	A	Function "Move-or-Iconify"

############################################################################
# Now some keyboard shortcuts.

# I don't use (or compile in, for that matter) the virtual stuff,
# so the Scroll keybindings are pretty useless to me.  I shut them
# off.  --tabaer@magnus

# Arrow Keys
# press arrow + meta key, and scroll by 1/10 of a page
Key Left	A	M	Scroll -10 +0
Key Right	A	M	Scroll +10 +0
Key Up		A	M	Scroll +0   -10
Key Down	A	M	Scroll +0   +10

# press shift arrow + control anywhere, and move the pointer by 1% of a page
Key Left	A	SC	CursorMove -1 0
Key Right	A	SC	CursorMove +1 +0
Key Up		A	SC	CursorMove +0   -1
Key Down	A	SC	CursorMove +0   +1

# press shift arrow + meta key, and move the pointer by 1/10 of a page
Key Left	A	SM	CursorMove -10 +0
Key Right	A	SM	CursorMove +10 +0
Key Up		A	SM	CursorMove +0   -10
Key Down	A	SM	CursorMove +0   +10

# Keyboard accelerators
# These are "borrowed" from the .4Dwmrc file on an SGI I use,
# except for AltF2 and AltF6 which I added for completeness.
# I think the other are standard Motif.  --tabaer@magnus
Key F1		WFST	M	Raise
Key F2		WFST	M	Delete
Key F3		WFST	M	Lower
Key F4		WFST	M	Destroy
Key F5		WFST	M	Raise
Key F6		A	M	WindowList
Key F7		WFST	M	Move
Key F8		WFST	M	Resize
Key F9		WFST	M	Iconify
Key F10		WFST	M	Maximize
