[gsharp-devel] Occasional type errors from CLX

Robert Strandh strandh at labri.fr
Mon Jul 26 12:44:52 UTC 2004

Christophe Rhodes writes:
 > Hi,
 > I'm not certain that this is a uniquely gsharp error... however:
 > On starting up I sometimes get a type error of the form:
 >   debugger invoked on a TYPE-ERROR in thread 5361:
 >     The value #<XLIB:PIXMAP :0 33554506>
 >     is not of type
 > from XLIB:SET-INPUT-FOCUS called, I think, from the (:EXPOSURE
 > :DISPLAY) clause of McCLIM's CLX backend EVENT-HANDLER.
 > My suspicion lands on gsharp rather than general McCLIM because of the
 > following detail in WITH-SCORE-PANE:
 > (defmacro with-score-pane (pane &body body)
 >   (let ((pixmap (gensym))
 >         (mirror (gensym)))
 >     `(let* ((*pane* ,pane)
 >             (*lighter-gray-progressions* (lighter-gray-progressions pane))
 >             (*darker-gray-progressions* (darker-gray-progressions pane))
 >             (,pixmap (allocate-pixmap *pane* 800 900))
 >             (,mirror (sheet-direct-mirror *pane*)))
 >       (draw-rectangle* ,pixmap 0 0 800 900 :filled t :ink +white+)
 >       (setf (sheet-direct-mirror *pane*) (climi::pixmap-mirror ,pixmap))
 >       (clear-output-record (stream-output-history *pane*))
 >       (with-translation (pane 0 900)
 >         (with-scaling (pane 1 -1)
 >           , at body))
 >       (setf (sheet-direct-mirror *pane*) ,mirror)
 >       (copy-from-pixmap ,pixmap 0 0 800 900 *pane* 0 0)
 >       (deallocate-pixmap ,pixmap))))
 > During the body of this, we appear to have set the mirror of *pane* to
 > something which is a CLX pixmap: which isn't (I guess: I do not speak
 > from authority here) a window.  Since we're using
 > climi::pixmap-mirror, my suspicion is that this is a no-no.  I have to
 > ask, though, what was this for?

This is the double buffering that avoids flickering.  As you have
noticed, this solution is not quite kosher (or "catholic" depending on
the country you are in). 

Do you know a better way of doing it? 

Robert Strandh

Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.

More information about the gsharp-devel mailing list