+ added a second version of wait-event. See event.scm for details.

This commit is contained in:
frese 2001-12-04 10:18:12 +00:00
parent b909c2a042
commit 03778abc9e
2 changed files with 22 additions and 7 deletions

View File

@ -146,13 +146,25 @@
;; wait-event blocks the current thread until an event is available,
;; and then it returns this new event.
;; In future releases this should be done with a select. But for now
;; we just do a loop with event-ready? and next-event. On this machine
;; that uses an acceptable amount of about 1% CPU-Time.
(define (wait-event display)
(if (event-ready? display)
(next-event display)
;; This does not work yet! We are working on it.
;(define (wait-event dpy) ; needs ports, locks
; (let ((port (display-message-inport dpy)))
; (display "obtaining port lock..." (current-error-port))
; (obtain-lock (port-lock port))
; (display " ...got it\n" (current-error-port))
;
; (display "waiting for events..." (current-error-port))
; (wait-for-channel (port->channel port))
; (display " ...receiving events.\n" (current-error-port))
;
; (release-lock (port-lock port))
; (next-event dpy)))
;; The old, ugly version that works...
(define (wait-event dpy)
(if (event-ready? dpy)
(next-event dpy)
(begin
(sleep 20) ; sleep for 20 ms
(wait-event display))))
(wait-event dpy))))

View File

@ -75,6 +75,9 @@
(open scheme
external-calls
threads ;; for sleep
ports locks ;; for locking the port
channel-i/o ;; for wait-for-channel
scsh-level-0 ;; for port->channel
xlib-types)
(files event))