From a8b395459f44af418f70ea8f405f1880905194db Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 14 Jan 2026 17:27:04 -0800 Subject: 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. --- oni/home/services/stumpwm/stumpwm.lisp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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) -- cgit v1.3-2-g0d8e