[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24019: 25.1.50; Allow using a custom callback with xwidget

From: Lars Ingebrigtsen
Subject: bug#24019: 25.1.50; Allow using a custom callback with xwidget
Date: Tue, 11 Aug 2020 16:21:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Kangas <stefan@marxist.se> writes:

>> `xwidgets.el' seems to have some commented code that used to allow using
>> a different callback on each xwidget.  This functionality is useful to
>> have and this is a patch that uncomments this code.  I've tested the
>> code, and it seems to work, and I'm not really sure, why this was
>> commented in the first place.
>> Thanks!
> Could you please help review the below patches?  They were submitted
> to the Emacs bug list in 2016, but no one has followed up on them.

I've re-spun the patch for Emacs 28.  It seems "obviously correct", and
by doing some cursory testing, it doesn't seem to have broken anything,
so I'll just push it.  If this leads to any problems, Joakim, feel free
to revert it.

diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index aed6c09122..a4c15a1e26 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -207,12 +207,8 @@ xwidget-event-handler
       ((xwidget-event-type (nth 1 last-input-event))
        (xwidget (nth 2 last-input-event))
-       ;;(xwidget-callback (xwidget-get xwidget 'callback))
-       ;;TODO stopped working for some reason
-       )
-    ;;(funcall  xwidget-callback xwidget xwidget-event-type)
-    (message "xw callback %s" xwidget)
-    (funcall  'xwidget-webkit-callback xwidget xwidget-event-type)))
+       (xwidget-callback (xwidget-get xwidget 'callback)))
+    (funcall xwidget-callback xwidget xwidget-event-type)))
 (defun xwidget-webkit-callback (xwidget xwidget-event-type)
   "Callback for xwidgets.
@@ -481,10 +477,11 @@ xwidget-webkit-adjust-size-in-frame
   (add-to-list 'window-size-change-functions
-(defun xwidget-webkit-new-session (url)
+(defun xwidget-webkit-new-session (url &optional callback)
   "Create a new webkit session buffer with URL."
       ((bufname (generate-new-buffer-name "*xwidget-webkit*"))
+       (callback (or callback #'xwidget-webkit-callback))
     (setq xwidget-webkit-last-session-buffer (switch-to-buffer
                                               (get-buffer-create bufname)))
@@ -494,7 +491,7 @@ xwidget-webkit-new-session
     (setq xw (xwidget-insert 1 'webkit bufname
-    (xwidget-put xw 'callback 'xwidget-webkit-callback)
+    (xwidget-put xw 'callback callback)
     (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url)))

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]