Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run main-loop on a thread #2

Open
lispnik opened this issue Apr 25, 2019 · 0 comments
Open

run main-loop on a thread #2

lispnik opened this issue Apr 25, 2019 · 0 comments
Labels

Comments

@lispnik
Copy link
Owner

lispnik commented Apr 25, 2019

Would like to be able to interactively build a gui from the REPL like you can with CAPI. main-loop blocks until the last dialog is closed though. Main consideration is that UI operations should run on the UI thread, otherwise bad thing happen (just like in swing, and maybe others).

Idea sketch:

(iup:open) ;; initialize manual

(defvar *idle-queue* '())

(defun idle-callback () 
   ;; lock
   (dolist (func *idle-queue*) (funcall func)
   (setf *idle-queue* '()))

(with-gui-thread ()
   (setf (iup:attribute foo :title) "new title"))
;;; ...
(call-with-gui-thread (func)
   ;; lock idle queue 
   (push func *idle-queue*))

notes:

  • also need to support the original purpose of the idle callback

  • set global var lockloop (so last dialog doesn't exit main-loop)

  • make sure it's not a multithreaded shit show

  • document

  • check that the CPU usage of idle callback isn't too high (iup docs explain it's called more than you think).

  • should enable this kind of interactive coding (like in TCL wish):

CL-USER> (in-package #:iup-user)
IUP-USER> (start-gui-thread)
IUP-USER> (setq dialog (dialog nil))
IUP-USER> (setq button (button :title "hi"))
IUP-USER> (show dialog)
IUP-USER> (iup:append dialog button)
IUP-USER> (setf (attribute button :title )"new title")
@lispnik lispnik added the todo label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant