Documentation update
[clfswm.git] / src / bindings-second-mode.lisp
blob5a7fb544509f9d68765fd6d8a845a8a52152e2d3
1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
3 ;;;
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Bindings keys and mouse for second mode
6 ;;;
7 ;;; Note: Mod-1 is the Alt or Meta key, Mod-2 is the Numlock key.
8 ;;; --------------------------------------------------------------------------
9 ;;;
10 ;;; (C) 2010 Philippe Brochard <hocwp@free.fr>
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 ;;;| Second keys
32 ;;;|
33 ;;;| CONFIG - Second mode bindings
34 ;;;`-----
35 (add-hook *binding-hook* 'init-*second-keys* 'init-*second-mouse*)
38 (defun open-frame-menu ()
39 "Open the frame menu"
40 (open-menu (find-menu 'frame-menu)))
42 (defun open-window-menu ()
43 "Open the window menu"
44 (open-menu (find-menu 'window-menu)))
46 (defun open-action-by-name-menu ()
47 "Open the action by name menu"
48 (open-menu (find-menu 'action-by-name-menu)))
50 (defun open-action-by-number-menu ()
51 "Open the action by number menu"
52 (open-menu (find-menu 'action-by-number-menu)))
54 (defun open-frame-pack-menu ()
55 "Open the frame pack menu"
56 (open-menu (find-menu 'frame-pack-menu)))
58 (defun open-frame-fill-menu ()
59 "Open the frame fill menu"
60 (open-menu (find-menu 'frame-fill-menu)))
62 (defun open-frame-resize-menu ()
63 "Open the frame resize menu"
64 (open-menu (find-menu 'frame-resize-menu)))
66 (defun tile-current-frame ()
67 "Tile the current frame"
68 (set-layout-once #'tile-layout)
69 (leave-second-mode))
71 ;;; default shell programs
72 (defmacro define-shell (key name docstring cmd)
73 "Define a second key to start a shell command"
74 `(define-second-key ,key
75 (defun ,name ()
76 ,docstring
77 (setf *second-mode-program* ,cmd)
78 (leave-second-mode))))
81 (defun set-default-second-keys ()
82 (define-second-key ("F1" :mod-1) 'help-on-clfswm)
83 (define-second-key ("m") 'open-menu)
84 (define-second-key ("less") 'open-menu)
85 (define-second-key ("less" :control) 'open-menu)
86 (define-second-key ("f") 'open-frame-menu)
87 (define-second-key ("w") 'open-window-menu)
88 (define-second-key ("n") 'open-action-by-name-menu)
89 (define-second-key ("u") 'open-action-by-number-menu)
90 (define-second-key ("p") 'open-frame-pack-menu)
91 (define-second-key ("l") 'open-frame-fill-menu)
92 (define-second-key ("r") 'open-frame-resize-menu)
93 ;;(define-second-key (#\g :control) 'stop-all-pending-actions)
94 (define-second-key ("i") 'identify-key)
95 (define-second-key ("colon") 'eval-from-query-string)
96 (define-second-key ("exclam") 'run-program-from-query-string)
97 (define-second-key ("Return") 'leave-second-mode)
98 (define-second-key ("Escape") 'leave-second-mode)
99 (define-second-key ("g" :control) 'leave-second-mode)
100 (define-second-key ("t") 'tile-current-frame)
101 (define-second-key ("Home" :mod-1 :control :shift) 'exit-clfswm)
102 (define-second-key ("Right" :mod-1) 'select-next-brother)
103 (define-second-key ("Left" :mod-1) 'select-previous-brother)
104 (define-second-key ("Down" :mod-1) 'select-previous-level)
105 (define-second-key ("Up" :mod-1) 'select-next-level)
107 (define-second-key ("Right") 'speed-mouse-right)
108 (define-second-key ("Left") 'speed-mouse-left)
109 (define-second-key ("Down") 'speed-mouse-down)
110 (define-second-key ("Up") 'speed-mouse-up)
111 (define-second-key ("Left" :control) 'speed-mouse-undo)
112 (define-second-key ("Up" :control) 'speed-mouse-first-history)
113 (define-second-key ("Down" :control) 'speed-mouse-reset)
115 (define-second-key ("Tab" :mod-1) 'select-next-child)
116 (define-second-key ("Tab" :mod-1 :shift) 'select-previous-child)
117 (define-second-key ("Tab" :mod-1 :control) 'select-next-subchild)
118 (define-second-key ("Tab" :shift) 'switch-to-last-child)
119 (define-second-key ("Return" :mod-1) 'enter-frame)
120 (define-second-key ("Return" :mod-1 :shift) 'leave-frame)
121 (define-second-key ("Return" :mod-5) 'frame-toggle-maximize)
122 (define-second-key ("Page_Up" :mod-1) 'frame-lower-child)
123 (define-second-key ("Page_Down" :mod-1) 'frame-raise-child)
124 (define-second-key ("Home" :mod-1) 'switch-to-root-frame)
125 (define-second-key ("Home" :mod-1 :shift) 'switch-and-select-root-frame)
126 (define-second-key ("Menu") 'toggle-show-root-frame)
127 (define-second-key (#\b :mod-1) 'banish-pointer)
128 (define-second-key (#\o) 'set-open-in-new-frame-in-parent-frame-nw-hook)
129 (define-second-key (#\o :control) 'set-open-in-new-frame-in-root-frame-nw-hook)
130 (define-second-key (#\a) 'add-default-frame)
131 ;; Escape
132 (define-second-key ("Escape" :control) 'ask-close/kill-current-window)
133 ;; Selection
134 (define-second-key ("x" :control) 'cut-current-child)
135 (define-second-key ("x" :control :mod-1) 'clear-selection)
136 (define-second-key ("c" :control) 'copy-current-child)
137 (define-second-key ("v" :control) 'paste-selection)
138 (define-second-key ("v" :control :shift) 'paste-selection-no-clear)
139 (define-second-key ("Delete" :control) 'remove-current-child)
140 (define-second-key ("Delete") 'delete-current-child)
141 (define-shell (#\c) b-start-xterm "start an xterm" "cd $HOME && exec xterm")
142 (define-shell (#\e) b-start-emacs "start emacs" "cd $HOME && exec emacs")
143 (define-shell (#\e :control) b-start-emacsremote
144 "start an emacs for another user"
145 "exec xterm -e emacsremote")
146 (define-shell (#\h) b-start-xclock "start an xclock" "exec xclock -d")
147 (define-second-key ("F10" :mod-1) 'fast-layout-switch)
148 (define-second-key ("F10" :shift :control) 'toggle-show-root-frame)
149 (define-second-key ("F10") 'expose-windows-current-child-mode)
150 (define-second-key ("F10" :control) 'expose-windows-mode)
151 (define-second-key ("F10" :control :shift) 'expose-all-windows-mode)
152 (define-second-key ("L2" :shift) 'show-all-frames-info-key)
153 (define-second-key ("L2" :shift :mod-1) 'show-all-frames-info)
154 ;; Bind or jump functions
155 (define-second-key ("1" :mod-1) 'bind-or-jump 1)
156 (define-second-key ("2" :mod-1) 'bind-or-jump 2)
157 (define-second-key ("3" :mod-1) 'bind-or-jump 3)
158 (define-second-key ("4" :mod-1) 'bind-or-jump 4)
159 (define-second-key ("5" :mod-1) 'bind-or-jump 5)
160 (define-second-key ("6" :mod-1) 'bind-or-jump 6)
161 (define-second-key ("7" :mod-1) 'bind-or-jump 7)
162 (define-second-key ("8" :mod-1) 'bind-or-jump 8)
163 (define-second-key ("9" :mod-1) 'bind-or-jump 9)
164 (define-second-key ("0" :mod-1) 'bind-or-jump 10))
166 (add-hook *binding-hook* 'set-default-second-keys)
171 ;;; Mouse action
172 (defun sm-mouse-click-to-focus-and-move (window root-x root-y)
173 "Move and focus the current child - Create a new frame on the root window.
174 Or do corners actions"
175 (declare (ignore window))
176 (or (do-corner-action root-x root-y *corner-second-mode-left-button*)
177 (mouse-focus-move/resize-generic root-x root-y #'move-frame nil)))
179 (defun sm-mouse-click-to-focus-and-resize (window root-x root-y)
180 "Resize and focus the current child - Create a new frame on the root window.
181 Or do corners actions"
182 (declare (ignore window))
183 (or (do-corner-action root-x root-y *corner-second-mode-right-button*)
184 (mouse-focus-move/resize-generic root-x root-y #'resize-frame nil)))
186 (defun sm-mouse-middle-click (window root-x root-y)
187 "Do actions on corners"
188 (declare (ignore window))
189 (or (do-corner-action root-x root-y *corner-second-mode-middle-button*)
190 (replay-button-event)))
195 (defun sm-mouse-select-next-level (window root-x root-y)
196 "Select the next level in frame"
197 (declare (ignore window root-x root-y))
198 (select-next-level))
203 (defun sm-mouse-select-previous-level (window root-x root-y)
204 "Select the previous level in frame"
205 (declare (ignore window root-x root-y))
206 (select-previous-level))
210 (defun sm-mouse-enter-frame (window root-x root-y)
211 "Enter in the selected frame - ie make it the root frame"
212 (declare (ignore window root-x root-y))
213 (enter-frame))
217 (defun sm-mouse-leave-frame (window root-x root-y)
218 "Leave the selected frame - ie make its parent the root frame"
219 (declare (ignore window root-x root-y))
220 (leave-frame))
223 (defun sm-mouse-click-to-focus-and-move-window (window root-x root-y)
224 "Move and focus the current child - Create a new frame on the root window"
225 (declare (ignore window))
226 (mouse-focus-move/resize-generic root-x root-y #'move-frame t))
229 (defun sm-mouse-click-to-focus-and-resize-window (window root-x root-y)
230 "Resize and focus the current child - Create a new frame on the root window"
231 (declare (ignore window))
232 (mouse-focus-move/resize-generic root-x root-y #'resize-frame t))
236 (defun set-default-second-mouse ()
237 (define-second-mouse (1) 'sm-mouse-click-to-focus-and-move)
238 (define-second-mouse (2) 'sm-mouse-middle-click)
239 (define-second-mouse (3) 'sm-mouse-click-to-focus-and-resize)
240 (define-second-mouse (1 :mod-1) 'sm-mouse-click-to-focus-and-move-window)
241 (define-second-mouse (3 :mod-1) 'sm-mouse-click-to-focus-and-resize-window)
242 (define-second-mouse (1 :control :mod-1) 'mouse-move-child-over-frame)
243 (define-second-mouse (4) 'sm-mouse-select-next-level)
244 (define-second-mouse (5) 'sm-mouse-select-previous-level)
245 (define-second-mouse (4 :mod-1) 'sm-mouse-enter-frame)
246 (define-second-mouse (5 :mod-1) 'sm-mouse-leave-frame))
248 (add-hook *binding-hook* 'set-default-second-mouse)