diff --git a/src/root-manager.scm b/src/root-manager.scm index 579a6a0..49d28b1 100644 --- a/src/root-manager.scm +++ b/src/root-manager.scm @@ -399,22 +399,22 @@ (define (find-manager-at root-wm x y) ;; returns the upper-most manager at root-window's coords x y - (let* ((dpy (root-wm:dpy root-wm)) - (candidates - (filter (lambda (wm) - (point-in-rectangle? (root-rectangle dpy (wm:window wm)) - x y)) - (root-wm-managers root-wm)))) - (letrec ((loop (lambda (wm level rest) - (if (null? rest) - wm - (let* ((next (car rest)) - (next-level (window-level dpy - (wm:window next)))) - (if (> next-level level) - (loop next next-level (cdr rest)) - (loop wm level (cdr rest)))))))) - (loop #f -1 candidates)))) + (letrec ((dpy (root-wm:dpy root-wm)) + (root-window (default-root-window dpy)) + (child-at (lambda (window x y) + (let ((res (translate-coordinates dpy root-window window + x y))) + (and res (not (zero? (third res))) (third res))))) + (window-at (lambda (window x y) + (let ((child (child-at window x y))) + (if child + (window-at child x y) + window)))) + (manager-of-window (lambda (window) + (or (get-manager-by-window root-wm window) + (let ((w (window-parent dpy window))) + (and w (manager-of-window w))))))) + (manager-of-window (window-at root-window x y)))) (define (get-manager-by-window root-wm window) (let ((l (filter (lambda (wm)