aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2021-11-07 08:50:59 +0800
committerLars Ingebrigtsen2021-11-07 02:59:42 +0100
commiteabd735e6c9f8f0ea87749beba6a37e2f6db6745 (patch)
treedcd3c0516f297460c65ea11ca0dcd773ad005902
parent686ce501cb54ce64cabb3411cac2b3f0ea936c49 (diff)
downloademacs-eabd735e6c9f8f0ea87749beba6a37e2f6db6745.tar.gz
emacs-eabd735e6c9f8f0ea87749beba6a37e2f6db6745.zip
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.
-rw-r--r--doc/lispref/display.texi5
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/xwidget.el12
-rw-r--r--src/xwidget.c3
4 files changed, 18 insertions, 8 deletions
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.
6801 6801
6802The @var{width} and @var{height} arguments specify the widget size in 6802The @var{width} and @var{height} arguments specify the widget size in
6803pixels, and @var{title}, a string, specifies its title. @var{related} 6803pixels, and @var{title}, a string, specifies its title. @var{related}
6804is used internally by the WebKit widget, and is not of interest to the 6804is used internally by the WebKit widget, and specifies another WebKit
6805programmer. 6805widget that the newly created widget should share settings and
6806subprocesses with.
6806@end defun 6807@end defun
6807 6808
6808@defun xwidgetp object 6809@defun xwidgetp object
diff --git a/etc/NEWS b/etc/NEWS
index 0e5caa4825d..b14f9a2549a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -745,6 +745,12 @@ an exact match, then the lowercased '[menu-bar foo\ bar]' and finally
745when converting menus to use 'easy-menu-define'. 745when converting menus to use 'easy-menu-define'.
746 746
747+++ 747+++
748** The function `make-xwidget' now accepts an optional RELATED argument.
749This argument is used as another widget for the newly created WebKit
750widget to share settings and subprocesses with. It must be another
751WebKit widget.
752
753+++
748** New function `xwidget-perform-lispy-event'. 754** New function `xwidget-perform-lispy-event'.
749This function allows you to send events to xwidgets. Usually, some 755This function allows you to send events to xwidgets. Usually, some
750equivalent of the event will be sent, but there is no guarantee of 756equivalent of the event will be sent, but there is no guarantee of
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 @@
35(require 'bookmark) 35(require 'bookmark)
36 36
37(declare-function make-xwidget "xwidget.c" 37(declare-function make-xwidget "xwidget.c"
38 (type title width height arguments &optional buffer)) 38 (type title width height arguments &optional buffer related))
39(declare-function xwidget-buffer "xwidget.c" (xwidget)) 39(declare-function xwidget-buffer "xwidget.c" (xwidget))
40(declare-function set-xwidget-buffer "xwidget.c" (xwidget buffer)) 40(declare-function set-xwidget-buffer "xwidget.c" (xwidget buffer))
41(declare-function xwidget-size-request "xwidget.c" (xwidget)) 41(declare-function xwidget-size-request "xwidget.c" (xwidget))
@@ -59,14 +59,14 @@
59 "Displaying native widgets in Emacs buffers." 59 "Displaying native widgets in Emacs buffers."
60 :group 'widgets) 60 :group 'widgets)
61 61
62(defun xwidget-insert (pos type title width height &optional args) 62(defun xwidget-insert (pos type title width height &optional args related)
63 "Insert an xwidget at position POS. 63 "Insert an xwidget at position POS.
64Supply the xwidget's TYPE, TITLE, WIDTH, and HEIGHT. 64Supply the xwidget's TYPE, TITLE, WIDTH, HEIGHT, and RELATED.
65See `make-xwidget' for the possible TYPE values. 65See `make-xwidget' for the possible TYPE values.
66The usage of optional argument ARGS depends on the xwidget. 66The usage of optional argument ARGS depends on the xwidget.
67This returns the result of `make-xwidget'." 67This returns the result of `make-xwidget'."
68 (goto-char pos) 68 (goto-char pos)
69 (let ((id (make-xwidget type title width height args))) 69 (let ((id (make-xwidget type title width height args nil related)))
70 (put-text-property (point) (+ 1 (point)) 70 (put-text-property (point) (+ 1 (point))
71 'display (list 'xwidget ':xwidget id)) 71 'display (list 'xwidget ':xwidget id))
72 id)) 72 id))
@@ -685,6 +685,7 @@ For example, use this to display an anchor."
685 (let* 685 (let*
686 ((bufname (generate-new-buffer-name "*xwidget-webkit*")) 686 ((bufname (generate-new-buffer-name "*xwidget-webkit*"))
687 (callback (or callback #'xwidget-webkit-callback)) 687 (callback (or callback #'xwidget-webkit-callback))
688 (current-session (xwidget-webkit-current-session))
688 xw) 689 xw)
689 (setq xwidget-webkit-last-session-buffer (switch-to-buffer 690 (setq xwidget-webkit-last-session-buffer (switch-to-buffer
690 (get-buffer-create bufname))) 691 (get-buffer-create bufname)))
@@ -697,7 +698,8 @@ For example, use this to display an anchor."
697 (setq xw (xwidget-insert 698 (setq xw (xwidget-insert
698 start 'webkit bufname 699 start 'webkit bufname
699 (xwidget-window-inside-pixel-width (selected-window)) 700 (xwidget-window-inside-pixel-width (selected-window))
700 (xwidget-window-inside-pixel-height (selected-window))))) 701 (xwidget-window-inside-pixel-height (selected-window))
702 nil current-session)))
701 (xwidget-put xw 'callback callback) 703 (xwidget-put xw 'callback callback)
702 (xwidget-webkit-mode) 704 (xwidget-webkit-mode)
703 (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url))) 705 (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:
110 110
111- webkit 111- webkit
112 112
113RELATED is nil, or an xwidget. This argument is used internally. 113RELATED is nil, or an xwidget. When constructing a WebKit widget, it
114will share the same settings and internal subprocess as RELATED.
114Returns the newly constructed xwidget, or nil if construction 115Returns the newly constructed xwidget, or nil if construction
115fails. */) 116fails. */)
116 (Lisp_Object type, 117 (Lisp_Object type,