]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix flickering system tooltips on Haiku
authorPo Lu <luangruo@yahoo.com>
Fri, 8 Jul 2022 06:55:01 +0000 (06:55 +0000)
committerPo Lu <luangruo@yahoo.com>
Fri, 8 Jul 2022 06:55:01 +0000 (06:55 +0000)
* src/haiku_support.cc (class EmacsView, MouseMoved): Restore
sticky status and mouse relative position.
(BView_set_and_show_sticky_tooltip):
* src/haikufns.c (haiku_hide_tip): Fix coding style.

src/haiku_support.cc
src/haikufns.c

index 9e38d9556fb0e61e3f9e595b1930d4be790f59c7..332321e2db9714fa5ccc75531968e1b6291928e1 100644 (file)
@@ -1517,7 +1517,7 @@ public:
   BLocker cr_surface_lock;
 #endif
 
-  BPoint tt_absl_pos;
+  BPoint tooltip_position;
   BMessage *wait_for_release_message;
 
   EmacsView () : BView (BRect (0, 0, 0, 0), "Emacs",
@@ -1798,11 +1798,16 @@ public:
     int32 windowid;
     EmacsWindow *window;
     BToolTip *tooltip;
+    BPoint target_tooltip_position;
 
     window = (EmacsWindow *) Window ();
     tooltip = ToolTip ();
 
-    rq.just_exited_p = transit == B_EXITED_VIEW;
+    if (transit == B_EXITED_VIEW)
+      rq.just_exited_p = true;
+    else
+      rq.just_exited_p = false;
+
     rq.x = point.x;
     rq.y = point.y;
     rq.window = window;
@@ -1817,8 +1822,14 @@ public:
       rq.dnd_message = false;
 
     if (tooltip)
-      tooltip->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x),
-                                                -(point.y - tt_absl_pos.y)));
+      {
+       target_tooltip_position
+         = BPoint (-(point.x - tooltip_position.x),
+                   -(point.y - tooltip_position.y));
+       tooltip->SetMouseRelativeLocation (target_tooltip_position);
+       tooltip->SetSticky (true);
+       ShowToolTip (tooltip);
+      }
 
     if (!grab_view_locker.Lock ())
       gui_abort ("Couldn't lock grab view locker");
@@ -4309,19 +4320,26 @@ BView_set_tooltip (void *view, const char *tooltip)
 
 /* Set VIEW's tooltip to a sticky tooltip at X by Y.  */
 void
-BView_set_and_show_sticky_tooltip (void *view, const char *tooltip,
+BView_set_and_show_sticky_tooltip (void *view, const char *tooltip_text,
                                   int x, int y)
 {
-  BToolTip *tip;
-  BView *vw = (BView *) view;
+  BToolTip *tooltip;
+  BView *vw;
+  EmacsView *ev;
+  BPoint pt;
+
+  vw = (BView *) view;
+
   if (!vw->LockLooper ())
     gui_abort ("Failed to lock view while showing sticky tooltip");
-  vw->SetToolTip (tooltip);
-  tip = vw->ToolTip ();
-  BPoint pt;
-  EmacsView *ev = dynamic_cast<EmacsView *> (vw);
+
+  vw->SetToolTip (tooltip_text);
+  tooltip = vw->ToolTip ();
+
+  ev = dynamic_cast<EmacsView *> (vw);
+
   if (ev)
-    ev->tt_absl_pos = BPoint (x, y);
+    ev->tooltip_position = BPoint (x, y);
 
   vw->GetMouse (&pt, NULL, 1);
   pt.x -= x;
@@ -4330,9 +4348,10 @@ BView_set_and_show_sticky_tooltip (void *view, const char *tooltip,
   pt.x = -pt.x;
   pt.y = -pt.y;
 
-  tip->SetMouseRelativeLocation (pt);
-  tip->SetSticky (1);
-  vw->ShowToolTip (tip);
+  tooltip->SetMouseRelativeLocation (pt);
+  tooltip->SetSticky (true);
+
+  vw->ShowToolTip (tooltip);
   vw->UnlockLooper ();
 }
 
index b79443203ff775d965d56dc94e035ded4c08f6cb..878917eeef7c06852c62d7e169ae8c8150e9f5cc 100644 (file)
@@ -1290,16 +1290,17 @@ compute_tip_xy (struct frame *f,
 static Lisp_Object
 haiku_hide_tip (bool delete)
 {
+  Lisp_Object it, frame;
+
   if (!NILP (tip_timer))
     {
       call1 (Qcancel_timer, tip_timer);
       tip_timer = Qnil;
     }
 
-  Lisp_Object it, frame;
   FOR_EACH_FRAME (it, frame)
-    if (FRAME_WINDOW_P (XFRAME (frame)) &&
-       FRAME_HAIKU_VIEW (XFRAME (frame)))
+    if (FRAME_WINDOW_P (XFRAME (frame))
+       && FRAME_HAIKU_VIEW (XFRAME (frame)))
       BView_set_tooltip (FRAME_HAIKU_VIEW (XFRAME (frame)), NULL);
 
   if (NILP (tip_frame)