Package: gdk
Function gdk:cursor-new-from-callback
Lambda Listgdk:cursor-new-from-callback (func &optional fallback) ArgumentsDetails
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
(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