]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow quitting inside font selection dialogs on Haiku
authorPo Lu <luangruo@yahoo.com>
Sun, 1 May 2022 03:20:58 +0000 (03:20 +0000)
committerPo Lu <luangruo@yahoo.com>
Sun, 1 May 2022 03:20:58 +0000 (03:20 +0000)
* src/haiku_support.cc (WaitForChoice): Accept new function for
checking quit flag.
(be_select_font): Pass that function.
* src/haiku_support.h: Update prototypes.
* src/haikufont.c (haikufont_should_quit_popup): New function.
(Fx_select_font): Give said function to `be_select_font'.

src/haiku_support.cc
src/haiku_support.h
src/haikufont.c

index 80b3dc7089ab554d7c72e349f89fdeebee5fbc4f..776f2d5e7ebf2726b835df77b7b0dbe4eb042a2e 100644 (file)
@@ -2650,7 +2650,8 @@ public:
 
   void
   WaitForChoice (struct font_selection_dialog_message *msg,
-                void (*process_pending_signals_function) (void))
+                void (*process_pending_signals_function) (void),
+                bool (*should_quit_function) (void))
   {
     int32 reply_type;
     struct object_wait_info infos[2];
@@ -2683,6 +2684,9 @@ public:
        if (infos[0].events & B_EVENT_READ)
          process_pending_signals_function ();
 
+       if (should_quit_function ())
+         goto cancel;
+
        infos[0].events = B_EVENT_READ;
        infos[1].events = B_EVENT_READ;
       }
@@ -4664,6 +4668,7 @@ be_get_ui_color (const char *name, uint32_t *color)
 
 bool
 be_select_font (void (*process_pending_signals_function) (void),
+               bool (*should_quit_function) (void),
                haiku_font_family_or_style *family,
                haiku_font_family_or_style *style,
                bool allow_monospace_only)
@@ -4684,7 +4689,8 @@ be_select_font (void (*process_pending_signals_function) (void),
     }
 
   dialog->Show ();
-  dialog->WaitForChoice (&msg, process_pending_signals_function);
+  dialog->WaitForChoice (&msg, process_pending_signals_function,
+                        should_quit_function);
 
   if (!dialog->LockLooper ())
     gui_abort ("Failed to lock font selection dialog looper");
index c9f7737798e81aa1031473adc2d51c5c7514833e..966122271065b9b76f6cd8ebc90a513853c1cf96 100644 (file)
@@ -659,7 +659,7 @@ extern bool be_drag_message (void *, void *, bool, void (*) (void),
 extern bool be_drag_and_drop_in_progress (void);
 
 extern bool be_replay_menu_bar_event (void *, struct haiku_menu_bar_click_event *);
-extern bool be_select_font (void (*process_pending_signals_function) (void),
+extern bool be_select_font (void (*) (void), bool (*) (void),
                            haiku_font_family_or_style *,
                            haiku_font_family_or_style *, bool);
 #ifdef __cplusplus
index 40e80aa943788f22260d2d91101d6060a4b35fd3..ecbe84aca2855bdaf7a3635a9793a8ffeb524c58 100644 (file)
@@ -1082,6 +1082,12 @@ struct font_driver const haikufont_driver =
     .list_family = haikufont_list_family
   };
 
+static bool
+haikufont_should_quit_popup (void)
+{
+  return !NILP (Vquit_flag);
+}
+
 DEFUN ("x-select-font", Fx_select_font, Sx_select_font, 0, 2, 0,
        doc: /* Read a font using a native dialog.
 Return a font spec describing the font chosen by the user.
@@ -1103,7 +1109,9 @@ in the font selection dialog.  */)
     error ("Trying to use a menu from within a menu-entry");
 
   popup_activated_p++;
-  rc = be_select_font (process_pending_signals, &family, &style,
+  rc = be_select_font (process_pending_signals,
+                      haikufont_should_quit_popup,
+                      &family, &style,
                       !NILP (exclude_proportional));
   popup_activated_p--;