aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/stumpwm/stumpwm.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'oni/home/services/stumpwm/stumpwm.lisp')
-rw-r--r--oni/home/services/stumpwm/stumpwm.lisp26
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)