changeset 37556:171c0f4964a9

(file_dialog_unmap_cb): New function. (Fx_file_dialog): Use it as XmNunmapCallback to capture the case where a dialog is closed via the window manager.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 03 May 2001 17:09:27 +0000
parents df1f76568623
children a3256408325f
files src/xfns.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Thu May 03 16:19:51 2001 +0000
+++ b/src/xfns.c	Thu May 03 17:09:27 2001 +0000
@@ -11083,6 +11083,21 @@
 }
 
 
+/* Callback for unmapping a file selection dialog.  This is used to
+   capture the case where a dialog is closed via a window manager's
+   closer button, for example. Using a XmNdestroyCallback didn't work
+   in this case.  */
+
+static void
+file_dialog_unmap_cb (widget, client_data, call_data)
+     Widget widget;
+     XtPointer call_data, client_data;
+{
+  int *result = (int *) client_data;
+  *result = XmCR_CANCEL;
+}
+
+
 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
   "Read file name, prompting with PROMPT in directory DIR.\n\
 Use a file selection dialog.\n\
@@ -11135,6 +11150,8 @@
 		 (XtPointer) &result);
   XtAddCallback (dialog, XmNcancelCallback, file_dialog_cb,
 		 (XtPointer) &result);
+  XtAddCallback (dialog, XmNunmapCallback, file_dialog_unmap_cb,
+		 (XtPointer) &result);
 
   /* Disable the help button since we can't display help.  */
   help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
@@ -11188,7 +11205,7 @@
 
   /* Process events until the user presses Cancel or OK.  */
   result = 0;
-  while (result == 0 || XtAppPending (Xt_app_con))
+  while (result == 0)
     XtAppProcessEvent (Xt_app_con, XtIMAll);
 
   /* Get the result.  */