diff --git a/scheme/xlib/window.scm b/scheme/xlib/window.scm index ea3f235..be80186 100644 --- a/scheme/xlib/window.scm +++ b/scheme/xlib/window.scm @@ -52,6 +52,8 @@ ;; window-exists? returns #t if the windows still exists (makes sense, ;; doesn't it :-) +;; This version is easier and faster, but causes an X Protocol error, +;; if the window does not exist. (define (window-exists? window) (and (integer? (window-Xwindow window)) ;; hasn't been destroyed by ;; destroy-window @@ -59,6 +61,27 @@ #t #f))) ;; the window does not ;; exists. +; (define (window-exists? window) +; (let ((dpy (window-display window))) +; (letrec ((loop (lambda (w) +; (or (eq? w window) +; (any loop (window-children w)))))) +; (any loop (map (lambda (i) +; (display-root-window dpy i)) +; (iota (display-screen-count dpy))))))) + +;; Alternative version, seems to be slower +; (define (window-exists? window) +; (let ((dpy (window-display window))) +; (let loop ((candidates (map (lambda (i) +; (display-root-window dpy i)) +; (iota (display-screen-count dpy))))) +; (cond +; ((null? candidates) #f) +; ((eq? (car candidates) window) #t) +; (else (loop (append (cdr candidates) +; (window-children (car candidates))))))))) + ;; *** change-window-attributes ************************************** ;; change-window-attributes takes an alist of set-window-attributes @@ -156,7 +179,8 @@ (define (make-win-attr-getter attribute) (lambda (window) - (cdr (assq attribute (get-window-attributes window))))) + (let ((attribs (get-window-attributes window))) + (and attribs (cdr (assq attribute attribs)))))) (define window-x (make-win-attr-getter (window-attribute x))) (define window-y (make-win-attr-getter (window-attribute y)))