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.
This commit is contained in:
Po Lu
2021-11-07 08:50:59 +08:00
committed by Lars Ingebrigtsen
parent 686ce501cb
commit eabd735e6c
4 changed files with 18 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)))

View File

@@ -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,