From: Po Lu Date: Sun, 7 Nov 2021 00:50:59 +0000 (+0800) Subject: Default to creating new related sessions X-Git-Tag: emacs-29.0.90~3671^2~122 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eabd735e6c9f8f0ea87749beba6a37e2f6db6745;p=emacs.git Default to creating new related sessions * doc/lispref/display.texi: * etc/NEWS: Document changes. * lisp/xwidget.el (xwidget-insert): Accept an extra RELATED argument. (xwidget-webkit-new-session): Pass current session as RELATED if present. * src/xwidget.c (Fmake_xwidget): Make RELATED argument public. --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 37f07c4f28a..60bca15eb21 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -6801,8 +6801,9 @@ The WebKit component. The @var{width} and @var{height} arguments specify the widget size in pixels, and @var{title}, a string, specifies its title. @var{related} -is used internally by the WebKit widget, and is not of interest to the -programmer. +is used internally by the WebKit widget, and specifies another WebKit +widget that the newly created widget should share settings and +subprocesses with. @end defun @defun xwidgetp object diff --git a/etc/NEWS b/etc/NEWS index 0e5caa4825d..b14f9a2549a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -744,6 +744,12 @@ an exact match, then the lowercased '[menu-bar foo\ bar]' and finally '[menu-bar foo-bar]'. This further improves backwards-compatibility when converting menus to use 'easy-menu-define'. ++++ +** The function `make-xwidget' now accepts an optional RELATED argument. +This argument is used as another widget for the newly created WebKit +widget to share settings and subprocesses with. It must be another +WebKit widget. + +++ ** New function `xwidget-perform-lispy-event'. This function allows you to send events to xwidgets. Usually, some diff --git a/lisp/xwidget.el b/lisp/xwidget.el index d427e702331..c17229d34c1 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -35,7 +35,7 @@ (require 'bookmark) (declare-function make-xwidget "xwidget.c" - (type title width height arguments &optional buffer)) + (type title width height arguments &optional buffer related)) (declare-function xwidget-buffer "xwidget.c" (xwidget)) (declare-function set-xwidget-buffer "xwidget.c" (xwidget buffer)) (declare-function xwidget-size-request "xwidget.c" (xwidget)) @@ -59,14 +59,14 @@ "Displaying native widgets in Emacs buffers." :group 'widgets) -(defun xwidget-insert (pos type title width height &optional args) +(defun xwidget-insert (pos type title width height &optional args related) "Insert an xwidget at position POS. -Supply the xwidget's TYPE, TITLE, WIDTH, and HEIGHT. +Supply the xwidget's TYPE, TITLE, WIDTH, HEIGHT, and RELATED. See `make-xwidget' for the possible TYPE values. The usage of optional argument ARGS depends on the xwidget. This returns the result of `make-xwidget'." (goto-char pos) - (let ((id (make-xwidget type title width height args))) + (let ((id (make-xwidget type title width height args nil related))) (put-text-property (point) (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) id)) @@ -685,6 +685,7 @@ For example, use this to display an anchor." (let* ((bufname (generate-new-buffer-name "*xwidget-webkit*")) (callback (or callback #'xwidget-webkit-callback)) + (current-session (xwidget-webkit-current-session)) xw) (setq xwidget-webkit-last-session-buffer (switch-to-buffer (get-buffer-create bufname))) @@ -697,7 +698,8 @@ For example, use this to display an anchor." (setq xw (xwidget-insert start 'webkit bufname (xwidget-window-inside-pixel-width (selected-window)) - (xwidget-window-inside-pixel-height (selected-window))))) + (xwidget-window-inside-pixel-height (selected-window)) + nil current-session))) (xwidget-put xw 'callback callback) (xwidget-webkit-mode) (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url))) diff --git a/src/xwidget.c b/src/xwidget.c index bf69f262fb7..5f013b7aadc 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -110,7 +110,8 @@ TYPE is a symbol which can take one of the following values: - webkit -RELATED is nil, or an xwidget. This argument is used internally. +RELATED is nil, or an xwidget. When constructing a WebKit widget, it +will share the same settings and internal subprocess as RELATED. Returns the newly constructed xwidget, or nil if construction fails. */) (Lisp_Object type,