Compare

51ccea63d66e8b7c5b540df6d53055a6bfa8440d..a262df09cc4cce548e6e94456d969d5c7ecb6ece

clwm-ext: pointer-keybinds-mixin

Raymond E. Pasco <ray@ameretat.dev> · 2026-10-27 08:18 UTC

Browse files
5 files changed, +67 −4
modified clwm-ext.lisp
@@ -20,4 +20,9 @@
20 20 ;; bindings
21 21 #:*lock-modifiers* #:*key-names*
22 22 ;; keybinds-mixin
23 - #:keybinds-mixin #:key-bindings #:grab-keys #:call-key-command))
23 + #:keybinds-mixin #:key-bindings #:grab-keys #:call-key-command
24 + ;; pointer-keybinds-mixin
25 + #:pointer-keybinds-mixin
26 + ;; commands
27 + #:spawn-command #:close-command #:hide-command
28 + #:raise-command #:lower-command))
added clwm-ext/commands.lisp mode 100644
@@ -0,0 +1,38 @@
1 + ;;;; common lisp window manager
2 + ;;;;
3 + ;;;; forms intended to be executed as wm commands
4 +
5 + (in-package #:clwm-ext)
6 +
7 + ;;; respecting POINTER-KEYBINDS-MIXIN convention
8 +
9 + (defun spawn-command (program &rest args)
10 + "Spawns a program.
11 + Respects POINTER-KEYBINDS-MIXIN convention."
12 + (lambda (wm &rest pointer)
13 + (declare (ignore pointer))
14 + (apply #'spawn wm program args)))
15 +
16 + (defun close-command (wm client x y)
17 + "Close the client under the pointer.
18 + Respects POINTER-KEYBINDS-MIXIN convention."
19 + (declare (ignore x y))
20 + (when client (close-client wm client)))
21 +
22 + (defun hide-command (wm client x y)
23 + "Hide the client under the pointer.
24 + Respects POINTER-KEYBINDS-MIXIN convention."
25 + (declare (ignore x y))
26 + (when client (hide-client wm client)))
27 +
28 + (defun raise-command (wm client x y)
29 + "Raise the client under the pointer.
30 + Respects POINTER-KEYBINDS-MIXIN convention."
31 + (declare (ignore x y))
32 + (when client (configure-client wm client :stack-mode :above)))
33 +
34 + (defun lower-command (wm client x y)
35 + "Lower the client under the pointer.
36 + Respects POINTER-KEYBINDS-MIXIN convention."
37 + (declare (ignore x y))
38 + (when client (configure-client wm client :stack-mode :below)))
added clwm-ext/pointer-keybinds-mixin.lisp mode 100644
@@ -0,0 +1,14 @@
1 + ;;;; common lisp window manager
2 + ;;;;
3 + ;;;; keybinds that know where the pointer is
4 + ;;;; the convention is (lambda (wm client x y) ...)
5 +
6 + (in-package #:clwm-ext)
7 +
8 + (defclass pointer-keybinds-mixin (keybinds-mixin) ()
9 + (:documentation "Keybinds which know where the pointer is,
10 + and what client is under it."))
11 +
12 + (defmethod call-key-command ((wm pointer-keybinds-mixin) command
13 + &rest e &key root-x root-y)
14 + (funcall command wm (apply #'event-client wm :key-press e) root-x root-y))
modified clwm.asd
@@ -19,5 +19,7 @@
19 19 (:file "ignored-clients-mixin")
20 20 (:file "interaction-mixin")
21 21 (:file "bindings")
22 - (:file "keybinds-mixin")))
22 + (:file "keybinds-mixin")
23 + (:file "pointer-keybinds-mixin")
24 + (:file "commands")))
23 25 (:file "clwm-user")))
modified example-init.lisp
@@ -4,7 +4,7 @@
4 4
5 5 (in-package #:clwm-user)
6 6
7 - (defclass my-wm (keybinds-mixin
7 + (defclass my-wm (pointer-keybinds-mixin
8 8 ignored-clients-mixin
9 9 focus-tracking-mixin
10 10 sloppy-focus-follows-mouse-mixin
@@ -12,7 +12,11 @@
12 12 ())
13 13
14 14 (defmethod key-bindings append ((wm my-wm))
15 - `(((:control :mod-1 #\Return) . ,(lambda (wm) (spawn wm "xterm")))))
15 + `(((:control :mod-1 #\Return) . ,(spawn-command "xterm"))
16 + ((:control :mod-1 #\x) . close-command)
17 + ((:mod-1 #\Return) . hide-command)
18 + ((:mod-1 :up) . raise-command)
19 + ((:mod-1 :down) . lower-command)))
16 20
17 21 (run-wm 'my-wm)
18 22