From: Po Lu Date: Sun, 1 May 2022 03:20:58 +0000 (+0000) Subject: Allow quitting inside font selection dialogs on Haiku X-Git-Tag: emacs-29.0.90~1931^2~166 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ece2ee965fe1db5fa30e2ed20b4a3b95b0da5db3;p=emacs.git 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'. --- diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 80b3dc7089a..776f2d5e7eb 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 c9f7737798e..96612227106 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 40e80aa9437..ecbe84aca28 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--;