From 769fbf26f0d9f7aaf3943d33ad7af2f02508107e Mon Sep 17 00:00:00 2001 From: cage Date: Wed, 31 Jul 2024 18:15:49 +0200 Subject: [PATCH] - added nested expansion of 'with-enqueued-process-and-unblock' and 'enqueue-request-and-wait-results'. --- src/gui/client/main-window.lisp | 35 +++++++++++++++--------------- src/gui/client/program-events.lisp | 9 +++++--- src/program-events.lisp | 13 ++++++++--- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 97bfe94..4332665 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -1869,23 +1869,24 @@ local file paths." (return-from uninline-all-images t))))) (defun scale-gemtext (main-window offset) - (let ((saved-active-stream (find-streaming-stream-url))) - (interrupt-rendering main-window) - (maybe-stop-streaming-stream-thread) - (when saved-active-stream - (open-iri (streaming-url saved-active-stream) main-window t)) - (let ((contains-inlined-images (ir-lines-contains-inlined-images-p main-window))) - (when contains-inlined-images - (uninline-all-images main-window)) - (restart-rendering main-window) - (clear-gemtext main-window) - (setf (gemtext-font-scaling main-window) - (if offset - (max 0.1 (+ (gemtext-font-scaling main-window) offset)) - 1.0)) - (render-ir-lines (get-address-bar-text main-window) main-window) - (when contains-inlined-images - (inline-all-images main-window))))) + (ev:with-enqueued-process-and-unblock () + (let ((saved-active-stream (find-streaming-stream-url))) + (interrupt-rendering main-window) + (maybe-stop-streaming-stream-thread) + (when saved-active-stream + (open-iri (streaming-url saved-active-stream) main-window t)) + (let ((contains-inlined-images (ir-lines-contains-inlined-images-p main-window))) + (when contains-inlined-images + (uninline-all-images main-window)) + (restart-rendering main-window) + (clear-gemtext main-window) + (setf (gemtext-font-scaling main-window) + (if offset + (max 0.1 (+ (gemtext-font-scaling main-window) offset)) + 1.0)) + (render-ir-lines (get-address-bar-text main-window) main-window) + (when contains-inlined-images + (inline-all-images main-window)))))) (defun initialize-keybindings (main-window target) (gui:bind target diff --git a/src/gui/client/program-events.lisp b/src/gui/client/program-events.lisp index 52718b8..b705e40 100644 --- a/src/gui/client/program-events.lisp +++ b/src/gui/client/program-events.lisp @@ -34,6 +34,9 @@ ,@on-error))) (defun enqueue-request-and-wait-results (method-name id priority &rest args) - (ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args)) - :push-event-fn #'ev:push-event-unblock - :priority priority)) + (if program-events::*already-enqueued* + (apply #'comm:make-request method-name id args) + (ev:push-function-and-wait-results (lambda () + (apply #'comm:make-request method-name id args)) + :push-event-fn #'ev:push-event-unblock + :priority priority))) diff --git a/src/program-events.lisp b/src/program-events.lisp index e250c88..207692d 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -249,10 +249,17 @@ :payload (lambda () ,@body) :priority ,priority))) +(defparameter *already-enqueued* nil) + (defmacro with-enqueued-process-and-unblock ((&optional (priority +standard-event-priority+)) &body body) - `(push-event-unblock (make-instance 'function-event - :payload (lambda () ,@body) - :priority ,priority))) + `(if *already-enqueued* + (funcall (lambda () ,@body)) + (push-event-unblock (make-instance 'function-event + :payload + (lambda () + (let ((*already-enqueued* t)) + ,@body)) + :priority ,priority)))) (defclass event-on-own-thread (program-event) ((lock