45d40d6d4efd5e48f455dd3378baca2350428153
[clfswm.git] / src / bindings.lisp
blob45d40d6d4efd5e48f455dd3378baca2350428153
1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
3 ;;;
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Bindings keys and mouse
6 ;;;
7 ;;; Note: Mod-1 is the Alt or Meta key, Mod-2 is the Numlock key.
8 ;;; --------------------------------------------------------------------------
9 ;;;
10 ;;; (C) 2012 Philippe Brochard <pbrochard@common-lisp.net>
11 ;;;
12 ;;; This program is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or
15 ;;; (at your option) any later version.
16 ;;;
17 ;;; This program is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with this program; if not, write to the Free Software
24 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 ;;;
26 ;;; --------------------------------------------------------------------------
28 (in-package :clfswm)
30 ;;;,-----
31 ;;;| CONFIG - Bindings main mode
32 ;;;`-----
35 (add-hook *binding-hook* 'init-*main-keys* 'init-*main-mouse*)
38 (defun help-on-clfswm ()
39 "Open the help and info window"
40 (open-menu (find-menu 'help-menu)))
43 (defun set-default-main-keys ()
44 (define-main-key ("F1" :mod-1) 'help-on-clfswm)
45 (define-main-key ("Home" :mod-1 :control :shift) 'exit-clfswm)
46 (define-main-key ("Right" :mod-1) 'select-next-brother)
47 (define-main-key ("Left" :mod-1) 'select-previous-brother)
48 (define-main-key ("Down" :mod-1) 'select-previous-level)
49 (define-main-key ("Up" :mod-1) 'select-next-level)
51 (define-main-key ("Right" :mod-1 :shift) 'select-next-brother-take-current)
52 (define-main-key ("Left" :mod-1 :shift) 'select-previous-brother-take-current)
54 (define-main-key ("Left" :control :mod-1) 'select-brother-spatial-move-left)
55 (define-main-key ("Right" :control :mod-1) 'select-brother-spatial-move-right)
56 (define-main-key ("Up" :control :mod-1) 'select-brother-spatial-move-up)
57 (define-main-key ("Down" :control :mod-1) 'select-brother-spatial-move-down)
59 (define-main-key ("Left" :control :mod-1 :shift) 'select-brother-spatial-move-left-take-current)
60 (define-main-key ("Right" :control :mod-1 :shift) 'select-brother-spatial-move-right-take-current)
61 (define-main-key ("Up" :control :mod-1 :shift) 'select-brother-spatial-move-up-take-current)
62 (define-main-key ("Down" :control :mod-1 :shift) 'select-brother-spatial-move-down-take-current)
64 (define-main-key ("Tab" :mod-1) 'select-next-child)
65 (define-main-key ("Tab" :mod-1 :shift) 'select-previous-child)
66 (define-main-key ("Tab" :mod-1 :control) 'select-next-subchild)
67 (define-main-key ("Return" :mod-1) 'enter-frame)
68 (define-main-key ("Return" :mod-1 :shift) 'leave-frame)
69 (define-main-key ("Return" :mod-1 :control) 'frame-toggle-maximize)
70 (define-main-key ("Return" :mod-5) 'frame-toggle-maximize)
71 (define-main-key ("Page_Up" :mod-1) 'frame-select-previous-child)
72 (define-main-key ("Page_Down" :mod-1) 'frame-select-next-child)
73 (define-main-key ("Page_Up" :mod-1 :control) 'frame-lower-child)
74 (define-main-key ("Page_Down" :mod-1 :control) 'frame-raise-child)
75 (define-main-key ("Home" :mod-1) 'switch-to-root-frame)
76 (define-main-key ("Home" :mod-1 :shift) 'switch-and-select-root-frame)
77 (define-main-key ("F10" :mod-1) 'fast-layout-switch)
78 (define-main-key ("F10" :shift :control) 'toggle-show-root-frame)
79 (define-main-key ("F10") 'expose-windows-mode)
80 (define-main-key ("F10" :control) 'expose-all-windows-mode)
81 (define-main-key ("F12" :control) 'present-clfswm-terminal)
82 (define-main-key ("F12" :shift) 'show-all-frames-info-key)
83 (define-main-key ("F12" :shift :mod-1) 'show-all-frames-info)
84 (define-main-key ("b" :mod-1) 'banish-pointer)
85 ;; Escape
86 (define-main-key ("Escape" :control) 'ask-close/kill-current-window)
87 ;; Second mode
88 (define-main-key (#\t :mod-1) 'second-key-mode)
89 (define-main-key ("less" :control) 'second-key-mode)
90 ;; Bind or jump functions
91 (define-main-key ("1" :mod-1) 'bind-or-jump 1)
92 (define-main-key ("2" :mod-1) 'bind-or-jump 2)
93 (define-main-key ("3" :mod-1) 'bind-or-jump 3)
94 (define-main-key ("4" :mod-1) 'bind-or-jump 4)
95 (define-main-key ("5" :mod-1) 'bind-or-jump 5)
96 (define-main-key ("6" :mod-1) 'bind-or-jump 6)
97 (define-main-key ("7" :mod-1) 'bind-or-jump 7)
98 (define-main-key ("8" :mod-1) 'bind-or-jump 8)
99 (define-main-key ("9" :mod-1) 'bind-or-jump 9)
100 (define-main-key ("0" :mod-1) 'bind-or-jump 10))
102 (add-hook *binding-hook* 'set-default-main-keys)
108 ;;; Mouse actions
109 (defun mouse-click-to-focus-and-move-window (window root-x root-y)
110 "Move and focus the current child - Create a new frame on the root window"
111 (declare (ignore window))
112 (stop-button-event)
113 (mouse-focus-move/resize-generic root-x root-y #'move-frame t))
116 (defun mouse-click-to-focus-and-resize-window (window root-x root-y)
117 "Resize and focus the current child - Create a new frame on the root window"
118 (declare (ignore window))
119 (stop-button-event)
120 (mouse-focus-move/resize-generic root-x root-y #'resize-frame t))
123 (defun mouse-click-to-focus-and-move-window-constrained (window root-x root-y)
124 "Move (constrained by other frames) and focus the current child - Create a new frame on the root window"
125 (declare (ignore window))
126 (stop-button-event)
127 (mouse-focus-move/resize-generic root-x root-y #'move-frame-constrained t))
130 (defun mouse-click-to-focus-and-resize-window-constrained (window root-x root-y)
131 "Resize (constrained by other frames) and focus the current child - Create a new frame on the root window"
132 (declare (ignore window))
133 (stop-button-event)
134 (mouse-focus-move/resize-generic root-x root-y #'resize-frame-constrained t))
138 (defun set-default-main-mouse ()
139 (define-main-mouse (1) 'mouse-click-to-focus-and-move)
140 (define-main-mouse (2) 'mouse-middle-click)
141 (define-main-mouse (3) 'mouse-click-to-focus-and-resize)
142 (define-main-mouse (1 :mod-1) 'mouse-click-to-focus-and-move-window)
143 (define-main-mouse (3 :mod-1) 'mouse-click-to-focus-and-resize-window)
144 (define-main-mouse (1 :mod-1 :shift) 'mouse-click-to-focus-and-move-window-constrained)
145 (define-main-mouse (3 :mod-1 :shift) 'mouse-click-to-focus-and-resize-window-constrained)
146 (define-main-mouse (1 :control :mod-1) 'mouse-move-child-over-frame)
147 (define-main-mouse (4) 'mouse-select-next-level)
148 (define-main-mouse (5) 'mouse-select-previous-level)
149 (define-main-mouse (4 :mod-1) 'mouse-enter-frame)
150 (define-main-mouse (5 :mod-1) 'mouse-leave-frame)
151 (define-main-mouse (4 :mod-1 :control) 'dec-transparency)
152 (define-main-mouse (5 :mod-1 :control) 'inc-transparency)
153 (define-main-mouse (4 :mod-1 :control :shift) 'dec-transparency-slow)
154 (define-main-mouse (5 :mod-1 :control :shift) 'inc-transparency-slow))
156 (add-hook *binding-hook* 'set-default-main-mouse)