Package: gdk

Function gdk:cursor-new-from-callback

Lambda List

gdk:cursor-new-from-callback (func &optional fallback)

Arguments

func -- a gdk:cursor-texture-callback callback function
fallback -- a gdk:cursor object to fall back to when this one cannot be supported

Details

Creates a new callback-based cursor object. Cursors of this kind produce textures for the cursor image on demand, when the callback is called.

Since 4.16

Examples

This example for a callback funtion is included in the GTK4 Demo.
(defun cursor-callback (cursor size scale width height xhotspot yhotspot)
  (declare (ignore cursor))
  (let ((glib-sys:*warn-deprecated* nil)) ; for gdk:texture-new-for-pixbuf
    (let* ((scaled (ceiling (* size scale)))
           (path "/images/cursors/gtk_logo_cursor.svg")
           (pixbuf (gdk:pixbuf-new-from-resource-at-scale path scaled scaled t)))
      (when pixbuf
        (setf (cffi:mem-ref width :int) (truncate size))
        (setf (cffi:mem-ref height :int) (truncate size))
        (setf (cffi:mem-ref xhotspot :int) (truncate (* 18 (/ size 32))))
        (setf (cffi:mem-ref yhotspot :int) (truncate (* 2 (/ size 32))))
        ;; Create texture for pixbuf
        (gdk:texture-new-for-pixbuf pixbuf)))))    
 

See also

2026-02-22