+ added a second version of wait-event. See event.scm for details.
This commit is contained in:
parent
b909c2a042
commit
03778abc9e
|
@ -146,13 +146,25 @@
|
||||||
|
|
||||||
;; wait-event blocks the current thread until an event is available,
|
;; wait-event blocks the current thread until an event is available,
|
||||||
;; and then it returns this new event.
|
;; 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)
|
;; This does not work yet! We are working on it.
|
||||||
(if (event-ready? display)
|
;(define (wait-event dpy) ; needs ports, locks
|
||||||
(next-event display)
|
; (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
|
(begin
|
||||||
(sleep 20) ; sleep for 20 ms
|
(sleep 20) ; sleep for 20 ms
|
||||||
(wait-event display))))
|
(wait-event dpy))))
|
||||||
|
|
|
@ -75,6 +75,9 @@
|
||||||
(open scheme
|
(open scheme
|
||||||
external-calls
|
external-calls
|
||||||
threads ;; for sleep
|
threads ;; for sleep
|
||||||
|
ports locks ;; for locking the port
|
||||||
|
channel-i/o ;; for wait-for-channel
|
||||||
|
scsh-level-0 ;; for port->channel
|
||||||
xlib-types)
|
xlib-types)
|
||||||
(files event))
|
(files event))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue