]> git.eshelyaron.com Git - emacs.git/commitdiff
Make last change of w32 GUI dialogs conditional and reversible
authorEli Zaretskii <eliz@gnu.org>
Wed, 28 Dec 2022 13:10:39 +0000 (15:10 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 28 Dec 2022 13:10:39 +0000 (15:10 +0200)
* src/w32term.c (syms_of_w32term) <w32-yes-no-dialog-show-cancel>:
New boolean variable.
(w32_initialize): Fix query for visible system caret: 'bool' is a
single-byte data type, whereas SystemParametersInfo wants a BOOL,
which is a 32-bit int.
* src/w32menu.c (simple_dialog_show): Show "Cancel" button only if
'w32-yes-no-dialog-show-cancel' is non-nil.

* etc/NEWS: Announce the change.

etc/NEWS
src/w32menu.c
src/w32term.c

index c64db9973d2f247191998149f4e47ab715db36ef..3060bba5e93f186e1163b365ec8b95af3d7d3d09 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -4701,6 +4701,15 @@ where those APIs are available.
 When 'w32-use-native-image-API' is non-nil, Emacs on MS-Windows now
 has built-in support for displaying BMP images.
 
+---
+*** GUI Yes/No dialogs now include a "Cancel" button.
+The "Cancel" button is in addition to "Yes" and "No", and is intended
+to allow users to quit the dialog, as an equivalent of C-g when Emacs
+asks a yes/no question via the echo area.  This is controlled by the
+new variable 'w32-yes-no-dialog-show-cancel', by default t.  Set it to
+nil to get back the old behavior of showing a modal dialog with only
+two buttons: "Yes" and "No".
+
 ** Cygwin
 
 ---
index c6d1efaf25bc819e37f3e54c130c77a187c6d329..5f06f4c41706efc583a67cf422e47c7ba6fdd5be 100644 (file)
@@ -1091,7 +1091,10 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
   /* We use MB_YESNOCANCEL to allow the user the equivalent of C-g
      when the Yes/No question is asked vya y-or-n-p or
      yes-or-no-p.  */
-  type = MB_YESNOCANCEL;
+  if (w32_yes_no_dialog_show_cancel)
+    type = MB_YESNOCANCEL;
+  else
+    type = MB_YESNO;
 
   /* Since we only handle Yes/No dialogs, and we already checked
      is_simple_dialog, we don't need to worry about checking contents
index dff21489e5b32dc663593bcef441c8671888e51f..e40e4588fde17c3ea02b031337e637393b452c71 100644 (file)
@@ -7696,6 +7696,7 @@ static void
 w32_initialize (void)
 {
   HANDLE shell;
+  BOOL caret;
   HRESULT (WINAPI * set_user_model) (const wchar_t * id);
 
   baud_rate = 19200;
@@ -7732,8 +7733,9 @@ w32_initialize (void)
 
   /* Initialize w32_use_visible_system_caret based on whether a screen
      reader is in use.  */
-  if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
-                            &w32_use_visible_system_caret, 0))
+  if (SystemParametersInfo (SPI_GETSCREENREADER, 0, &caret, 0))
+    w32_use_visible_system_caret = caret == TRUE;
+  else
     w32_use_visible_system_caret = 0;
 
   any_help_event_p = 0;
@@ -7923,6 +7925,11 @@ unconditionally set to nil on older systems.  */);
   w32_use_native_image_api = 0;
 #endif
 
+  DEFVAR_BOOL ("w32-yes-no-dialog-show-cancel",
+              w32_yes_no_dialog_show_cancel,
+     doc: /* If non-nil, show Cancel button in MS-Windows GUI Yes/No dialogs. */);
+  w32_yes_no_dialog_show_cancel = 1;
+
   /* FIXME: The following variable will be (hopefully) removed
      before Emacs 25.1 gets released.  */