diff --git a/scheme/xlib/event.scm b/scheme/xlib/event.scm index f3787f2..859ab66 100644 --- a/scheme/xlib/event.scm +++ b/scheme/xlib/event.scm @@ -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)))) diff --git a/scheme/xlib/xlib-packages.scm b/scheme/xlib/xlib-packages.scm index 5e2c16a..b60d90a 100644 --- a/scheme/xlib/xlib-packages.scm +++ b/scheme/xlib/xlib-packages.scm @@ -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))