######################################################################
# FVWM - functions
######################################################################

#=====================================================================
# startup and shutdown

# --------------------------------------------------------------------
# run at true startup only
DestroyFunc	InitFunction
AddToFunc	InitFunction
+ I GotoDesk 0 0
+ I GotoPage 0 0
#+ I Exec exec qasmixer -t -c 1

# --------------------------------------------------------------------
# run at true startup *and* restarts
DestroyFunc	StartFunction
AddToFunc	StartFunction
+ I Module FvwmButtons FvwmDock
+ I Module FvwmEvent

#=====================================================================
# event hooks

# --------------------------------------------------------------------
DestroyFunc	EvtWinAdd
AddToFunc	EvtWinAdd
# called by FvwmEvent when any new window is created
# we check for a handful of windows, and perform actions for those
+ I ThisWindow ("xterm") WarpToWindow
+ I ThisWindow ("kcalc") WarpToWindow
+ I ThisWindow ("Emacs") WarpToWindow

#=====================================================================
# screen lock

# --------------------------------------------------------------------
DestroyFunc	ScreenLock
AddToFunc	ScreenLock
+ I Exec xscreensaver-command -lock

# --------------------------------------------------------------------
DestroyFunc	ScreenDark
AddToFunc	ScreenDark
+ I ScreenLock
+ I Exec exec dark

#=====================================================================
# window lists

# --------------------------------------------------------------------
# cycle through windows, MSFT-style
DestroyFunc	WinListCycle
AddToFunc	WinListCycle
+ I WindowList (CurrentDesk, AnyScreen) Root c c NoGeometry CurrentAtEnd

# --------------------------------------------------------------------
# concise window list, current desktop only
# The empty "SelectOnRelease" suppresses "release left ALT to select".
# Tried putting it in "MenuStyle WindowList" but didn't seem to work.
DestroyFunc	WinListDesk
AddToFunc	WinListDesk
+ I WindowList (CurrentDesk, AnyScreen) Root c c NoGeometry SelectOnRelease

# --------------------------------------------------------------------
# like WinListDesk, but pop up under the mouse cursor
DestroyFunc	WinListMouse
AddToFunc	WinListMouse
+ I WindowList (CurrentDesk, AnyScreen) Mouse 0 0 NoGeometry

# --------------------------------------------------------------------
# comprehensive window list, all desktops, all details
# sort this one by X Resource name, since I use it when lost
DestroyFunc	WinListAll
AddToFunc	WinListAll
+ I WindowList Root c c SortByResource SelectOnRelease

#=====================================================================
# multiplexers for frames and title bar buttons

# --------------------------------------------------------------------
DestroyMenu	WinMenuButton
AddToFunc	WinMenuButton
# click or drag = window menu; double-click = close window
+ C PopUp WinOpsMenu
+ M PopUp WinOpsMenu
+ D Delete

# --------------------------------------------------------------------
DestroyFunc	MoveRaise
AddToFunc	MoveRaise
# click = raise/lower, drag = move
+ C RaiseLower
+ M Move

# --------------------------------------------------------------------
DestroyFunc	SizeRaise
AddToFunc	SizeRaise
# click = raise/lower, drag = resize
+ C RaiseLower
+ M Resize

# --------------------------------------------------------------------
DestroyFunc	MoveIconifyRaise
AddToFunc	MoveIconifyRaise
# drag = move, click = raise/lower, double-click = (de)iconify
+ M Move
+ C RaiseLower
+ D Iconify

# --------------------------------------------------------------------
DestroyFunc	MoveMaxRaise
AddToFunc	MoveMaxRaise
# drag = move, click = raise/lower, double-click = (un)maximize
+ M Move
+ C RaiseLower
+ D Maximize

#=====================================================================
# misc window movement/resize/focus

# --------------------------------------------------------------------
DestroyFunc	ArrangeIcons
AddToFunc	ArrangeIcons
+ I All (CurrentDesk, Iconic) PlaceAgain Icon

# --------------------------------------------------------------------
DestroyFunc	MaximizeAndRaise
AddToFunc	MaximizeAndRaise
+ I Maximize
+ I Schedule 100 Raise

# --------------------------------------------------------------------
DestroyFunc	FlipAndRaise
AddToFunc	FlipAndRaise
+ I FlipFocus
+ I Raise

# --------------------------------------------------------------------
DestroyFunc	CenterWin
AddToFunc	CenterWin
+ I ThisWindow Piperead "echo Move \
	+$(( $[wa.width]/2  - $[w.width]/2   ))p \
	+$(( $[wa.height]/2 - $[w.height]/2  ))p Warp"
# in fvwm3, $vp is all-monitors-boundingbox, $wa is current monitor
# Warp so window doesn't lose focus after moving

# --------------------------------------------------------------------
DestroyFunc	MoveWarpScreen
# Moves the window to the specified monitor, with the mouse pointer.
AddToFunc	MoveWarpScreen
+ I MoveToScreen $0
+ I WarpToWindow 50 50

#=====================================================================
# incremental window movement

# --------------------------------------------------------------------
DestroyFunc	MoveWinLeft
AddToFunc	MoveWinLeft
+ I Move w-10p keep
+ I CursorMove -10p 0

# --------------------------------------------------------------------
DestroyFunc	MoveWinRight
AddToFunc	MoveWinRight
+ I Move w+10p keep
+ I CursorMove +10p 0

# --------------------------------------------------------------------
DestroyFunc	MoveWinUp
AddToFunc	MoveWinUp
+ I Move keep w-10p
+ I CursorMove 0 -10p

# --------------------------------------------------------------------
DestroyFunc	MoveWinDown
AddToFunc	MoveWinDown
+ I Move keep w+10p
+ I CursorMove 0 +10p

#=====================================================================
# directional fills - grow window to meet next object

# --------------------------------------------------------------------
DestroyFunc	FillLeft
AddToFunc	FillLeft
+ I Maximize True growleft 0
+ I Maximize forget

# --------------------------------------------------------------------
DestroyFunc	FillRight
AddToFunc	FillRight
+ I Maximize True growright 0
+ I Maximize forget

# --------------------------------------------------------------------
DestroyFunc	FillUp
AddToFunc	FillUp
+ I Maximize True 0 growup
+ I Maximize forget

# --------------------------------------------------------------------
DestroyFunc	FillDown
AddToFunc	FillDown
+ I Maximize True 0 growdown
+ I Maximize forget

######################################################################
# END OF FILE
######################################################################
