(ql:quickload :mcclim)

(in-package :clim-user)

;; Used to work, I think, under X11 (vs Wayland)

#+NIL
(defmacro with-busy-cursor (&rest body)
  `(let* ((sheet (frame-top-level-sheet *application-frame*))
	  (old-cursor (sheet-pointer-cursor sheet)))
     #-NIL (format *terminal-io* "with-busy-cursor 1~%")
     (setf (sheet-pointer-cursor sheet) :busy)
     (progn ,@body)
     (setf (sheet-pointer-cursor sheet) old-cursor)
     #-NIL (format *terminal-io* "with-busy-cursor 2~%")))

;; From some CLIM Spec doc

#+NIL
(defmacro with-busy-cursor ((&optional (frame 'clim:*application-frame*))
			    &body body)
  (let ((pointer '#:pointer)
	(old-cursor '#:old-cursor))
    `(let* ((,pointer (clim:port-pointer (port ,frame)))
	    (,old-cursor (clim:pointer-cursor ,pointer)))
      (setf (clim:pointer-cursor ,pointer) :busy)
      (unwind-protect
	   ,@body
	(setf (clim:pointer-cursor ,pointer) ,old-cursor)))))

(define-application-frame test-cursor ()
  ()
  (:panes
   (empty-pane :interactor
	       :height 400
	       :width 400)
   #+NIL (:command-table test-cursor-command-table)))

(define-test-cursor-command (com-busy1 :name t) ()
  (let* ((sheet (frame-top-level-sheet *application-frame*))
	 (old-cursor (sheet-pointer-cursor sheet)))
    (setf (sheet-pointer-cursor sheet) :busy)))

(define-test-cursor-command (com-busy2 :name t) ()
  (let* ((pointer (clim:port-pointer (port *application-frame*)))
	 (old-cursor (clim:pointer-cursor pointer)))
    (setf (clim:pointer-cursor pointer) :busy)))

(run-frame-top-level (make-application-frame 'test-cursor))



