# Binding Functions
#
# "I" stands for Immediate
# "M" stands for Motion
# "C" stands for Click
# "H" stands for Hold
# "D" stands for Double Click

DestroyFunc FuncFvwmMoveOrRaiseOrShade
AddToFunc   FuncFvwmMoveOrRaiseOrShade
+ H	Move
+ M	Move
+ C	Raise
+ D	WindowShade

DestroyFunc FuncFvwmResizeOrRaiseOrShade
AddToFunc   FuncFvwmResizeOrRaiseOrShade
+ H	Resize$0
+ M	Resize$0
+ C	Raise
+ D	WindowShade

DestroyFunc FuncFvwmMoveOrRaiseLower
AddToFunc   FuncFvwmMoveOrRaiseLower
+ H	Move
+ M	Move
+ C	RaiseLower

DestroyFunc FuncFvwmMoveOrIconify
AddToFunc   FuncFvwmMoveOrIconify
+ M	Move
+ D	Iconify

DestroyFunc FuncFvwmMaximizeFullScreen
AddToFunc   FuncFvwmMaximizeFullScreen
+ I ThisWindow (Maximized) WindowStyle Title, Borders
+ I TestRc (!Match) WindowStyle !Title, !Borders
+ I TestRc (!Match) Raise
+ I TestRc (!Match) UpdateStyles
+ I Maximize ewmhiwa

DestroyFunc FuncFvwmWindowOpsOrAction
AddToFunc   FuncFvwmWindowOpsOrAction
+ I Menu MenuFvwmWindowOps2 $*
#+ C Menu MenuFvwmWindowOps3
#+ D $*

DestroyFunc FuncFvwmSetTitleBindings
AddToFunc   FuncFvwmSetTitleBindings
+ I Mouse 1 	$0	A	FuncFvwmMoveOrRaiseOrShade
+ I Mouse 1 	$0	C	FuncFvwmMoveOrRaiseLower
+ I MouseXX 2 3	$0	A	FuncFvwmMoveOrRaiseLower
+ I MouseXX 3 2	$0	A	Menu MenuFvwmWindowOps2
+ I MouseXX 3 2	$0	M	Menu MenuFvwmWindowOps

DestroyFunc FuncFvwmUnsetTitleBindings
AddToFunc   FuncFvwmUnsetTitleBindings
+ I Mouse 1 	$0	A	-
+ I Mouse 1 	$0	C	-
+ I MouseXX 2 3	$0	A	-
+ I MouseXX 3 2	$0	A	-
+ I MouseXX 3 2	$0	M	-

# ---------------------------------------------------------------------------
# Contexts:
#     R = Root Window                 rrrrrrrrrrrrrrrrrrrrrr
#     W = Application Window          rIrrrrFSSSSSSSSSFrrrrr
#     F = Frame Corners               rrrrrrS13TTTT642Srrrrr
#     S = Frame Sides                 rIrrrrSwwwwwwwwwSrrrrr
#     T = Title Bar                   rrrrrrSwwwwwwwwwSrrrrr
#     I = Icon                        rIrrrrFSSSSSSSSSFrrrrr
#                                     rrrrrrrrrrrrrrrrrrrrrr
# Numbers are buttons: 1 3 5 7 9   0 8 6 4 2
#
# Modifiers: (A)ny, (C)ontrol, (S)hift, (M)eta, (N)othing

# ---------------------------------------------------------------------------
# key/mouse btn	context	modifie	function

# press Ctrl-Alt arrow anywhere, and scroll by one page
Key Left	A	CM	GotoPage -1p +0p
Key Right	A	CM	GotoPage +1p +0p
Key Up  	A	CM	GotoPage +0p -1p
Key Down	A	CM	GotoPage +0p +1p

# press Shift-Ctrl-Alt arrow anywhere, and scroll by 10% of a page
Key Left	A	SCM	Scroll -10  +0
Key Right	A	SCM	Scroll +10  +0
Key Up  	A	SCM	Scroll  +0 -10
Key Down	A	SCM	Scroll  +0 +10

# press Shift-Ctrl arrow anywhere, reserved
Key Left	A	SC	Nop
Key Right	A	SC	Nop
Key Up  	A	SC	Nop
Key Down	A	SC	Nop

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

# direction commands, Ctrl+KP_N (do not always work)
Key KP_1	A	C	Direction SouthWest FuncFvwmSelectWindow
Key KP_2	A	C	Direction South     FuncFvwmSelectWindow
Key KP_3	A	C	Direction SouthEast FuncFvwmSelectWindow
Key KP_4	A	C	Direction West      FuncFvwmSelectWindow
Key KP_5	A	C	Direction Center    FuncFvwmSelectWindow
Key KP_6	A	C	Direction East      FuncFvwmSelectWindow
Key KP_7	A	C	Direction NorthWest FuncFvwmSelectWindow
Key KP_8	A	C	Direction North     FuncFvwmSelectWindow
Key KP_9	A	C	Direction NorthEast FuncFvwmSelectWindow

# These {move,go} to {page,desk} bindings are experimental, may be changed.

# go to page, Ctrl+Alt+KP_N (these keys do not always work)
Key KP_1	A	CM	GotoPage 0 2
Key KP_2	A	CM	GotoPage 1 2
Key KP_3	A	CM	GotoPage 2 2
Key KP_4	A	CM	GotoPage 0 1
Key KP_5	A	CM	GotoPage 1 1
Key KP_6	A	CM	GotoPage 2 1
Key KP_7	A	CM	GotoPage 0 0
Key KP_8	A	CM	GotoPage 1 0
Key KP_9	A	CM	GotoPage 2 0
Key KP_0	A	CM	GotoPage prev

Key 1   	A	SCM	GotoPage 0 2
Key 2   	A	SCM	GotoPage 1 2
Key 3   	A	SCM	GotoPage 2 2
Key 4   	A	SCM	GotoPage 0 1
Key 5   	A	SCM	GotoPage 1 1
Key 6   	A	SCM	GotoPage 2 1
Key 7   	A	SCM	GotoPage 0 0
Key 8   	A	SCM	GotoPage 1 0
Key 9   	A	SCM	GotoPage 2 0
Key 0   	A	SCM	GotoPage prev

# move to page, Shift+Ctrl+KP_N
Key KP_1	A	SC	MoveToPage 0 2
Key KP_2	A	SC	MoveToPage 1 2
Key KP_3	A	SC	MoveToPage 2 2
Key KP_4	A	SC	MoveToPage 0 1
Key KP_5	A	SC	MoveToPage 1 1
Key KP_6	A	SC	MoveToPage 2 1
Key KP_7	A	SC	MoveToPage 0 0
Key KP_8	A	SC	MoveToPage 1 0
Key KP_9	A	SC	MoveToPage 2 0
Key KP_0	A	SC	MoveToPage prev

# move without the cursor, Shift+Alt+KP_N
Key KP_1	A	SM	Move w-1 w+1
Key KP_2	A	SM	Move w   w+1
Key KP_3	A	SM	Move w+1 w+1
Key KP_4	A	SM	Move w-1 w
Key KP_5	A	SM	Move w   w
Key KP_6	A	SM	Move w+1 w
Key KP_7	A	SM	Move w-1 w-1
Key KP_8	A	SM	Move w   w-1
Key KP_9	A	SM	Move w+1 w-1

# go to desk, Ctrl+Alt+N
Key 1   	A	CM	GotoDesk 0 0
Key 2   	A	CM	GotoDesk 0 1
Key 3   	A	CM	GotoDesk 0 2
Key 4   	A	CM	GotoDesk 0 3
Key 0   	A	CM	GotoDeskAndPage prev

# move to desk, Shift+Ctrl+N
Key 1   	A	SC	MoveToDesk 0 0
Key 2   	A	SC	MoveToDesk 0 1
Key 3   	A	SC	MoveToDesk 0 2
Key 4   	A	SC	MoveToDesk 0 3
Key 0   	A	SC	MoveToDesk prev

# keyboard accelerators
# Shift is needed to let apps (xwe, dosemu, kcalc) to handle Alt-FN keys
KeyMM F1  	A	M SM	Menu MenuFvwmRoot
KeyMM F2  	A	M SM	WindowList SelectOnRelease
KeyMM F3  	A	M SM	Menu MenuFvwmWindowOps
KeyMM F4  	A	M SM	Close
KeyMM F5  	A	M SM	RaiseLower
KeyMM F6  	A	M SM	FuncFvwmRestore
KeyMM F7  	A	M SM	Move
KeyMM F8  	A	M SM	Resize
KeyMM F9  	A	M SM	Iconify
KeyMM F10  	A	M SM	Pick FuncFvwmSimpleMaximize
KeyMM F11 	A	M SM	Module FvwmIdent
KeyMM F12 	A	M SM	FuncFvwmConsole

Key Tab 	A	M	WindowList Root c c NoDeskSort, SelectOnRelease Meta_L
Key Tab 	A	SM	WindowList Root c c OnlyListSkip, NoDeskSort, SelectOnRelease
Key Tab 	A	CM	Prev FuncFvwmSelectWindow
Key Tab 	A	SCM	Next FuncFvwmSelectWindow
Key Prior	A	M	Prev FuncFvwmSelectWindow
Key Next	A	M	Next FuncFvwmSelectWindow
Key F11 	A	SC	Pick FuncFvwmMaximizeFullScreen
Key F12 	A	SC	FuncFvwmConfirm `Refresh with no cache?` FuncFvwmThemesFreshUncached

# misc.
Key F8		A	SC	FuncFvwmShowAllColorsets
Key F9		A	SC	FuncFvwmShowColourTable

# ---------------------------------------------------------------------------
#     button	context	modifie	function

# pointer in Root
Mouse 1 	R	A	Menu MenuFvwmRoot
MouseXX 2 3	R	A	WindowList
MouseXX 3 2	R	A	Menu MenuFvwmWindowOps

MouseXX 2 3	R	C	Module FvwmPager -transient FvwmPager-Single * *
MouseXX 2 3	R	SC	Module FvwmPager -transient FvwmPager-Desker 0 3

# pointer on a EWMH desktop

# pointer in Window Buttons
# now in 'buttons' component
Mouse 1 	D	M	Menu MenuFvwmRoot
MouseXX 2 3	D	M	WindowList
MouseXX 3 2	D	M	Menu MenuFvwmWindowOps

MouseXX 2 3	D	MC	Module FvwmPager -transient FvwmPager-Single * *
MouseXX 2 3	D	MSC	Module FvwmPager -transient FvwmPager-Desker 0 3

# pointer in Window Decorations
FuncFvwmSetTitleBindings TSF
Mouse 1 	SF	A	FuncFvwmResizeOrRaiseOrShade
Mouse 1 	SF	S	FuncFvwmResizeOrRaiseOrShade Maximize

# pointer in Icon
Mouse 1 	I	A	FuncFvwmMoveOrIconify
MouseXX 2 3	I	A	FuncFvwmIconify
MouseXX 3 2	I	A	Menu MenuFvwmWindowOps2
Mouse 1 	I	S	FuncFvwmIconify
MouseXX 2 3	I	S	FuncFvwmIconifySameResource off
MouseXX 3 2	I	S	FuncFvwmIconifySameResource toggle

# pointer in Window (and in Icon for consistency)
Mouse 1 	WI	M	Menu MenuFvwmRoot
Mouse 1 	WI	CM	FuncFvwmMoveOrRaiseLower
MouseXX 2 3	WI	M	FuncFvwmMoveOrRaiseLower
MouseXX 3 2	WI	M	Menu MenuFvwmWindowOps

# ---------------------------------------------------------------------------
# We need to destroy the bindings to avoid current problems with fvwm.

DestroyFunc FuncFvwmStartBindings
AddToFunc   FuncFvwmStartBindings

DestroyFunc FuncFvwmStopBindings
AddToFunc   FuncFvwmStopBindings
+ I Key Left	A	CM	-
+ I Key Right	A	CM	-
+ I Key Up  	A	CM	-
+ I Key Down	A	CM	-
+ I Key Left	A	SCM	-
+ I Key Right	A	SCM	-
+ I Key Up  	A	SCM	-
+ I Key Down	A	SCM	-
+ I Key Left	A	SC	-
+ I Key Right	A	SC	-
+ I Key Up  	A	SC	-
+ I Key Down	A	SC	-
+ I Key Left	A	SM	-
+ I Key Right	A	SM	-
+ I Key Up  	A	SM	-
+ I Key Down	A	SM	-
+ I Key KP_1	A	C	-
+ I Key KP_2	A	C	-
+ I Key KP_3	A	C	-
+ I Key KP_4	A	C	-
+ I Key KP_5	A	C	-
+ I Key KP_6	A	C	-
+ I Key KP_7	A	C	-
+ I Key KP_8	A	C	-
+ I Key KP_9	A	C	-
+ I Key KP_1	A	CM	-
+ I Key KP_2	A	CM	-
+ I Key KP_3	A	CM	-
+ I Key KP_4	A	CM	-
+ I Key KP_5	A	CM	-
+ I Key KP_6	A	CM	-
+ I Key KP_7	A	CM	-
+ I Key KP_8	A	CM	-
+ I Key KP_9	A	CM	-
+ I Key KP_0	A	CM	-
+ I Key 1	A	SCM	-
+ I Key 2	A	SCM	-
+ I Key 3	A	SCM	-
+ I Key 4	A	SCM	-
+ I Key 5	A	SCM	-
+ I Key 6	A	SCM	-
+ I Key 7	A	SCM	-
+ I Key 8	A	SCM	-
+ I Key 9	A	SCM	-
+ I Key 0	A	SCM	-
+ I Key KP_1	A	SC	-
+ I Key KP_2	A	SC	-
+ I Key KP_3	A	SC	-
+ I Key KP_4	A	SC	-
+ I Key KP_5	A	SC	-
+ I Key KP_6	A	SC	-
+ I Key KP_7	A	SC	-
+ I Key KP_8	A	SC	-
+ I Key KP_9	A	SC	-
+ I Key KP_0	A	SC	-
+ I Key KP_1	A	SM	-
+ I Key KP_2	A	SM	-
+ I Key KP_3	A	SM	-
+ I Key KP_4	A	SM	-
+ I Key KP_5	A	SM	-
+ I Key KP_6	A	SM	-
+ I Key KP_7	A	SM	-
+ I Key KP_8	A	SM	-
+ I Key KP_9	A	SM	-
+ I Key 1   	A	CM	-
+ I Key 2   	A	CM	-
+ I Key 3   	A	CM	-
+ I Key 4   	A	CM	-
+ I Key 0   	A	CM	-
+ I Key 1   	A	SC	-
+ I Key 2   	A	SC	-
+ I Key 3   	A	SC	-
+ I Key 4   	A	SC	-
+ I Key 0   	A	SC	-
+ I KeyMM F1  	A	M SM	-
+ I KeyMM F2  	A	M SM	-
+ I KeyMM F3  	A	M SM	-
+ I KeyMM F4  	A	M SM	-
+ I KeyMM F5  	A	M SM	-
+ I KeyMM F6  	A	M SM	-
+ I KeyMM F7  	A	M SM	-
+ I KeyMM F8  	A	M SM	-
+ I KeyMM F9  	A	M SM	-
+ I KeyMM F10 	A	M SM	-
+ I KeyMM F11 	A	M SM	-
+ I KeyMM F12 	A	M SM	-
+ I Key Tab 	A	M	-
+ I Key Tab 	A	SM	-
+ I Key Tab 	A	CM	-
+ I Key Tab 	A	SCM	-
+ I Key Prior	A	M	-
+ I Key Next	A	M	-
+ I Mouse 1 	R	A	-
+ I MouseXX 2 3	R	A	-
+ I MouseXX 3 2	R	A	-
+ I MouseXX 2 3	R	C	-
+ I MouseXX 2 3	R	SC	-
+ I Mouse 1 	D	M	-
+ I MouseXX 2 3	D	M	-
+ I MouseXX 3 2	D	M	-
+ I MouseXX 2 3	D	MC	-
+ I MouseXX 2 3	D	MSC	-
+ I FuncFvwmUnsetTitleBindings TSF
+ I Mouse 1 	SF	A	-
+ I Mouse 1 	I	A	-
+ I MouseXX 2 3	I	A	-
+ I MouseXX 3 2	I	A	-
+ I Mouse 1 	I	S	-
+ I MouseXX 2 3	I	S	-
+ I MouseXX 3 2	I	S	-
+ I Mouse 1 	WI	M	-
+ I Mouse 1 	WI	CM	-
+ I MouseXX 2 3	WI	M	-
+ I MouseXX 3 2	WI	M	-
