anchor.diff:                          (<= #x-8000 x2 #x7FFF) (<= #x-8000 y2 #x7FFF))
                      (xlib:draw-line mirror gc x1 y1 x2 y2))
                     (t
  -                   (let ((line (region-intersection (make-rectangle* #x-8000 #x-8000 #x7FFF #x7FFF)
  +                   (let ((line (region-intersection (load-time-value
  +                                                     (make-rectangle* #x-8000 #x-8000 #x7FFF #x7FFF))
                                                       (make-line* x1 y1 x2 y2))))
                        (when (linep line)
                          (multiple-value-bind (x1 y1) (line-start-point* line)
                            (multiple-value-bind (x2 y2) (line-end-point* line)
                              (xlib:draw-line mirror gc
  -                                           (min #x7FFF (max #x-8000 (round-coordinate x1)))
  -                                           (min #x7FFF (max #x-8000 (round-coordinate y1)))
  -                                           (min #x7FFF (max #x-8000 (round-coordinate x2)))
  -                                           (min #x7FFF (max #x-8000 (round-coordinate y2))))))))))))))))
  +                                           (clamp (round-coordinate x1) #x-8000 #x7FFF)
  +                                           (clamp (round-coordinate y1) #x-8000 #x7FFF)
  +                                           (clamp (round-coordinate x2) #x-8000 #x7FFF)
  +                                           (clamp (round-coordinate y2) #x-8000 #x7FFF))))))))))))))
   
   (defmethod medium-draw-polygon* ((medium clx-medium) coord-seq closed filled)
     ;; TODO:
  
positive.code:               (max-x (round-coordinate (max left right)))
                (max-y (round-coordinate (max top bottom))))
            (let ((^cleanup nil))
              (unwind-protect (xlib:draw-rectangle (port-lookup-mirror (port medium)
                                                                       (medium-sheet medium))
                                                   (medium-gcontext medium (medium-background medium))
                                                   (max #x-8000 (min #x7fff min-x))
                                                   (max #x-8000 (min #x7fff min-y))
                                                   (max 0 (min #xffff (- max-x min-x)))
                                                   (max 0 (min #xffff (- max-y min-y)))
                                                   t)
                (mapc #'funcall ^cleanup))))))))
  
  (defmethod medium-beep ((medium clx-medium))
  
negative.code:                 (bottom (round-coordinate bottom)))
              ;; To clip rectangles, we just need to clamp the coordinates
              (xlib:draw-rectangle mirror gc
                                   (clamp left           #x-8000 #x7FFF)
                                   (clamp top            #x-8000 #x7FFF)
                                   (clamp (- right left) 0       #xFFFF)
                                   (clamp (- bottom top) 0       #xFFFF)
                                   filled)))))))
  
  (defmethod medium-draw-rectangles* ((medium clx-medium) position-seq filled)
    (let ((length (length position-seq)))
      (assert (zerop (mod length 4)))
      (with-transformed-positions ((sheet-native-transformation
                                    (medium-sheet medium))
                                   position-seq)
        (with-clx-graphics () medium
          (let ((points (make-array length))
                (index  0))
            (do-sequence ((left top right bottom) position-seq)
              (let ((min-x (round-coordinate left))
                    (max-x (round-coordinate right))
                    (min-y (round-coordinate top))
                    (max-y (round-coordinate bottom)))
                (setf (aref points (+ index 0)) min-x)
                (setf (aref points (+ index 1)) min-y)
                (setf (aref points (+ index 2)) (- max-x min-x))
                (setf (aref points (+ index 3)) (- max-y min-y)))
              (incf index 4))
            (xlib:draw-rectangles mirror gc points filled))))))
  
  (defun %draw-rotated-ellipse (medium center-x center-y
                                radius-1-dx radius-1-dy
  