emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ece2ee965f: Allow quitting inside font selection dialogs on Haiku


From: Po Lu
Subject: master ece2ee965f: Allow quitting inside font selection dialogs on Haiku
Date: Sat, 30 Apr 2022 23:21:20 -0400 (EDT)

branch: master
commit ece2ee965fe1db5fa30e2ed20b4a3b95b0da5db3
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Allow quitting inside font selection dialogs on Haiku
    
    * 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 | 10 ++++++++--
 src/haiku_support.h  |  2 +-
 src/haikufont.c      | 10 +++++++++-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 80b3dc7089..776f2d5e7e 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -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");
diff --git a/src/haiku_support.h b/src/haiku_support.h
index c9f7737798..9661222710 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -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
diff --git a/src/haikufont.c b/src/haikufont.c
index 40e80aa943..ecbe84aca2 100644
--- a/src/haikufont.c
+++ b/src/haikufont.c
@@ -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--;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]