emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bc015a7b44: Fix flickering system tooltips on Haiku


From: Po Lu
Subject: master bc015a7b44: Fix flickering system tooltips on Haiku
Date: Fri, 8 Jul 2022 02:55:27 -0400 (EDT)

branch: master
commit bc015a7b44ab0803cfc35f69987eb28d9f4597e1
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix flickering system tooltips on Haiku
    
    * 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 | 49 ++++++++++++++++++++++++++++++++++---------------
 src/haikufns.c       |  7 ++++---
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 9e38d9556f..332321e2db 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -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 ();
 }
 
diff --git a/src/haikufns.c b/src/haikufns.c
index b79443203f..878917eeef 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]