diff options
| author | 2026-01-14 17:27:04 -0800 | |
|---|---|---|
| committer | 2026-01-14 17:27:04 -0800 | |
| commit | a8b395459f44af418f70ea8f405f1880905194db (patch) | |
| tree | 5683caf88f81646376156d0d2ec0affa253b06c7 | |
| parent | 7719c52e29d5370cbc4a3201f2899af4fe730cdf (diff) | |
| download | new-dotfiles-a8b395459f44af418f70ea8f405f1880905194db.tar.gz new-dotfiles-a8b395459f44af418f70ea8f405f1880905194db.zip | |
stumpwm: Move always-on-top floating windows aside on focus
When a window is focused and there are overlapping floating windows, move those
windows aside, making sure not to move them off-screen.
| -rw-r--r-- | oni/home/services/stumpwm/stumpwm.lisp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/oni/home/services/stumpwm/stumpwm.lisp b/oni/home/services/stumpwm/stumpwm.lisp index 273235d..b8d8207 100644 --- a/oni/home/services/stumpwm/stumpwm.lisp +++ b/oni/home/services/stumpwm/stumpwm.lisp @@ -183,3 +183,29 @@ after it has been unlocked." (add-hook *restart-hook* 'stop-swank) (which-key-mode) (restore-from-file "default") + +(defun oni-move-floating-windows (current-window _last-window) + (if (not (stumpwm::float-window-p current-window)) + (let* ((current-frame (stumpwm::window-frame current-window)) + (frame-left-edge (round (frame-x current-frame))) + (frame-right-edge (+ frame-left-edge (round (frame-width current-frame)))) + (screen-width (screen-width (current-screen)))) + (mapc (lambda (window) + (let* ((window-left-edge (window-x window)) + (window-right-edge (+ window-left-edge (window-width window))) + (window-distance-to-right-edge (abs (- frame-right-edge window-left-edge))) + (window-distance-to-left-edge (abs (- window-right-edge frame-left-edge)))) + (if (and (< frame-left-edge window-right-edge) + (> frame-right-edge window-left-edge)) + (stumpwm::float-window-move-resize window :x (if (> (+ frame-right-edge 10) screen-width) + (- frame-left-edge (window-width window) 10) + (if (< (- frame-left-edge (window-width window) 10) 0) + (+ frame-right-edge 10) + (if (> window-distance-to-left-edge + window-distance-to-right-edge) + (+ frame-right-edge 10) + (- frame-left-edge (window-width window) 10)))))))) + (stumpwm::group-on-top-windows (current-group))) + (redisplay)))) + +(add-hook *focus-window-hook* 'oni-move-floating-windows) |
