Improve handling of tooltips inside menus on Haiku

* src/haiku_support.cc (BMenu_run): Make
`process_pending_signals_function' return a struct timespec.
* src/haiku_support.h: Update prototypes.
* src/haikumenu.c (haiku_process_pending_signals_for_menu):
Return result of `timer_run'.
* src/haikuterm.c (haiku_flush): Flip buffers if frame is dirty.
This commit is contained in:
Po Lu 2022-03-09 03:21:36 +00:00
parent 6e66d1f90a
commit 9cf69e1171
4 changed files with 27 additions and 10 deletions

View file

@ -2697,7 +2697,7 @@ BMenu_run (void *menu, int x, int y,
void (*run_help_callback) (void *, void *),
void (*block_input_function) (void),
void (*unblock_input_function) (void),
void (*process_pending_signals_function) (void),
struct timespec (*process_pending_signals_function) (void),
void *run_help_callback_data)
{
BPopUpMenu *mn = (BPopUpMenu *) menu;
@ -2705,10 +2705,12 @@ BMenu_run (void *menu, int x, int y,
void *buf;
void *ptr = NULL;
struct be_popup_menu_data data;
struct object_wait_info infos[2];
struct object_wait_info infos[3];
struct haiku_menu_bar_help_event *event;
BMessage *msg;
ssize_t stat;
struct timespec next_time;
bigtime_t timeout;
block_input_function ();
port_popup_menu_to_emacs = create_port (1800, "popup menu port");
@ -2733,6 +2735,10 @@ BMenu_run (void *menu, int x, int y,
(void *) &data);
infos[1].type = B_OBJECT_TYPE_THREAD;
infos[1].events = B_EVENT_INVALID;
infos[2].object = port_application_to_emacs;
infos[2].type = B_OBJECT_TYPE_PORT;
infos[2].events = B_EVENT_READ;
unblock_input_function ();
if (infos[1].object < B_OK)
@ -2749,10 +2755,16 @@ BMenu_run (void *menu, int x, int y,
while (true)
{
process_pending_signals_function ();
next_time = process_pending_signals_function ();
if ((stat = wait_for_objects_etc ((object_wait_info *) &infos, 2,
B_RELATIVE_TIMEOUT, 10000)) < B_OK)
if (next_time.tv_nsec < 0)
timeout = 100000;
else
timeout = (next_time.tv_sec * 1000000
+ next_time.tv_nsec / 1000);
if ((stat = wait_for_objects_etc ((object_wait_info *) &infos, 3,
B_RELATIVE_TIMEOUT, timeout)) < B_OK)
{
if (stat == B_INTERRUPTED || stat == B_TIMED_OUT)
continue;
@ -2792,6 +2804,7 @@ BMenu_run (void *menu, int x, int y,
infos[0].events = B_EVENT_READ;
infos[1].events = B_EVENT_INVALID;
infos[2].events = B_EVENT_READ;
}
}

View file

@ -744,7 +744,7 @@ extern "C"
void (*run_help_callback) (void *, void *),
void (*block_input_function) (void),
void (*unblock_input_function) (void),
void (*process_pending_signals_function) (void),
struct timespec (*process_pending_signals_function) (void),
void *run_help_callback_data);
extern void

View file

@ -340,13 +340,12 @@ haiku_menu_show_help (void *help, void *data)
show_help_echo (Qnil, Qnil, Qnil, Qnil);
}
static void
static struct timespec
haiku_process_pending_signals_for_menu (void)
{
process_pending_signals ();
input_pending = false;
detect_input_pending_run_timers (true);
return timer_check ();
}
Lisp_Object

View file

@ -2513,7 +2513,12 @@ haiku_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
static void
haiku_flush (struct frame *f)
{
if (FRAME_VISIBLE_P (f))
/* This is needed for tooltip frames to work properly with double
buffering. */
if (FRAME_DIRTY_P (f))
haiku_flip_buffers (f);
if (FRAME_VISIBLE_P (f) && !FRAME_TOOLTIP_P (f))
BWindow_Flush (FRAME_HAIKU_WINDOW (f));
}