DEF globalKeyBindings {
   TaskSwitcher               : KeyPress = Tab & Alt_L,
   MenuRemapFocused(rootmenu) : KeyPress = Escape & Control_L
}

DEF defaultAllWindows {
   Raise                  : ButtonPress = Button1 & Alt_L,
   StartOpaqueMove        : ButtonPress = Button1 & Alt_L,
   StartOpaqueResizeRight : ButtonPress = Button3 & Alt_L,
   Lower                  : ButtonPress = Button2 & Alt_L,
   EndMoveResize          : ButtonRelease = Button1 & MoveResizeMask,
   EndMoveResize          : ButtonRelease = Button3 & MoveResizeMask
}

DEF defaultAllDecor {
	defaultAllWindows,
   Raise             : ButtonPress = Button1 & !Alt_L,
   Focus             : ButtonPress = Button1 & !Alt_L,
   Lower             : ButtonPress = Button2 & !Alt_L,
   MenuRemap(window) : ButtonPress = Button3 & !Alt_L,
   MenuUnmap(window) : ButtonPress = Button1 & !Alt_L,
   MenuUnmap(window) : ButtonPress = Button2 & !Alt_L
}

DEF defaultAllTitle {
   defaultAllDecor,
   StartOpaqueMove : ButtonPress = Button1 & !Alt_L,
   ToggleShade     : DoubleClick = Button1 & !Alt_L
}

window.frame { 
   defaultAllDecor,
   Focus : EnterNotify
}
window.title { defaultAllTitle }
window.label { defaultAllTitle }
window.handle { defaultAllDecor }
window.leftgrip { 
   defaultAllWindows,
   StartOpaqueResizeLeft : ButtonPress = Button1 & !Alt_L
}
window.rightgrip { 
   defaultAllWindows,
   StartOpaqueResizeRight : ButtonPress = Button1 & !Alt_L
}
window.button0 {
   defaultAllWindows,
   ToggleShade : ButtonRelease = Button1
}
window.button1 { 
   defaultAllWindows, 
   Close : ButtonRelease = Button1
}
window.button2 {
   defaultAllWindows,
   ToggleMaximize : ButtonRelease = Button1,
   Raise          : ButtonRelease = Button1
}
window.passiveclient { 
   defaultAllWindows,
   MoveToSmartPlace : MapRequest & !Control_L,
   Raise            : MapRequest,
   StartMove        : MapRequest & Control_L,
   Focus            : MapRequest & Control_L  
}
window.activeclient {
   defaultAllWindows,
   ToggleShade              : KeyPress = F1 & Alt_L,
   ToggleMaximize           : KeyPress = F2 & Alt_L,
   Raise                    : KeyPress = F2 & Alt_L,
   MenuRemapFocused(window) : KeyPress = F3 & Alt_L,
   Close                    : KeyPress = F4 & Alt_L,
   Kill                     : KeyPress = F10 & Alt_L,
   globalKeyBindings
}

root {
   MenuRemap(rootmenu) : ButtonPress = Button3,
   MenuUnmap(rootmenu) : ButtonPress = Button1,
   StartViewportMove   : ButtonPress = Button2,
   EndMoveResize       : ButtonRelease = Button2 & MoveResizeMask,
   globalKeyBindings
}

westedge { ViewportLeft : EnterNotify }

eastedge { ViewportRight : EnterNotify }
 
northedge { ViewportUp : EnterNotify [250 : LeaveNotify] }
 
southedge { ViewportDown : EnterNotify [250 : LeaveNotify] }

DEF allMenuWindows {
   Raise           : ButtonPress = Button1 & Alt_L,
   StartOpaqueMove : ButtonPress = Button1 & Alt_L,
   UnLink          : ButtonPress = Button1 & Alt_L,
   EndMoveResize   : ButtonRelease = Button1 & MoveResizeMask
}

DEF allMenuItems {
   allMenuWindows,
   Exec         : ButtonRelease = AnyButton,
   Func         : ButtonRelease = AnyButton,
   NextItem     : KeyPress = Tab,
   NextItem     : KeyPress = Down,
   PreviousItem : KeyPress = Up,
   UnmapSubs    : KeyPress = Left,
   UnmapFocused : KeyPress = Left,
   UnmapTree    : KeyPress = Escape,
   Exec         : KeyPress = Return,
   Func         : KeyPress = Return
} 

menu.title {
   allMenuWindows,
   Raise           : ButtonPress = Button1,
   UnLink          : ButtonPress = Button1 & !Alt_L,
   StartOpaqueMove : ButtonPress = Button1 & !Alt_L,
   UnmapSubs       : ButtonPress = Button3,
   Unmap           : ButtonPress = Button3
}
menu.item {
   allMenuItems,
   UnmapSubs    : EnterNotify,
   UnmapTree    : ButtonRelease = AnyButton,
   UnmapFocused : KeyRelease = Alt_L,
   Func         : KeyRelease = Alt_L,
   UnmapTree    : KeyPress = Return
}
menu.checkbox {
   allMenuItems,
   UnmapSubs : EnterNotify,
   Exec      : KeyPress = space,
   Func      : KeyPress = space
}
menu.sub {
   allMenuItems,
   MapSubOnly      : EnterNotify,
   RemapSub        : ButtonPress = AnyButton,
   RemapSubFocused : KeyPress = Right,
   RemapSubFocused : KeyPress = Return
}

n/^desktop_window$/.passiveclient {
   MenuRemap(rootmenu)  : ButtonPress = Button3 & !Control_L,
   StartViewportMove    : ButtonPress = Button2 & !Control_L,
   *MenuUnmap(rootmenu) : ButtonPress = Button1,
   Focus                : ButtonPress = Button1,
   EndMoveResize        : ButtonRelease = Button2 & MoveResizeMask
}

n/^desktop_window$/.activeclient {
   globalKeyBindings,
   MenuRemap(rootmenu)  : ButtonPress = Button3 & !Control_L,
   StartViewportMove    : ButtonPress = Button2 & !Control_L,
   *MenuUnmap(rootmenu) : ButtonPress = Button1
}

n/^desktop_window$/.frame {}

n/^panel_window$/.passiveclient {
   *Focus : ButtonPress = Button1
}

n/^panel_window$/.activeclient {
   globalKeyBindings,
   EndMoveResize : ButtonRelease = Button1 & MoveResizeMask,
   EndMoveResize : ButtonRelease = Button3 & MoveResizeMask
}

n/^panel_window$/.frame {}

n/^KDE Desktop$/.passiveclient {
   MenuRemap(rootmenu)  : ButtonPress = Button3 & !Control_L,
   StartViewportMove    : ButtonPress = Button2 & !Control_L,
   *MenuUnmap(rootmenu) : ButtonPress = Button1,
   Focus                : ButtonPress = Button1,
   EndMoveResize        : ButtonRelease = Button2 & MoveResizeMask
}

n/^KDE Desktop$/.activeclient {
   globalKeyBindings,
   MenuRemap(rootmenu)  : ButtonPress = Button3 & !Control_L,
   StartViewportMove    : ButtonPress = Button2 & !Control_L,
   *MenuUnmap(rootmenu) : ButtonPress = Button1
}

n/^KDE Desktop$/.frame {}

n/^kicker$/.passiveclient {
   *Focus : ButtonPress = Button1
}

n/^kicker$/.activeclient {
   globalKeyBindings,
   EndMoveResize : ButtonRelease = Button1 & MoveResizeMask,
   EndMoveResize : ButtonRelease = Button3 & MoveResizeMask
}

n/^kicker$/.frame {}
