at commit 84db1d64
| 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)) |