Re: CLX/CMUCL: Event processing speed



Hi Ulrich,

I tried your suggestion, but its behaviour is still the same. See
below.


Ulrich Hobelmann <u.hobelmann@xxxxxx> writes:

> David Trudgett wrote:
>> The primary question I have is about a strategy to deal with this
>> situation. For example, perhaps one might only process one exposure
>> event per second (and discarding all the others). Does anyone have any
>> tips for this? Sample code? :-)
>
> Hm, it's been a while since I did any X window. Wasn't there an event
> count associated with each sort of event. I remember reading
> something about that if some count > 0, you simply discard the event,
> so that you only redraw after the last resize/expose/... was received.

I thought I was doing that, but I looked at the code and realised I
must have accidentally deleted it somewhere along the line. In any
case, I put it back in, but the behaviour is just the same. I assume
it must be generating lots of exposure events with count equal to
zero.

Anyway, here is the corrected bit:

(defmacro with-drawing-window (&body body)
(flet ((do-stuff () `(progn ,@body (display-finish-output *display*))))
`(unwind-protect
(progn
(show-drawing-window)
(event-case
(*display* :force-output-p t :discard-p t)
(:button-press ()
t)
(:key-press ()
t)
(:exposure (count)
(when (zerop count)
,(do-stuff))
nil)))
(close-display *display*)
(setf *drawing-window* nil)
(setf *graphics-context* nil)
(setf *display* nil)
(setf *screen* nil))))


and a sample expansion:

(UNWIND-PROTECT
(PROGN
(SHOW-DRAWING-WINDOW)
(EVENT-CASE (*DISPLAY* :FORCE-OUTPUT-P T :DISCARD-P T)
(:BUTTON-PRESS NIL T)
(:KEY-PRESS NIL T)
(:EXPOSURE (COUNT)
(WHEN (ZEROP COUNT)
(PROGN
(DRAW-GLYPHS *DRAWING-WINDOW*
*GRAPHICS-CONTEXT*
50
50
"DRAW-PIXEL-LINE-1")
(DRAW-GLYPHS *DRAWING-WINDOW*
*GRAPHICS-CONTEXT*
50
250
"XLIB:DRAW-LINE")
(DO ((X-INC 50)
(X 150 (+ X X-INC))
(Y1 200 (- Y1 10))
(Y2 400 (- Y2 10)))
((< Y1 50))
(DRAW-PIXEL-LINE-1 '(100 100) (LIST X Y1))
(DRAW-LINE *DRAWING-WINDOW*
*GRAPHICS-CONTEXT*
100
300
X
Y2)
(WHEN (>= X 590) (SETQ X-INC (- X-INC))))
(DISPLAY-FINISH-OUTPUT *DISPLAY*)))
NIL)))
(CLOSE-DISPLAY *DISPLAY*)
(SETF *DRAWING-WINDOW* NIL)
(SETF *GRAPHICS-CONTEXT* NIL)
(SETF *DISPLAY* NIL)
(SETF *SCREEN* NIL))


Thanks anyway, you managed to catch an omission I wasn't aware of.

David




--

David Trudgett
http://www.zeta.org.au/~wpower/

Beware of bugs in the above code;
I have only proved it correct, not tried it.

-- Donald Knuth (1977)

.