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 698730 - [PATCH] tooltip: Fix possible wrong placement
[PATCH] tooltip: Fix possible wrong placement
Status: RESOLVED DUPLICATE of bug 703460
Product: gtk+
Classification: Platform
Component: Widget: Other
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 721583 733887 754109 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-04-24 13:12 UTC by Olivier Brunel (jjacky)
Modified: 2018-03-30 14:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tooltip: Fix possible wrong placement (1.47 KB, patch)
2013-04-24 13:12 UTC, Olivier Brunel (jjacky)
none Details | Review
tooltip: Fix possible wrong placement (1008 bytes, patch)
2013-10-15 15:34 UTC, Olivier Brunel (jjacky)
committed Details | Review
tooltip: Fix possibly briefly appearing at 0x0 (2.06 KB, patch)
2013-11-15 21:20 UTC, Olivier Brunel (jjacky)
needs-work Details | Review
on every twice try, tooltip is not centered on the window but is placed far left, half outside (33.85 KB, image/png)
2014-02-18 22:34 UTC, Thierry Vignaud
  Details
another misplacement example with drakx (Mageia installer) (32.46 KB, image/png)
2014-02-18 22:35 UTC, Thierry Vignaud
  Details

Description Olivier Brunel (jjacky) 2013-04-24 13:12:58 UTC
Created attachment 242321 [details] [review]
tooltip: Fix possible wrong placement

When showing a tooltip on the edge of a monitor, the tooltip could be wrongly
placed and be shown going from one monitor to the next.

This happened because the current_window wasn't set visible, and when it wasn't
the returned allocated size would be 1, hence wrong calculations.

(See b495ce5446a0 for why the allocated size is 1 when not visible.)

With GTK 3.8: it seems the tooltip would be correctly placed at first, but if
moving the mouse (hiding it) and waiting a bit (re-showing it) it would then
always be wrongly placed.
I'm guessing this might be a bug in the fix for #696882, that made it return a
wrong size the first time (since current_window isn't visible then either).

(I use my patch to fix #696882, and I'd always have the tooltip wrongly placed.)
Comment 1 Olivier Brunel (jjacky) 2013-10-15 15:34:03 UTC
Created attachment 257359 [details] [review]
tooltip: Fix possible wrong placement

Updated patch.
Comment 2 Matthias Clasen 2013-10-16 01:00:36 UTC
Attachment 257359 [details] pushed as 1922b7d - tooltip: Fix possible wrong placement
Comment 3 Michael Webster 2013-11-15 18:00:03 UTC
Hi,

This appears to be causing trouble with GtkTreeViews and GtkIconViews - what seems to occur with them is tooltips have an initial position of X0,Y0, and are shown in the upper left corner of the screen briefly before being positioned correctly.

Removing this line prevents this from occurring.
Comment 4 Olivier Brunel (jjacky) 2013-11-15 21:20:06 UTC
Created attachment 259950 [details] [review]
tooltip: Fix possibly briefly appearing at 0x0

Ok, coudln't reproduce it but I think this should fix it. Instead of making the window visible, the natural size is used when the allocation isn't available/was reset.
Comment 5 Thierry Vignaud 2013-12-06 08:28:31 UTC
This regression affects Mageia linux installer:
https://bugs.mageia.org/show_bug.cgi?id=11893

I confirm the patch in comment #4 fixes the issue for Mageia
Comment 6 sébastien lafargue 2014-02-13 18:53:08 UTC
I confirm it fix a bug on Gedit too.
Comment 7 Jeffrey Knockel 2014-02-16 17:33:30 UTC
The patch that was committed in comment #2 is also causing application launcher tooltips to flicker on gnome-panel, but the patch in comment #4 fixes this regression.
Comment 8 Thierry Vignaud 2014-02-17 17:32:55 UTC
Actually while this patch fixes most misplacements, I still see some tooltips misplaced (but not at top, rather at full left) with Mga installer
Comment 9 Thierry Vignaud 2014-02-18 22:34:48 UTC
Created attachment 269631 [details]
on every twice try, tooltip is not centered on the window but is placed far left, half outside
Comment 10 Thierry Vignaud 2014-02-18 22:35:12 UTC
Created attachment 269632 [details]
another misplacement example with drakx (Mageia installer)
Comment 11 Michael Webster 2014-05-08 15:22:08 UTC
Any update on this?  I realize this does not occur in gnome-shell, and have been trying to nail down why this is the case.  I'm assuming it has to do with the frame sync implementation that was implemented in Gtk and mutter, but even injecting those changes into my wm has not solved the issue.  Obviously I'm not seeing the full picture, or am missing something critical and/or basic - perhaps something not directly related to frame syncing.

I know I could apply this second proposed patch here and solve my problem in my distro, but I'd rather learn, understand things correctly, and do the proper fix (and maintain a well-behaved wm in the process).

Thanks a lot.
Comment 12 Matthias Clasen 2014-05-09 15:49:59 UTC
I've discussed this bug with Benjamin, and here is an outline of how we want to address this:

1) Add _gtk_window_set_position_func which us set a callback for determining a position

2) Call it in gtk_window_constrain_position when it is set

3) Make use of this for positioning tooltips

4) For extra credit, convert menus to use it too

Note that we want to keep this API private, since it won't work on Wayland
Comment 13 Matthias Clasen 2014-07-28 22:15:01 UTC
*** Bug 733887 has been marked as a duplicate of this bug. ***
Comment 14 edscott 2014-08-15 19:28:03 UTC
As a quick hack, your application can use a custom tooltip widget and move it down to the bottom right hand corner of the screen to avoid seeing the flashing and to avoid a collision with the pointer location.
Comment 15 Olav Vitters 2015-02-13 08:06:14 UTC
Could we have this in for GTK+ 3.15.x? I accidentally dropped the patch we were carrying in Mageia and that mistake took quite a while to sort out.
Comment 16 Carlos Garcia Campos 2015-09-02 10:41:06 UTC
Yes, this broke tooltips in matchbox window manager, it seems matchbox uses the window position when the map is requested, but ignores any move_resize donde afterwards. I also confirm patch in comment #4 fixes the issue.
Comment 17 Alex Băluț 2015-11-03 01:15:55 UTC
Also happens in Pitivi with the tooltips for the clips in the timeline.
Comment 18 edscott 2015-11-03 15:04:14 UTC
*** Bug 721583 has been marked as a duplicate of this bug. ***
Comment 19 mi 2016-01-28 09:07:17 UTC
FYI - 
I've suggested another workaround (patch) for this bug on my duplicate report:
Bug 754109
https://bugzilla.gnome.org/show_bug.cgi?id=754109
Comment 20 Alexandre Franke 2016-11-24 15:27:02 UTC
*** Bug 754109 has been marked as a duplicate of this bug. ***
Comment 21 Alexandre Franke 2016-11-24 15:55:54 UTC
(In reply to mi from comment #19)
> FYI - 
> I've suggested another workaround (patch) for this bug on my duplicate
> report:
> Bug 754109
> https://bugzilla.gnome.org/show_bug.cgi?id=754109

Can you please reattach here your patch from there? It's better to keep a single report open and do review in one place.
Comment 22 Daniel Boles 2017-07-31 19:27:58 UTC
Review of attachment 259950 [details] [review]:

Just cosmetic comments, in case this is ever picked back up.

::: gtk/gtktooltip.c
@@ +1104,3 @@
   width = gtk_widget_get_allocated_width (GTK_WIDGET (tooltip->current_window));
   height = gtk_widget_get_allocated_height (GTK_WIDGET (tooltip->current_window));
+  /* if window was hidden, it's allocation was reset to { -1, -1, 1, 1 } and

Substitute to "If" and "its"

@@ +1107,3 @@
+   * using such invalid width/height might lead to wrong placement.
+   * In such a case, get the natural size instead to perform calculation.
+   * See bug #698730 */

Afaict, bug refs are only included if the fix is a kludge or otherwise temporary. If not, i.e. if the patch is the ideal code and will not need changed, no reference should be included in the diff, only in the commit message, and users who want to know why the code was added will git blame and get to this bug that way.

@@ +1113,3 @@
+
+      gtk_widget_get_preferred_size (GTK_WIDGET (tooltip->current_window),
+              NULL, &requisition);

GTK+'s coding style keeps arguments either on one line or left-aligned below the first argument; not hanging like this
Comment 23 Daniel Boles 2018-03-30 14:52:00 UTC

*** This bug has been marked as a duplicate of bug 703460 ***