tooltips: hide tooltips before showing popups
because if there's a tooltip visible then popups fail to show
with the following warning:
"Gdk-WARNING **: Tried to map a popup with a non-top most parent"
This bug affect popups of the form:
 1) popups from gtk_menu_popup_{at_widget|at_rect|for_device}()
    This can be reproduce with a normal GtkComboBox that has a
    tooltip attached (eg. via GtkBuilder 'tooltip_text' attribute).
    Also see GtkLabel reproducer from gtk3-demo mentioned in #1785
 2) custom popups created with gtk_window_new (GTK_WINDOW_POPUP)
    A reproducer that shows this case is a GtkComboBox with
    the property 'appears-as-list'[1] set to TRUE (default is FALSE).
Fixes issue #1785
[1] https://developer.gnome.org/gtk3/stable/GtkComboBox.html#GtkComboBox--s-appears-as-list
			
			
This commit is contained in:
		@ -44,6 +44,7 @@
 | 
			
		||||
#include "gtkwindow.h"
 | 
			
		||||
#include "gtktypebuiltins.h"
 | 
			
		||||
#include "gtkprivate.h"
 | 
			
		||||
#include "gtktooltipprivate.h"
 | 
			
		||||
#include "gtkcomboboxprivate.h"
 | 
			
		||||
 | 
			
		||||
#include <gobject/gvaluecollector.h>
 | 
			
		||||
@ -2315,6 +2316,7 @@ gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  _gtk_tooltip_hide (GTK_WIDGET (combo_box));
 | 
			
		||||
  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
 | 
			
		||||
  if (GTK_IS_WINDOW (toplevel))
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -133,6 +133,7 @@
 | 
			
		||||
#include "gtkcssnodeprivate.h"
 | 
			
		||||
#include "gtkstylecontextprivate.h"
 | 
			
		||||
#include "gtkcssstylepropertyprivate.h"
 | 
			
		||||
#include "gtktooltipprivate.h"
 | 
			
		||||
 | 
			
		||||
#include "deprecated/gtktearoffmenuitem.h"
 | 
			
		||||
 | 
			
		||||
@ -1824,6 +1825,7 @@ gtk_menu_popup_internal (GtkMenu             *menu,
 | 
			
		||||
  g_return_if_fail (GTK_IS_MENU (menu));
 | 
			
		||||
  g_return_if_fail (device == NULL || GDK_IS_DEVICE (device));
 | 
			
		||||
 | 
			
		||||
  _gtk_tooltip_hide_in_display (gtk_widget_get_display (GTK_WIDGET (menu)));
 | 
			
		||||
  display = gtk_widget_get_display (GTK_WIDGET (menu));
 | 
			
		||||
 | 
			
		||||
  if (device == NULL)
 | 
			
		||||
 | 
			
		||||
@ -1280,6 +1280,22 @@ _gtk_tooltip_hide (GtkWidget *widget)
 | 
			
		||||
    gtk_tooltip_hide_tooltip (tooltip);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_gtk_tooltip_hide_in_display (GdkDisplay *display)
 | 
			
		||||
{
 | 
			
		||||
  GtkTooltip *tooltip;
 | 
			
		||||
 | 
			
		||||
  if (!display)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
 | 
			
		||||
 | 
			
		||||
  if (!tooltip || !GTK_TOOLTIP_VISIBLE (tooltip))
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  gtk_tooltip_hide_tooltip (tooltip);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
tooltips_enabled (GdkEvent *event)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,7 @@ void _gtk_tooltip_focus_out              (GtkWidget          *widget);
 | 
			
		||||
void _gtk_tooltip_toggle_keyboard_mode   (GtkWidget          *widget);
 | 
			
		||||
void _gtk_tooltip_handle_event           (GdkEvent           *event);
 | 
			
		||||
void _gtk_tooltip_hide                   (GtkWidget          *widget);
 | 
			
		||||
void _gtk_tooltip_hide_in_display        (GdkDisplay         *display);
 | 
			
		||||
 | 
			
		||||
GtkWidget * _gtk_widget_find_at_coords   (GdkWindow          *window,
 | 
			
		||||
                                          gint                window_x,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user