tooltips in windows make more attempts to not overlap with pointer
authorMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 8 Dec 2014 01:09:28 +0000 (20:09 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 8 Dec 2014 01:22:30 +0000 (20:22 -0500)
this prevents (in most cases) a race condition where the pointer will continually trigger a show-hide-show loop due to slow X message processing

src/lib/els_tooltip.c

index 7d68cf0..836fbc3 100644 (file)
@@ -531,6 +531,26 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
    else if (ty < 0) ty -= tt->pad.by;
    else if (ty > ch) ty += tt->pad.by;
    TTDBG("PAD (BORDER):  tx=%d,ty=%d\n", tx, ty);
+   if (tt->tt_win)
+     {
+#define INSIDE(x, y, xx, yy, ww, hh) \
+  (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
+        /* attempt to ensure no overlap with pointer */
+        if (INSIDE(px, py, tx, ty, tw, th))
+          {
+             int ax, ay;
+
+             ax = tt->pad.x ?: 1;
+             ay = tt->pad.y ?: 1;
+             if (!INSIDE(px, py, tx, ty + (py - ty) + ay, tw, th))
+               ty += py - ty + ay;
+             else if (!INSIDE(px, py, tx + (px - tx) + ax, ty, tw, th))
+               tx += px - tx + ax;
+             else if (!INSIDE(px, py, tx + (px - tx) + ax, ty + (py - ty) + ay, tw, th))
+               tx += px - tx + ax, ty += py - ty + ay;
+          }
+#undef
+     }
    if (((tx < 0) && (tw < cw)) || ((ty < 0) && (th < ch)))
      {
         TTDBG("POSITIONING FAILED! THIS IS A BUG SOMEWHERE!\n");