- bug in make-win-attr-getter fixed
- added window-exists? function
This commit is contained in:
parent
6984e99ccc
commit
c48fde11ba
|
@ -52,6 +52,8 @@
|
||||||
;; window-exists? returns #t if the windows still exists (makes sense,
|
;; window-exists? returns #t if the windows still exists (makes sense,
|
||||||
;; doesn't it :-)
|
;; 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)
|
(define (window-exists? window)
|
||||||
(and (integer? (window-Xwindow window)) ;; hasn't been destroyed by
|
(and (integer? (window-Xwindow window)) ;; hasn't been destroyed by
|
||||||
;; destroy-window
|
;; destroy-window
|
||||||
|
@ -59,6 +61,27 @@
|
||||||
#t #f))) ;; the window does not
|
#t #f))) ;; the window does not
|
||||||
;; exists.
|
;; 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 **************************************
|
||||||
|
|
||||||
;; change-window-attributes takes an alist of set-window-attributes
|
;; change-window-attributes takes an alist of set-window-attributes
|
||||||
|
@ -156,7 +179,8 @@
|
||||||
|
|
||||||
(define (make-win-attr-getter attribute)
|
(define (make-win-attr-getter attribute)
|
||||||
(lambda (window)
|
(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-x (make-win-attr-getter (window-attribute x)))
|
||||||
(define window-y (make-win-attr-getter (window-attribute y)))
|
(define window-y (make-win-attr-getter (window-attribute y)))
|
||||||
|
|
Loading…
Reference in New Issue