]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve handling of tooltips inside menus on Haiku
authorPo Lu <luangruo@yahoo.com>
Wed, 9 Mar 2022 03:21:36 +0000 (03:21 +0000)
committerPo Lu <luangruo@yahoo.com>
Wed, 9 Mar 2022 03:22:04 +0000 (03:22 +0000)
* 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.

src/haiku_support.cc
src/haiku_support.h
src/haikumenu.c
src/haikuterm.c

index 057464c9088607754333974b91d80de14ce7e1b2..2f2adfd8f8a003a39c23840b89f95c4eda4f199d 100644 (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 (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, 2,
-                                       B_RELATIVE_TIMEOUT, 10000)) < B_OK)
+      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;
     }
 }
 
index 04079edbbc557ca92f26f1423c3967c551a24341..fb86372c4ff2366872ea3ca3659fa0da2537de2a 100644 (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
index 74328086d6fc6ae4768922d58e6a2efda4916807..2f75a5dd03ec1ef6ed609854c6b19ce0aa0bf530 100644 (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
index 633e87fd4352a080eaf6a58cd086ebf094ff11b2..3950e45fe9bd557bbb361f53f215f6f8b61d4b0e 100644 (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));
 }