Fix bug #16636 with simple dialogs on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Tue, 4 Feb 2014 16:13:51 +0000 (18:13 +0200)
committerEli Zaretskii <eliz@gnu.org>
Tue, 4 Feb 2014 16:13:51 +0000 (18:13 +0200)
 src/w32menu.c (w32_popup_dialog): Don't condition the whole function
 on HAVE_DIALOGS.  If the dialog is "simple", pop up a message box
 to show it; otherwise return 'unsupported--w32-dialog' to signal
 to the caller that emulation with menus is necessary.  This
 resurrects code inadvertently deleted by the 2013-10-08 commit.
 (syms_of_w32menu): DEFSYM Qunsupported__w32_dialog.
 src/w32term.h (w32_popup_dialog): Prototype is no longer conditioned
 by HAVE_DIALOGS.
 src/menu.c (Fx_popup_dialog): Don't condition the call to
 w32_popup_dialog on HAVE_DIALOGS.  If w32_popup_dialog returns a
 special symbol 'unsupported--w32-dialog', emulate the dialog with
 a menu by calling x-popup-menu.
 src/menu.h (Qunsupported__w32_dialog): New extern variable.

src/ChangeLog
src/menu.c
src/menu.h
src/w32menu.c
src/w32term.h

index 746bdff..5bba143 100644 (file)
@@ -1,3 +1,23 @@
+2014-02-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32menu.c (w32_popup_dialog): Don't condition the whole function
+       on HAVE_DIALOGS.  If the dialog is "simple", pop up a message box
+       to show it; otherwise return 'unsupported--w32-dialog' to signal
+       to the caller that emulation with menus is necessary.  This
+       resurrects code inadvertently deleted by the 2013-10-08 commit.
+       (Bug#16636)
+       (syms_of_w32menu): DEFSYM Qunsupported__w32_dialog.
+
+       * w32term.h (w32_popup_dialog): Prototype is no longer conditioned
+       by HAVE_DIALOGS.
+
+       * menu.c (Fx_popup_dialog): Don't condition the call to
+       w32_popup_dialog on HAVE_DIALOGS.  If w32_popup_dialog returns a
+       special symbol 'unsupported--w32-dialog', emulate the dialog with
+       a menu by calling x-popup-menu.
+
+       * menu.h (Qunsupported__w32_dialog): New extern variable.
+
 2014-02-04  Michael Albinus  <michael.albinus@gmx.de>
 
        * keyboard.c (kbd_buffer_get_event): Read file notification events
index c38152f..47ebc92 100644 (file)
@@ -1566,9 +1566,15 @@ for instance using the window manager, then this produces a quit and
     return xw_popup_dialog (f, header, contents);
   else
 #endif
-#if defined (HAVE_NTGUI) && defined (HAVE_DIALOGS)
+#if defined (HAVE_NTGUI)
   if (FRAME_W32_P (f))
-    return w32_popup_dialog (f, header, contents);
+    {
+      Lisp_Object selection = w32_popup_dialog (f, header, contents);
+
+      if (!EQ (selection, Qunsupported__w32_dialog))
+       return selection;
+      goto dialog_via_menu;
+    }
   else
 #endif
 #ifdef HAVE_NS
@@ -1582,6 +1588,8 @@ for instance using the window manager, then this produces a quit and
     Lisp_Object x, y, frame, newpos, prompt;
     int x_coord, y_coord;
 
+  dialog_via_menu:
+
     prompt = Fcar (contents);
     if (FRAME_WINDOW_P (f))
       {
index ae97fe2..429dcfa 100644 (file)
@@ -21,6 +21,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "systime.h" /* for Time */
 
+#ifdef HAVE_NTGUI
+extern Lisp_Object Qunsupported__w32_dialog;
+#endif
+
 extern void x_set_menu_bar_lines (struct frame *f,
                                   Lisp_Object value,
                                   Lisp_Object oldval);
index c0983a7..a4acdfd 100644 (file)
@@ -98,7 +98,7 @@ AppendMenuW_Proc unicode_append_menu = NULL;
 MessageBoxW_Proc unicode_message_box = NULL;
 #endif /* NTGUI_UNICODE */
 
-Lisp_Object Qdebug_on_next_call;
+Lisp_Object Qdebug_on_next_call, Qunsupported__w32_dialog;
 
 void set_frame_menubar (struct frame *, bool, bool);
 
@@ -114,34 +114,44 @@ static int fill_in_menu (HMENU, widget_value *);
 
 void w32_free_menu_strings (HWND);
 
-#ifdef HAVE_DIALOGS
 Lisp_Object
 w32_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
 {
-  Lisp_Object title;
-  char *error_name;
-  Lisp_Object selection;
 
   check_window_system (f);
 
-  /* Decode the dialog items from what was specified.  */
-  title = Fcar (contents);
-  CHECK_STRING (title);
+#ifndef HAVE_DIALOGS
 
-  list_of_panes (Fcons (contents, Qnil));
+  /* Handle simple Yes/No choices as MessageBox popups.  */
+  if (is_simple_dialog (contents))
+    return simple_dialog_show (f, contents, header);
+  else
+    return Qunsupported__w32_dialog;
+#else  /* HAVE_DIALOGS */
+    {
+      Lisp_Object title;
+      char *error_name;
+      Lisp_Object selection;
 
-  /* Display them in a dialog box.  */
-  block_input ();
-  selection = w32_dialog_show (f, 0, title, header, &error_name);
-  unblock_input ();
+      /* Decode the dialog items from what was specified.  */
+      title = Fcar (contents);
+      CHECK_STRING (title);
 
-  discard_menu_items ();
-  FRAME_DISPLAY_INFO (f)->grabbed = 0;
+      list_of_panes (Fcons (contents, Qnil));
 
-  if (error_name) error (error_name);
-  return selection;
-}
+      /* Display them in a dialog box.  */
+      block_input ();
+      selection = w32_dialog_show (f, 0, title, header, &error_name);
+      unblock_input ();
+
+      discard_menu_items ();
+      FRAME_DISPLAY_INFO (f)->grabbed = 0;
+
+      if (error_name) error (error_name);
+      return selection;
+    }
 #endif /* HAVE_DIALOGS */
+}
 
 /* Activate the menu bar of frame F.
    This is called from keyboard.c when it gets the
@@ -1621,6 +1631,7 @@ syms_of_w32menu (void)
   current_popup_menu = NULL;
 
   DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
+  DEFSYM (Qunsupported__w32_dialog, "unsupported--w32-dialog");
 
   defsubr (&Smenu_or_popup_active_p);
 }
index f85e6bc..e3b65f0 100644 (file)
@@ -781,9 +781,7 @@ typedef char guichar_t;
 
 #define GUI_SDATA(x) ((guichar_t*) SDATA (x))
 
-#if defined HAVE_DIALOGS
 extern Lisp_Object w32_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
-#endif
 
 extern void syms_of_w32term (void);
 extern void syms_of_w32menu (void);