After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 516130 - gtktooltip calls query function too soon
gtktooltip calls query function too soon
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 574941 580090 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-02-12 22:04 UTC by Allison Karlitskaya (desrt)
Modified: 2017-07-30 11:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
query_tooltip should not reset the timer (1.89 KB, patch)
2011-11-13 17:01 UTC, Joachim Breitner
none Details | Review
Redone the patch with git. (2.38 KB, patch)
2011-11-20 12:17 UTC, Joachim Breitner
none Details | Review
Rebased. (2.38 KB, patch)
2012-04-30 20:52 UTC, Joachim Breitner
none Details | Review

Description Allison Karlitskaya (desrt) 2008-02-12 22:04:16 UTC
i wrote a query function and enabled has-tooltip on a gtkwidget.

merely moving the mouse pointer across the window causes my query function to be called many times (even though i never stopped the mouse long enough to cause a tooltip to appear)

the query function should probably only be called once the mouse has been still long enough for a tooltip to actually be displayed.
Comment 1 Björn Lindqvist 2008-03-22 04:34:04 UTC
It seems like the query-tooltip signal is emitted on motion-notify, enter-notify, leave-notify and scroll events and when it is time to show the tooltip. Which is not at all what the documentation says: "Emitted when the "gtk-tooltip-timeout" has expired with the cursor hovering "above" widget". The signal is not emitted unless the has-tooltip property is TRUE. 

But in the description of the tooltip API here http://lists.zerezo.com/gtk-devel/msg02385.html it is said that "once gtk is in tooltip mode, ::query_tooltip() is simply emitted as the pointer moves." So either the documentation is wrong or the implementation. 
Comment 2 Kristian Rietveld 2008-09-29 16:14:47 UTC
I agree that the code can be reworked to delay the actual queries.  What you are seeing right now is probably this:

1st motion-event: no tooltip exists, one is created (no query here).
2nd motion-event: tooltip exists, via query we check whether to renew the popup timeout or terminate it.

We can probably opt for always renewing the timeout and deciding in the popup timeout handler (if the tooltip is not visible yet).

Also there are plans to limit the amount of calls to the query handler by doing some kind of throttling, a few people have also complained about superfluous calls to their query handlers.
Comment 3 Douglas Peale 2010-10-13 20:36:39 UTC
I ran into this problem as well. I tried to reduce the traffic by changing the tooltip text at most only once every 10 seconds, but found that the tooltip would then be empty. So I created my text and saved it only once every ten seconds, but set the tooltip text every single time the callback was called.

This call back would be much more efficient if it was only called after the timeout the way it is documented.
Comment 4 Nick Schermer 2011-01-23 11:27:58 UTC
This issue is still not resolved.
Comment 5 Joachim Breitner 2011-11-13 16:16:57 UTC
This seems to be duplicated in bug #574941 and bug #580090, and causes problems in various applications, see bug #645284, bug #581311 and bug #636615.

It seems that it is not correct for gtk_tooltip_trigger_tooltip_query() to just create a fake mouse move event, as a real mouse move event should reset the timer, while a tooltip_query() should do all the rest that is done in _gtk_tooltip_handle_event, but not reset the timer if it is already running.
Comment 6 Joachim Breitner 2011-11-13 17:01:21 UTC
I have just tested the attached bug, and it fixes the problem described in bug #636615 for me.
Comment 7 Joachim Breitner 2011-11-13 17:01:45 UTC
Created attachment 201321 [details] [review]
query_tooltip should not reset the timer
Comment 8 Paolo Borelli 2011-11-20 07:37:04 UTC
Review of attachment 201321 [details] [review]:

Just a couple of formal comments while you wait for review of a gtk maintainer...


Also if possible, please attach a patch with git format-patch that includes the commit message with the rationale of the change.

::: gtk+3.0-3.0.12.orig/gtk/gtktooltip.c
@@ +1507,3 @@
+
+void
+_gtk_tooltip_handle_event_real (GdkEvent *event, gboolean may_reset)

This can be a static function that does not need to go in the .h file, just define it before _gtk_tooltip_handle_event

@@ +1618,3 @@
 	    if (hide_tooltip)
 	      gtk_tooltip_hide_tooltip (current_tooltip);
 	    else

"else if" on the same line
Comment 9 Joachim Breitner 2011-11-20 10:36:17 UTC
Thanks for the hints. The gtk-git-repo is so large that I aborted the pull and based my change on the debian package... but I’ll download it again, recreate the patch and make the _real function static. This has also the advantage that I’ll likely appear as the Author of the patch in the gtk repo, which does not always happen with free-form patch files :-)
Comment 10 Joachim Breitner 2011-11-20 12:17:24 UTC
Created attachment 201737 [details] [review]
Redone the patch with git.
Comment 11 Joachim Breitner 2012-02-17 20:56:15 UTC
I’m cleaning out my home directory and found a git repo with a path that did not make it upstream yet, so I’m checking back: Did anybody review the patch yet?
Comment 12 Joachim Breitner 2012-02-17 20:57:41 UTC
I should add, just for reference, that the bug is still present in gtk 3.2.3.
Comment 13 Joachim Breitner 2012-04-30 20:52:16 UTC
Created attachment 213141 [details] [review]
Rebased.

I just rebased the patch to current master, hoping it will eventually get applied.
Comment 14 Joachim Breitner 2012-11-25 17:34:01 UTC
By now, the bug #636615, which I assumed was caused by this, is closed, and I also cannot reproduce the problem described here any more. Guess this was fixed by something else and can be closed.
Comment 15 Cosimo Cecchi 2012-11-26 13:54:02 UTC
Closing as OBSOLETE for comment #14. Feel free to reopen if this proves to still be an issue.
Comment 16 Yann Leboulanger 2012-12-27 22:46:51 UTC
I don't know in which version it's supposed to be fixed, but I'm using GTK 3.6.1, and query-tooltip is still call on every movement instead of 500ms after the last movement.
Comment 17 Daniel Boles 2017-07-30 11:26:28 UTC
*** Bug 574941 has been marked as a duplicate of this bug. ***
Comment 18 Daniel Boles 2017-07-30 11:26:34 UTC
*** Bug 580090 has been marked as a duplicate of this bug. ***