Compare
04b30b0b99651a5c8fbb26a581401eb7ef1e96a2..84db1d645616d0023971f959191a4b469c07c5b3
clwm-ext: pointer-placement-mixin
Raymond E. Pasco <ray@ameretat.dev> · 2026-10-27 10:57 UTC
4 files changed,
+46
−3
modified clwm-ext.lisp
| @@ -42,4 +42,6 @@ | |||
| 42 | 42 | #:screen-geometry-changed #:area-at #:work-area | |
| 43 | 43 | #:geometry-bounds #:constrain-move #:constrain-resize | |
| 44 | 44 | ;; screen-geometry using commands | |
| 45 | - | #:bounded-drag-move #:bounded-drag-resize)) | |
| 45 | + | #:bounded-drag-move #:bounded-drag-resize | |
| 46 | + | ;; pointer-placement-mixin | |
| 47 | + | #:pointer-placement-mixin)) | |
added clwm-ext/pointer-placement-mixin.lisp mode 100644
| @@ -0,0 +1,39 @@ | |||
| 1 | + | ;;;; common lisp window manager | |
| 2 | + | ;;;; | |
| 3 | + | ;;;; place new clients under the pointer by default | |
| 4 | + | ||
| 5 | + | (in-package #:clwm-ext) | |
| 6 | + | ||
| 7 | + | (defclass pointer-placement-mixin (screen-geometry-mixin) () | |
| 8 | + | (:documentation | |
| 9 | + | "Place new clients under the pointer if they don't place themselves. | |
| 10 | + | Keep them inside the SCREEN-GEOMETRY-MIXIN work area.")) | |
| 11 | + | ||
| 12 | + | (defmethod place-client ((wm pointer-placement-mixin) client) | |
| 13 | + | (let ((hints (client-normal-hints client))) | |
| 14 | + | (unless (and | |
| 15 | + | hints | |
| 16 | + | ;; ridiculously long names | |
| 17 | + | (or (xlib:wm-size-hints-user-specified-position-p hints) | |
| 18 | + | ;; for some reason, not exported | |
| 19 | + | (xlib::wm-size-hints-program-specified-position-p | |
| 20 | + | hints))) | |
| 21 | + | (multiple-value-bind (x y width height) | |
| 22 | + | (client-geometry wm client) | |
| 23 | + | (declare (ignore x y)) | |
| 24 | + | (multiple-value-bind (pointer-x pointer-y) | |
| 25 | + | (xlib:query-pointer (root wm)) | |
| 26 | + | (multiple-value-bind (area-x area-y area-width area-height) | |
| 27 | + | (work-area wm (area-at wm pointer-x pointer-y)) | |
| 28 | + | (flet ((inside (position size start extent) | |
| 29 | + | (max start | |
| 30 | + | (min position (- (+ start extent) size))))) | |
| 31 | + | (configure-client | |
| 32 | + | wm client | |
| 33 | + | :x (inside | |
| 34 | + | (- pointer-x (floor width 2)) | |
| 35 | + | width area-x area-width) | |
| 36 | + | :y (inside | |
| 37 | + | (- pointer-y (floor height 2)) | |
| 38 | + | height area-y area-height)))))))) | |
| 39 | + | (call-next-method)) | |
modified clwm.asd
| @@ -25,5 +25,6 @@ | |||
| 25 | 25 | (:file "mousebinds-mixin") | |
| 26 | 26 | (:file "warp-pointer-mixin") | |
| 27 | 27 | (:file "alt-tab-ring-mixin") | |
| 28 | - | (:file "screen-geometry-mixin"))) | |
| 28 | + | (:file "screen-geometry-mixin") | |
| 29 | + | (:file "pointer-placement-mixin"))) | |
| 29 | 30 | (:file "clwm-user"))) | |
modified example-init.lisp
| @@ -4,7 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | 5 | (in-package #:clwm-user) | |
| 6 | 6 | ||
| 7 | - | (defclass my-wm (screen-geometry-mixin | |
| 7 | + | (defclass my-wm (pointer-placement-mixin | |
| 8 | + | screen-geometry-mixin | |
| 8 | 9 | alt-tab-ring-mixin | |
| 9 | 10 | warp-pointer-mixin | |
| 10 | 11 | mousebinds-mixin | |