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'.
This commit is contained in:
Po Lu 2022-05-01 03:20:58 +00:00
parent ed0de6200d
commit ece2ee965f
3 changed files with 18 additions and 4 deletions

View file

@ -2650,7 +2650,8 @@ class EmacsFontSelectionDialog : public BWindow
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 @@ class EmacsFontSelectionDialog : public BWindow
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");

View 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

View 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--;