mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 02:50:26 -08:00
Handle xwidgets like processes and delete them when their buffer is killed.
* lisp/xwidget.el (xwidget-kill-buffer-query-function): New function to query a user before killing a buffer with xwidgets in it. This function is stored in `kill-buffer-query-functions' and called from `kill-buffer'. * src/buffer.c (Fkill_buffer): Call `kill_buffer_xwidgets'. * src/xwidget.c (kill_buffer_xwidgets): Delete xwidgets attached to the specified buffer. * src/xwidget.h (kill_buffer_xwidgets): Add definition.
This commit is contained in:
parent
d65ea7dd1d
commit
da95bc007d
4 changed files with 37 additions and 2 deletions
|
|
@ -454,6 +454,16 @@ It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'."
|
||||||
;;(add-hook 'window-configuration-change-hook 'xwidget-cleanup)
|
;;(add-hook 'window-configuration-change-hook 'xwidget-cleanup)
|
||||||
(add-hook 'window-configuration-change-hook 'xwidget-delete-zombies)
|
(add-hook 'window-configuration-change-hook 'xwidget-delete-zombies)
|
||||||
|
|
||||||
|
(defun xwidget-kill-buffer-query-function ()
|
||||||
|
"Ask beforek illing a buffer that has xwidgets."
|
||||||
|
(let ((xwidgets (get-buffer-xwidgets (current-buffer))))
|
||||||
|
(or (not xwidgets)
|
||||||
|
(yes-or-no-p
|
||||||
|
(format "Buffer %S has xwidgets; kill it? "
|
||||||
|
(buffer-name (current-buffer)))))))
|
||||||
|
|
||||||
|
(add-hook 'kill-buffer-query-functions 'xwidget-kill-buffer-query-function)
|
||||||
|
|
||||||
;;killflash is sadly not reliable yet.
|
;;killflash is sadly not reliable yet.
|
||||||
(defvar xwidget-webkit-kill-flash-oneshot t)
|
(defvar xwidget-webkit-kill-flash-oneshot t)
|
||||||
(defun xwidget-webkit-kill-flash ()
|
(defun xwidget-webkit-kill-flash ()
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_XWIDGETS
|
||||||
|
#include "xwidget.h"
|
||||||
|
#endif /* HAVE_XWIDGETS */
|
||||||
|
|
||||||
struct buffer *current_buffer; /* The current buffer. */
|
struct buffer *current_buffer; /* The current buffer. */
|
||||||
|
|
||||||
/* First buffer in chain of all buffers (in reverse order of creation).
|
/* First buffer in chain of all buffers (in reverse order of creation).
|
||||||
|
|
@ -1835,6 +1839,11 @@ cleaning up all windows currently displaying the buffer to be killed. */)
|
||||||
kill_buffer_processes (buffer);
|
kill_buffer_processes (buffer);
|
||||||
UNGCPRO;
|
UNGCPRO;
|
||||||
|
|
||||||
|
#ifdef HAVE_XWIDGETS
|
||||||
|
GCPRO1 (buffer);
|
||||||
|
kill_buffer_xwidgets (buffer);
|
||||||
|
UNGCPRO;
|
||||||
|
#endif /* HAVE_XWIDGETS */
|
||||||
/* Killing buffer processes may run sentinels which may have killed
|
/* Killing buffer processes may run sentinels which may have killed
|
||||||
our buffer. */
|
our buffer. */
|
||||||
if (!BUFFER_LIVE_P (b))
|
if (!BUFFER_LIVE_P (b))
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ TYPE is a symbol which can take one of the following values:
|
||||||
//should work a bit like "make-button"(make-button BEG END &rest PROPERTIES)
|
//should work a bit like "make-button"(make-button BEG END &rest PROPERTIES)
|
||||||
// arg "type" and fwd should be keyword args eventually
|
// arg "type" and fwd should be keyword args eventually
|
||||||
//(make-xwidget 3 3 'button "oei" 31 31 nil)
|
//(make-xwidget 3 3 'button "oei" 31 31 nil)
|
||||||
//(xwidget-info (car xwidget-alist))
|
//(xwidget-info (car xwidget-list))
|
||||||
struct xwidget* xw = allocate_xwidget();
|
struct xwidget* xw = allocate_xwidget();
|
||||||
Lisp_Object val;
|
Lisp_Object val;
|
||||||
xw->type = type;
|
xw->type = type;
|
||||||
|
|
@ -1619,7 +1619,7 @@ syms_of_xwidget (void)
|
||||||
|
|
||||||
DEFSYM (QCplist, ":plist");
|
DEFSYM (QCplist, ":plist");
|
||||||
|
|
||||||
DEFVAR_LISP ("xwidget-alist", Vxwidget_list, doc: /*xwidgets list*/);
|
DEFVAR_LISP ("xwidget-list", Vxwidget_list, doc: /*xwidgets list*/);
|
||||||
Vxwidget_list = Qnil;
|
Vxwidget_list = Qnil;
|
||||||
|
|
||||||
DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/);
|
DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/);
|
||||||
|
|
@ -1845,4 +1845,18 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Kill all xwidget in BUFFER. */
|
||||||
|
void
|
||||||
|
kill_buffer_xwidgets (Lisp_Object buffer)
|
||||||
|
{
|
||||||
|
Lisp_Object tail, xw;
|
||||||
|
|
||||||
|
for (tail = Fget_buffer_xwidgets (buffer); CONSP (tail); tail = XCDR (tail))
|
||||||
|
{
|
||||||
|
xw = XCAR (tail);
|
||||||
|
Vxwidget_list = Fdelq (xw, Vxwidget_list);
|
||||||
|
/* TODO free the GTK things in xw */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_XWIDGETS */
|
#endif /* HAVE_XWIDGETS */
|
||||||
|
|
|
||||||
|
|
@ -107,4 +107,6 @@ struct xwidget* lookup_xwidget (Lisp_Object spec);
|
||||||
#define XG_XWIDGET "emacs_xwidget"
|
#define XG_XWIDGET "emacs_xwidget"
|
||||||
#define XG_XWIDGET_VIEW "emacs_xwidget_view"
|
#define XG_XWIDGET_VIEW "emacs_xwidget_view"
|
||||||
void xwidget_view_delete_all_in_window( struct window *w );
|
void xwidget_view_delete_all_in_window( struct window *w );
|
||||||
|
|
||||||
|
void kill_buffer_xwidgets (Lisp_Object buffer);
|
||||||
#endif /* XWIDGET_H_INCLUDED */
|
#endif /* XWIDGET_H_INCLUDED */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue