From: Grégoire Jadi Date: Thu, 18 Jul 2013 09:48:13 +0000 (+0200) Subject: * src/xwidget.c (Fxwidget_delete_zombies): Re-implemented in Lisp. X-Git-Tag: emacs-25.0.90~2883 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a425ea65234441d4774d32dc7511a9401467b54d;p=emacs.git * src/xwidget.c (Fxwidget_delete_zombies): Re-implemented in Lisp. Note: It is not longer necessary to delete xwidget with killed buffer here because it is done automatically when a buffer is killed. (Fdelete_xwidget_view): New function to delete the given xwidget-view. * lisp/xwidget.el (xwidget-delete-zombies): Re-implementation. * src/xwidget.c (Fxwidget_delete_zombies): Re-implemented in Lisp. Note: It is not longer necessary to delete xwidget with killed buffer here because it is done automatically when a buffer is killed. (Fdelete_xwidget_view): New function to delete the given xwidget-view. * lisp/xwidget.el (xwidget-delete-zombies): New implementation. --- diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 5d04618209c..81589e3d57d 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -438,16 +438,24 @@ It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun xwidget-delete-zombies () + (mapcar (lambda (xwidget-view) + (when (or (not (window-live-p (xwidget-view-window xwidget-view))) + (not (find (xwidget-view-model xwidget-view) + xwidget-list))) + (delete-xwidget-view xwidget-view))) + xwidget-view-list)) + (defun xwidget-cleanup () "Delete zombie xwidgets." ;;its still pretty easy to trigger bugs with xwidgets. ;;this function tries to implement a workaround (interactive) - (xwidget-delete-zombies) ;;kill xviews who should have been deleted but stull linger - (redraw-display);;redraw display otherwise ghost of zombies will remain to haunt the screen - ) - - + ;; kill xviews who should have been deleted but stull linger + (xwidget-delete-zombies) + ;; redraw display otherwise ghost of zombies will remain to haunt the screen + (redraw-display)) ;;this is a workaround because I cant find the right place to put it in C ;;seems to work well in practice though diff --git a/src/xwidget.c b/src/xwidget.c index ad4e07c6dd2..837b607643b 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -1520,30 +1520,15 @@ DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_sen return Qnil; } - - -DEFUN("xwidget-delete-zombies", Fxwidget_delete_zombies , Sxwidget_delete_zombies, 0,0,0, doc: /* */) - (void) +DEFUN ("delete-xwidget-view", Fdelete_xwidget_view, Sdelete_xwidget_view, + 1, 1, 0, + doc: /* Delete the XWIDGET-VIEW. */) + (Lisp_Object xwidget_view) { - /* - - remove all views with window gone - - TODO - - remove all xwidgets with buffer gone - - remove all views with xw gone - - */ - struct xwidget_view* xv = NULL; - for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail); tail = XCDR (tail)) - { - if (XWIDGET_VIEW_P (XCAR (tail))) { - xv = XXWIDGET_VIEW (XCAR (tail)); - if(!WINDOW_LIVE_P (xv->w)) { - gtk_widget_destroy(GTK_WIDGET(xv->widgetwindow)); - Vxwidget_view_list = Fdelq (XCAR (tail), Vxwidget_view_list); - } - } - } + CHECK_XWIDGET_VIEW (xwidget_view); + struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); + gtk_widget_destroy(GTK_WIDGET (xv->widgetwindow)); + Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list); } DEFUN ("xwidget-view-lookup", Fxwidget_view_lookup, Sxwidget_view_lookup, @@ -1653,7 +1638,7 @@ syms_of_xwidget (void) defsubr (&Sxwgir_xwidget_call_method ); defsubr (&Sxwgir_require_namespace); defsubr (&Sxwidget_size_request ); - defsubr (&Sxwidget_delete_zombies); + defsubr (&Sdelete_xwidget_view); defsubr (&Sxwidget_disable_plugin_for_mime); defsubr (&Sxwidget_send_keyboard_event);